Skip to main content

validate XML file against schema and feed an XSL transform

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
jdevbilbo
Offline
Joined: 2010-12-23

Hello,
I have an XML file that follows an XML schema, and I have an XSL transformation that converts the input XML file into a properties file (text format "key=value", not an XML properties file).
What I have to do is:

  1. Check that the input file is valid against the schema
  2. Apply the XSL transformation to the input XML file
  3. Feed the result of the XSL transformation to the method load(InputStream) of class Properties.

However, as far as I know, I can get the result of the XSL transformation in a StreamResult or SAXResult, but the former returns an OutputStream object, not an InputStream object, as the Properties.load() method requires. Besides, I wouldn't want to use a DOMSource for performance reasons.
Could anybody help me? Any hint or suggestion would be highly appreciated.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kubatzki
Offline
Joined: 2011-03-25

<b>javax.xml.transform.stream.StreamResult can be initialized with an arbitrary Outputstream</b> including <a title="class in java.io" href="http://localhost/doc-packs/javaDocs/api/java/io/ByteArrayOutputStream.html">ByteArrayOutputStream</a>. which allowin  in memory access.
of the result after transformation.
take the bytes and create and [prettify]&lt;b&gt;&lt;a href=&quot;http://localhost/doc-packs/javaDocs/api/java/io/ByteArrayInputStream.html#ByteArrayInputStream%28byte%5B%5D%29&quot;&gt;ByteArrayInputStream&lt;/a&gt;&lt;/b&gt;(byte[] buf)
which you can use to load the properties. ys. [/prettify]