[summary] reading xml from pipeline into a flow script

2003-06-30 Thread Simon Price
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:[EMAIL PROTECTED]
Sent: Saturday, June 28, 2003 3:25 PM
To: [EMAIL PROTECTED]
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
[EMAIL PROTECTED]
http://www.ilrt.bristol.ac.uk
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--

---
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
[EMAIL PROTECTED]
http://www.ilrt.bristol.ac.uk
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: reading xml from pipeline into a flow script

2003-06-30 Thread Frank Taffelt
you can use this snippet:

function getString(src) {
try {
 var is =  cocoon.environment.resolveURI(src).getInputStream();
 return
Packages.org.apache.cocoon.components.language.markup.xsp.XSPUtil.getContent
s(is);
}
catch(ex) {
print(ex: + ex);
}
return null;


}


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



RE: reading xml from pipeline into a flow script

2003-06-30 Thread Reinhard Pötz

This will work but not with the upcoming Flow Object Model. You won't
have access to the environment any more. If you are interested in the
FOM you find a reference here:
http://wiki.cocoondev.org/Wiki.jsp?page=FOM (be aware that this is a
working document and may change!!!)

So currently the easiest way is
{
...
 var uri = cocoon://blablabla;
var resolver = cocoon.componentManager.lookup(
Packages.org.apache.cocoon.environment.SourceResolver.ROLE );
var srce = resolver.resolveURI( uri );
cocoon.componentManager.release( resolver );
var dom =
Packages.org.apache.cocoon.components.source.SourceUtil.toDOM( srce );
...
}

which will probably change with FOM to

{
...
 var uri = cocoon://blablabla;
var resolver = cocoon.getComponent(
Packages.org.apache.cocoon.environment.SourceResolver.ROLE );
var srce = resolver.resolveURI( uri );
// release of the component (not defined yet
var dom =
Packages.org.apache.cocoon.components.source.SourceUtil.toDOM( srce );
...
}

Hope this helps!

Reinhard



 -Original Message-
 From: Frank Taffelt [mailto:[EMAIL PROTECTED] 
 Sent: Monday, June 30, 2003 9:34 AM
 To: [EMAIL PROTECTED]
 Subject: Re: reading xml from pipeline into a flow script
 
 
 you can use this snippet:
 
 function getString(src) {
 try {
  var is =  
 cocoon.environment.resolveURI(src).getInputStream();
  return 
 Packages.org.apache.cocoon.components.language.markup.xsp.XSPU
 til.getContent
 s(is);
 }
 catch(ex) {
 print(ex: + ex);
 }
 return null;
 
 
 }
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


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



Re: reading xml from pipeline into a flow script

2003-06-30 Thread Simon Price
Thanks. I was glad of any solution at midnight on saturday, but I'll 
watch to see how the fom evolves as you advise. Thanks.

Simon

Reinhard Pötz wrote:
This will work but not with the upcoming Flow Object Model. You won't
have access to the environment any more. If you are interested in the
FOM you find a reference here:
http://wiki.cocoondev.org/Wiki.jsp?page=FOM (be aware that this is a
working document and may change!!!)
So currently the easiest way is
{
...
 var uri = cocoon://blablabla;
var resolver = cocoon.componentManager.lookup(
Packages.org.apache.cocoon.environment.SourceResolver.ROLE );
var srce = resolver.resolveURI( uri );
cocoon.componentManager.release( resolver );
var dom =
Packages.org.apache.cocoon.components.source.SourceUtil.toDOM( srce );
...
}
which will probably change with FOM to

{
...
 var uri = cocoon://blablabla;
var resolver = cocoon.getComponent(
Packages.org.apache.cocoon.environment.SourceResolver.ROLE );
var srce = resolver.resolveURI( uri );
// release of the component (not defined yet
var dom =
Packages.org.apache.cocoon.components.source.SourceUtil.toDOM( srce );
...
}
Hope this helps!

Reinhard




-Original Message-
From: Frank Taffelt [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 30, 2003 9:34 AM
To: [EMAIL PROTECTED]
Subject: Re: reading xml from pipeline into a flow script

you can use this snippet:

function getString(src) {
   try {
var is =  
cocoon.environment.resolveURI(src).getInputStream();
return 
Packages.org.apache.cocoon.components.language.markup.xsp.XSPU
til.getContent
s(is);
   }
   catch(ex) {
   print(ex: + ex);
   }
   return null;

}

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


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



--

---
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
[EMAIL PROTECTED]
http://www.ilrt.bristol.ac.uk
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


reading xml from pipeline into a flow script

2003-06-28 Thread Simon Price
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
[EMAIL PROTECTED]
http://www.ilrt.bristol.ac.uk
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: reading xml from pipeline into a flow script

2003-06-28 Thread Jonathan Spaeth
Title: RE: reading xml from pipeline into a flow script





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:[EMAIL PROTECTED]] 
Sent: Saturday, June 28, 2003 3:25 PM
To: [EMAIL PROTECTED]
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
[EMAIL PROTECTED]
http://www.ilrt.bristol.ac.uk



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