On Fri, 2003-11-07 at 22:37, Upayavira wrote:
> JD Daniels wrote:
> 
> >I was wondering if it was possible to load an xsp pipeline instead of a
> >source xml file..
> >
> >ex.
> >// parse the document to a DOM-tree
> >var document = loadDocument("forms/test.xml");
> >
> >// bind the document data to the form
> >form.load(document);
> >form.showForm("display-pipeline");
> >
> >Change to:
> >
> >// Load DOM-tree From Xsp
> >
> var uri = "context://formdata.xsp?id=" + cocoon.request.get("id");
> 
> var resolver = 
> cocoon.getComponent(Packages.org.apache.excalibur.source.SourceResolver.ROLE);
> var source = resolver.resolve(uri);
> var parser = 
> cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
> var document = 
> parser.parseDocument(Packages.org.apache.cocoon.components.source.SourceUtil.getInputSource(source));
> 
> form.load(document);

A bit more optimized would be:

var document =
Packages.org.apache.cocoon.components.source.SourceUtil.toDOM(source);

this will build the DOM directly from the SAX events comming out of the
XSP, instead of first serializing to XML and then reparsing.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
[EMAIL PROTECTED]                          [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to