cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Velychko <velychko_pe...@mail.ru>
Subject Re: Reading XML data from flowscript
Date Thu, 08 Jul 2004 09:17:38 GMT
Hello Peter,

Some corrections. I looked at mail of Leszek Gawron and uderstand that
I forgotten to release components used.
Taking into account the message of Leszek it sould be:

var uri = cocoon.parameters.myUri;
try {
        var resolver = cocoon.getComponent(Packages.org.apache.excalibur.source.SourceResolver.ROLE);
        var parser = cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
        var xpathProcessor = cocoon.getComponent(Packages.org.apache.excalibur.xml.xpath.XPathProcessor.ROLE);
        
        var source = resolver.resolveURI(uri);
        var document = Packages.org.apache.cocoon.components.source.SourceUtil.toDOM(source);
        
        var result = xpathProcessor.evaluateAsString(document,'/config/lang');
        
} finally {     
        resolver.release(source);
        cocoon.releaseComponent(resolver);
        cocoon.releaseComponent(parser);
        cocoon.releaseComponent(xpathProcessor);
}

Thursday, July 8, 2004, 12:01:14 PM, you wrote:

PV> Hello Derek,

PV> Try to use the following

PV> function testPage() {
PV>         var uri = cocoon.parameters.myUri;
        
PV>         var resolver = cocoon.getComponent(Packages.org.apache.excalibur.source.SourceResolver.ROLE);
PV>         var parser = cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
PV>         var xpathProcessor = cocoon.getComponent(Packages.org.apache.excalibur.xml.xpath.XPathProcessor.ROLE);
        
PV>         var source = resolver.resolveURI(uri);
PV>         var is = Packages.org.apache.cocoon.components.source.SourceUtil.getInputSource(source);
PV>         var document = parser.parseDocument(is);
PV>         print("res="+xpathProcessor.evaluateAsString(document,'/config/lang'))
PV> }

PV> Thursday, July 8, 2004, 10:41:04 AM, you wrote:

DH>> Is there is a simple function in flow script that 
DH>> will allow me to:
DH>> - access a specified XML file (say, passed as a 
DH>> request/sitemap parameter)
DH>> - read in one or nodes from the file and store
DH>> these as flowscript variables.

DH>> Thanks
DH>> Derek

-- 
Best regards,
Peter
velychko_peter@mail.ru


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


Mime
View raw message