Return-Path: Delivered-To: apmail-xml-cocoon-users-archive@xml.apache.org Received: (qmail 81943 invoked by uid 500); 30 Jun 2003 07:44:30 -0000 Mailing-List: contact cocoon-users-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-users@xml.apache.org Delivered-To: mailing list cocoon-users@xml.apache.org Received: (qmail 81929 invoked from network); 30 Jun 2003 07:44:29 -0000 Received: from cmailm5.svr.pol.co.uk (195.92.193.21) by daedalus.apache.org with SMTP; 30 Jun 2003 07:44:29 -0000 Received: from modem-1384.aardvark.dialup.pol.co.uk ([217.134.5.104] helo=bristol.ac.uk) by cmailm5.svr.pol.co.uk with esmtp (Exim 4.14) id 19WtL6-00068Y-84 for cocoon-users@xml.apache.org; Mon, 30 Jun 2003 08:44:40 +0100 Message-ID: <3EFFEA72.6040108@bristol.ac.uk> Date: Mon, 30 Jun 2003 08:44:50 +0100 From: Simon Price User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 X-Accept-Language: en-us, en MIME-Version: 1.0 To: cocoon-users@xml.apache.org Subject: [summary] reading xml from pipeline into a flow script References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Jonathan's suggestion worked, so I thought I'd summarize the solution back to the list as a demo javascript flow script. function demo() { print getXML("http://localhost:8080/cocoon/mypipeline.xml"); } function getXML(urlStr) { // // return output of a pipeline as an xml string (and/or dom) // [NB. watch out for my app-specific parse settings below!] // var factory = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance(); factory.setValidating(false); // Prevent expansion of entity references factory.setExpandEntityReferences(false); // Configure it to ignore comments factory.setIgnoringComments(true); var document; var isvalid = true; try { document = factory.newDocumentBuilder().parse(urlStr); } catch (e) { isvalid = false; print("xml parse error:" + e + "\n"); } var xmlStr; if (isvalid) { // Convert document to string var format = new Packages.org.apache.xml.serialize.OutputFormat(document); var strOut = new Packages.java.io.StringWriter(); var XMLSerial = new Packages.org.apache.xml.serialize.XMLSerializer(strOut,format); XMLSerial.serialize(document.getDocumentElement()); xmlStr = strOut.toString(); } return xmlStr; } Jonathan Spaeth wrote: > One simple way of accomplishing this is to simply, define pipeline to > generate, transform, and serialize the xml. Then, in the flowscript, > simply use the jaxp dom api to load the generated xml: > > flow() { > var document = > Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().build(http://uri-to-xml-file); > > ... > > document.getDocumentElement(); > // it is now a dom > } > > > -----Original Message----- > From: Simon Price [mailto:simon.price@bristol.ac.uk] > Sent: Saturday, June 28, 2003 3:25 PM > To: cocoon-users@xml.apache.org > Subject: reading xml from pipeline into a flow script > > From within a flow script, I would like to read (or pass in) xml > generated by a series of pipeline xslt transformations. > > Please could someone give me a pointer on how to do this? > > Cheers > > Simon > > ------------------------------------------------------------------- > Simon Price > Institute for Learning and Research Technology > University of Bristol > 8-10 Berkeley Square > Bristol BS8 1HH > United Kingdom > > Direct: +44 (0)7071 226 720 > Office: +44 (0)117 928 7193 > Fax: +44 (0)117 928 7112 > Simon.Price@bristol.ac.uk > http://www.ilrt.bristol.ac.uk > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org > For additional commands, e-mail: cocoon-users-help@xml.apache.org > -- ------------------------------------------------------------------- Simon Price Institute for Learning and Research Technology University of Bristol 8-10 Berkeley Square Bristol BS8 1HH United Kingdom Direct: +44 (0)7071 226 720 Office: +44 (0)117 928 7193 Fax: +44 (0)117 928 7112 Simon.Price@bristol.ac.uk http://www.ilrt.bristol.ac.uk --------------------------------------------------------------------- To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org For additional commands, e-mail: cocoon-users-help@xml.apache.org