[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Convert 2 xml with 1 xsl file

Subject: Re: Convert 2 xml with 1 xsl file
From: JBryant@xxxxxxxxx
Date: Thu, 9 Dec 2004 17:44:32 -0600
convert string to streamsource
I can't speak to the Java part of it, but the document function can solve
the convert two (or n) files from a single stylesheet problem. The
following instruction pulls in the content of another document and
processes it:

<xsl:apply-templates select="document(otherDocument)"/>

Jay Bryant
Bryant Communication Services




Marcelo <marcelochyna@xxxxxxxxxxxx>
12/09/2004 08:30 PM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc

Subject
 Convert 2 xml with 1 xsl file






Hi! May anybody help me? I need to convert 2 xml with
1 xsl file to a XHTML file. How do I do that?

Besides that. Does anybody knows Java? Because I need
to do this convertion within it.

My code converts 1 xml with 1 xsl file. But how can I
do with 2 xml)

Thanks.

Marcelo.


This is my code:

***************************************************


public static void xsl(
                                 String xml1,
                                 String xml2,
                                 String outFilename,
                                 String xslFilename) {
                                 try {
                                                 // Create transformer
factory
                                                 TransformerFactory
factory =
TransformerFactory.newInstance();

                                                 // Use the factory to
create a template containing
the xsl file
                                                 Templates template =
 factory.newTemplates(
  new StreamSource(new
FileInputStream(xslFilename)));

                                                 // Use the template to
create a transformer
                                                 Transformer xformer =
template.newTransformer();

                                                 InputStream in = new
URL(xml1).openStream();
                                 //              StringBuffer s = new
StringBuffer();

 System.out.println(in.toString());
                                                 Source source = new
StreamSource(in);
                                                 //Source source = new
StreamSource(new
FileInputStream(inFilename));
                                                 Result result = new
StreamResult(new
FileOutputStream(outFilename));

                                                 // Apply the xsl file to
the source file and write
the result to the output file
                                                 xformer.transform(source,
result);
                                 } catch (FileNotFoundException e) {
 System.out.println("FileNotFoundException ");
                                                 e.printStackTrace();
                                 } catch
(TransformerConfigurationException e) {

System.out.println("TransformerConfigurationException
");
                                                 e.printStackTrace();
                                                 // An error occurred in
the XSL file
                                 } catch (TransformerException e) {
 System.out.println("TransformerException ");
                                                 // An error occurred
while applying the XSL file
                                                 // Get location of error
in input file
                                                 SourceLocator locator =
e.getLocator();
                                                 int col =
locator.getColumnNumber();
                                                 int line =
locator.getLineNumber();
                                                 String publicId =
locator.getPublicId();
                                                 String systemId =
locator.getSystemId();
                                                 e.printStackTrace();
                                 } catch (MalformedURLException e) {
                                                 // TODO Auto-generated
catch block
                                                 e.printStackTrace();
                                 } catch (IOException e) {
                                                 // TODO Auto-generated
catch block
                                                 e.printStackTrace();
                                 }
                 }
}

************************************************





_______________________________________________________
Yahoo! Mail - Agora com 250MB de espago gratuito. Abra
uma conta agora! http://br.info.mail.yahoo.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.