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