Hi Erik,
Thanks for your reply.
I've tried to use the scope generator as suggested, however this is
not giving the results I would like.
I've pasted my code below and would be grateful if you could check
what I am doing wrong. It doesn't seem to be reading any input in
from File1.xml.
Thanks,
Zahida.
*** The Java Method is :
public void start() {
// 6. Initialize a PipelineContext
PipelineContext pipelineContext = new PipelineContext();
// z test parameters - start
String paramKey = "testparam";
String paramValue = "file://C://xml//main.xml";
ExternalContext externalContext =
(ExternalContext)
pipelineContext.getAttribute(PipelineContext.EXTERNAL_CONTEXT);
pipelineContext.setAttribute(paramKey, paramValue);
try{
String temp =
(String) pipelineContext.getAttribute((Object)
paramKey);
System.out.println("temp: " + temp );
}
catch(ClassCastException e)
{
System.out.println("CalssCast: " + e.getMessage());
e.printStackTrace();
}
// z test parameters - end
// Some processors may require a JNDI context. In general,
this is not required.
Context jndiContext;
try {
jndiContext = new InitialContext();
} catch (NamingException e) {
throw new OXFException(e);
}
pipelineContext.setAttribute(PipelineContext.JNDI_CONTEXT, jndiContext);
try {
// 7. Run the pipeline from the processor definition
created earlier. An ExternalContext
// is supplied for those processors using external
contexts, such as most serializers.
PipelineEngineFactory.instance().executePipeline(processorDefinition,
new CommandLineExternalContext(), pipelineContext);
//
PipelineEngineFactory.instance().executePipeline(processorDefinition,
externalContext, pipelineContext);
} catch (Exception e) {
// 8. Display exceptions if needed
System.out.println("Stupid exception thrown : " +
e.getMessage());
LocationData locationData =
ValidationException.getRootLocationData(e);
Throwable throwable = OXFException.getRootThrowable(e);
String message = locationData == null
? "Exception with no location data"
: "Exception at " + locationData.toString();
logger.error(message, throwable);
System.out.println("message: " + message);
}
}
*** The Command Line Output from the Java App is :
Starting Orbeon XML Server OXF_2_5_BUILD_353
Initializing Resource Manager with:
{oxf.resources.priority.2=org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory,
oxf.resources.factory=org.orbeon.oxf.resources.PriorityResourceManagerFactory,
oxf.resources.priority.1=org.orbeon.oxf.resources.FilesystemResourceManagerFactory}
fileURL: file:/C:/General
downloads/jakarta-tomcat-5.0.29/webapps/orbeon/WEB-INF//resources//examples//zed//javatest.xpl
filePath: ..//resources//examples//zed//javatest.xpl
temp: file://C://xml//main.xml
Running processor
- Timing: 812 - Cache hits: 4, fault: 14, adds: 14, success rate: 22%
*** The XPL file:
<!--
Test XPL which combines the XML from 2 files into one file under a
root element
-->
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<p:param name="testparam" type="input"/>
<!-- Transform an XML file -->
<p:processor name="oxf:scope-generator"
xmlns:p="http://www.orbeon.com/oxf/pipeline">
<p:input name="config">
<config>
<key>#testparam</key>
<scope>application</scope>
</config>
</p:input>
<p:output name="data" id="filename"/>
</p:processor>
<p:processor name="oxf:file-serializer">
<p:input name="config">
<config>
<file>Testresults.xml</file>
<directory>C:\General
downloads\jakarta-tomcat-5.0.29\webapps\orbeon\WEB-INF\resources\examples\zed</directory>
</config>
</p:input>
<p:input name="data" href="aggregate('document', #filename,
file2.xml)" />
</p:processor>
</p:config>
*** The Resulting output in the file Testresults.xml is:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<document>
<null xsi:nil="true"/>
<journals>the journal of content loading</journals>
</document>
*** The Input files are:
File1.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<books>rubbish************************</books>
File2.xml
<journals>the journal of content loading</journals>
On Tue, 11 Jan 2005 18:46:33 +0100, Erik Bruchez <[EMAIL PROTECTED]> wrote:
> Zahida Chaudri wrote:
>
> > I am new to Orbeon and investigating the use of pipelines for a
> > project we have. Ideally we would like to run this from java using
> > XML pipelines as we will be dealing with XML content.
>
> Good plan.
>
> > 1. How to run the pipeline from java. I've used OXF.java to work
> > from and have it running now so that's OK
>
> Yes, please let us know if you encounter any problem.
>
> > 2. When adding a pipeline to run the email processor it is throwing an
> > error saying the content-type attribute was not expected in the body
> > element. Error unexpected attribute "content-type"(schema:
> > http://www.orbeon.com/oxf/email).
> > However when I run the following it works for only the HTML part.
> > <body mime-multipart="alternative">
> > <part name="part1" content-type="text/plain">
> > This is part 1
> > </part>
> > <part name="part2" content-type="text/html">
> > <html>
> > <body>
> > <p>
> > This is part 2
> > </p>
> > </body>
> > </html>
> > </part>
>
> Both parts should be sent. Did you look at the source of your email
> and check that only the text/html part was created? BTW don't trust
> your email client to debug, better look at the actual raw message.
>
> > 3. I will be dealing with a number of XML files and will need to
> > create the pipeline dynamically, or perhaps pass the parameters into
> > the pipeline. How do you pass parameters into a pipeline from java?
>
> One solution is to create an ExternalContext instance, store your
> parameters in the request scope, and then use the Scope generator to
> retrieve them. This is lacking documentation at the moment though.
>
> Another simple solution is to store your parameters into the
> PipelineContext instance that you create before running the pipeline,
> and then using either a simple custom processor or the Java processor,
> extract this data and make it available as an XML document.
>
> > 4. Is it possible to validate against DTDs?
>
> Not from within XPL. You can validate at parsing time though when
> using the URL generator, by specifying the
> <validating>true</validating> parameter. See:
>
> http://www.orbeon.com/ois/doc/processors-generators-url
>
> -Erik
>
> -------------------------------------------------------
> The SF.Net email is sponsored by: Beat the post-holiday blues
> Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
> It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
> _______________________________________________
> orbeon-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/orbeon-user
>
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
orbeon-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/orbeon-user