On 09/09/2011 13:51, Kate Tang wrote:

About System.out setting.


I'm not quite sure what you are asking, but the Javadoc for StreamResult can be found here:

http://download.oracle.com/javase/6/docs/api/javax/xml/transform/stream/StreamResult.html

Michael Kay
Saxonica

 

From: Michael Kay [mailto:mike@saxonica.com]
Sent: September-09-11 8:18 AM
To: Kate Tang; Saxon Help List
Subject: Re: [saxon] Help about saxon9he.jar

 

Please don't go off-list! It's important that when a question is present in the list archives, the answer is there too.

You're sending the principal output to

new StreamResult(System.out)

The StreamResult has a systemId property which you can set using setSystemId(). If you set this property, it will be used as the "base output URI" for the href references in xsl:result-document. If you don't set it, it defaults to the current directory, which is often not useful.

Michael Kay
Saxonica

On 09/09/2011 12:56, Kate Tang wrote:

Hi Michael,

 

Thanks lot for answering my question.  I can make it work now. The problem is I could not output file to a particular path.

In the XSLT, a relative path (output) is defined. In the code, I use “trans.transform(xmlSource, new StreamResult(System.out));”.

Then, it generates output folder to /JBOSS/Bin. I wonder how I can do setting and let it produce output folder to a particular path.

 

Thanks again,

Kate

 

 

 

From: Michael Kay [mailto:mike@saxonica.com]
Sent: September-09-11 5:30 AM
To: saxon-help@lists.sourceforge.net; Kate Tang
Subject: Re: [saxon] Help about saxon9he.jar

 

On 08/09/2011 16:33, Kate Tang wrote:

Hi,

 

   I tried the command “java -cp .\saxon\saxon9he.jar net.sf.saxon.Transform -t -s:operationsReport_1_151624.xml  -xsl:operationReport.xsl “ to generate multi html files.

It works well.  

  

  The following is what I use now.  However, it could not produce multi html files. 


You haven't said how it failed.

Presumably you are using xsl:result-document to produce the multiple output files.

One possibility is that your code has loaded Xalan instead of Saxon. You can test this by seeing what implementation of TransformerFactory has been loaded. If you want to be sure that your code always loads Saxon then the simplest way is to replace the call TransformerFactory.newInstance() with "new net.sf.saxon.TransformerFactoryImpl()". (Putting Saxon on the classpath should also work, but is more error-prone and less performant.)

Alternatively, it may be failing because you haven't supplied an output destination for the files. If the href attribute of xsl:result-document is a relative location, it is interpreted relative to the location of the principal output for the transformation, but this is unknown because you supplied the destination as a ByteArrayOutputStream with no systemId property.

(If you had explained exactly how it failed, then it wouldn't be necessary to give you two alternative explanations...)

Michael Kay
Saxonica




I wonder how I can use saxon9he in java code.

 

 

              InputStream xsltStream = null;

              xsltStream = MessageContentUtil.class.getClassLoader().getResourceAsStream(DEFAULT_XSL_PATH);      

 

              Source xsltSource = new StreamSource(xsltStream);

             

              File f = new File( "\\messagepoint\\reports\\operationsReports\\operationsReport.xml" );

              InputStream xmlStream = new FileInputStream(f);

              Source xmlSource = new StreamSource(xmlStream);

             

              TransformerFactory transFact = TransformerFactory.newInstance();

              URIResolver resolver = new URIResolver() {

                     public Source resolve(String href, String base)

                                  throws TransformerException {

                           InputStream includeXSLTStream = MessageContentUtil.class

                                         .getClassLoader().getResourceAsStream(

                                                       "com/prinova/messagepoint/model/util/" + href);

                           Source includeXSLTSource = new StreamSource(includeXSLTStream);

                           return includeXSLTSource;

                     }

              };

              transFact.setURIResolver(resolver);

              Transformer trans = transFact.newTransformer(xsltSource);

 

              ByteArrayOutputStream reportHTMLstream = new ByteArrayOutputStream();

              trans.transform(xmlSource, new StreamResult(reportHTMLstream));

 

Thanks,

Kate





------------------------------------------------------------------------------
Why Cloud-Based Security and Archiving Make Sense
Osterman Research conducted this study that outlines how and why cloud
computing security and archiving is rapidly being adopted across the IT 
space for its ease of implementation, lower cost, and increased 
reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/





_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help