cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bart Molenkamp" <b.molenk...@bizzdesign.nl>
Subject RE: JXPath
Date Wed, 02 Feb 2005 14:26:16 GMT
I forgot to say, you can get an input stream from the source. E.g.

var inputStream = source.getInputStream();

You can pass this source to the parser as the source of your xml.

> -----Original Message-----
> From: Bart Molenkamp
> Sent: Wednesday, February 02, 2005 3:25 PM
> To: users@cocoon.apache.org
> Subject: RE: JXPath
> 
> var sourceResolver =
> cocoon.getComponent(Packages.org.apache.excalibur.source.SourceResolver.RO
> LE);
> var source = sourceResolver.resolveURI("cocoon:/xmldata/users.xml");
> var document = ...;	// parse the document
> var context =
> org.apache.commons.jxpath.JXPathContext.newContext(document);
> 
> ...
> 
> To parse the document, you'll need a parser. Have a look at
> org.apache.cocoon.forms.util.DomHelper.parse() [1].
> Or lookup the service "org.apache.excalibur.xml.dom.DOMParser" (never used
> that one myself).
> 
> This is an example of how you could parse XML. You must parse it to a
> Document, and create a context on that document.
> 
> [1]
> http://svn.apache.org/repos/asf/cocoon/branches/BRANCH_2_1_X/src/blocks/fo
> rms/java/org/apache/cocoon/forms/util/DomHelper.java
> 
> -----Original Message-----
> From: Roberto [mailto:rmarra@montefiore.ch]
> Sent: Wednesday, February 02, 2005 3:13 PM
> To: users@cocoon.apache.org
> Subject: Re: JXPath
> 
> Sorry Im still new on Cocoon can you make me an example pls?
> Thanx
> 
> ROb
> ----- Original Message -----
> From: Bart Molenkamp
> To: users@cocoon.apache.org
> Sent: Wednesday, February 02, 2005 2:14 PM
> Subject: RE: JXPath
> 
> I think that JXPath doesn't understand the cocoon:/ scheme. You should use
> the source resolver, resolve the source,
> Parse it, and pass the document to JXPathContext.newContext();
> 
> -----Original Message-----
> From: Roberto [mailto:rmarra@montefiore.ch]
> Sent: Wednesday, February 02, 2005 11:42 AM
> To: users@cocoon.apache.org
> Subject: JXPath
> 
> Hi cocoon developers,
> Im trying to use JXPath to read the value of xml file in a flow, like
> that:
> 
>     var context =
> org.apache.commons.jxpath.JXPathContext.newContext("cocoon:/xmldata/users.
> xml");
>     var value =
> toString(context.getValue("autentication/users/user[@id='1']/pwd"));
> The xml file is:
> 
> <autentication>
> <users>
> <user id="1">
> <userName type="internal" lang="it">Roberto</userName>
> <pwd>pippo</pwd>
> </user>
> </autentication>
> 
> The problem is that the value variable is null. What's wrong with me?
> 
> Thanx in advance
> Cheers
> Roberto
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message