M
Michael
Hello
I am trying to write a Java-Program which converts a XML-file in a HTML.
It should take the Transformation-file from the XML-file itself.
Below find a possible XML-file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 rel. 3 U (http://www.xmlspy.com) by Michael
Herren (private) -->
<?xml-stylesheet type="text/xsl" href="ch/qXMLsigner/files/order.xslt"
type="text/xsl?>
<order xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ch/qXMLsigner/files/order.xsd">
<address>
<name>Herren</name>
<firstname>Michael</firstname>
<street>Postgasse 62</street>
<zip>3011</zip>
<place>Bern</place>
</address>
<item>
<quantity>2</quantity>
<productcode>684562</productcode>
<description>DVD "Cruel Intentions"</description>
<unitprice>25</unitprice>
<price>50</price>
</item>
<conditions>
<discount>
<percent>5</percent>
<amount>3.9</amount>
</discount>
<fees>10</fees>
<currency>CHF</currency>
</conditions>
<totalamount>84.1</totalamount>
</order>
When I try to load the stylesheet a Java-Exception is thrown. Below find
the Java code:
XMLReader reader =
XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
InputSource inputSource = new InputSource(new
FileInputStream("ch/qXMLsigner/files/order.xml"));
reader.parse(inputSource);
SAXSource xmlDocument = new SAXSource(reader, inputSource);
transformXMLItem.setEnabled(true);
TransformerFactoryImpl transFactory = new TransformerFactoryImpl();
Source xsltSource = transFactory.getAssociatedStylesheet(xmlDocument,
null, null, null);
And the exception looks like:
Failed while looking for xml-stylesheet PI
java.io.IOException: The system cannot find the path specified
java.io.IOException: The system cannot find the path specified
at java.io.FileInputStream.read(Native Method)
at
org.apache.xerces.impl.XMLEntityManager$RewindableInputStream.read(Unknown
Source)
at
org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at
org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:145)
at net.sf.saxon.event.Sender.send(Sender.java:50)
at
net.sf.saxon.TransformerFactoryImpl.getAssociatedStylesheet(TransformerFactoryImpl.java:171)
at ch.qXMLsigner.viewer.Viewer.actionPerformed(Viewer.java:289)
at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
at
javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1113)
at
javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:943)
at java.awt.Component.processMouseEvent(Component.java:5134)
at java.awt.Component.processEvent(Component.java:4931)
at java.awt.Container.processEvent(Container.java:1566)
at java.awt.Component.dispatchEventImpl(Component.java:3639)
at java.awt.Container.dispatchEventImpl(Container.java:1623)
at java.awt.Component.dispatchEvent(Component.java:3480)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
at java.awt.Container.dispatchEventImpl(Container.java:1609)
at java.awt.Window.dispatchEventImpl(Window.java:1590)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
If anyone could help me I would be very thanksful.
Kind Regards
Michael
I am trying to write a Java-Program which converts a XML-file in a HTML.
It should take the Transformation-file from the XML-file itself.
Below find a possible XML-file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 rel. 3 U (http://www.xmlspy.com) by Michael
Herren (private) -->
<?xml-stylesheet type="text/xsl" href="ch/qXMLsigner/files/order.xslt"
type="text/xsl?>
<order xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ch/qXMLsigner/files/order.xsd">
<address>
<name>Herren</name>
<firstname>Michael</firstname>
<street>Postgasse 62</street>
<zip>3011</zip>
<place>Bern</place>
</address>
<item>
<quantity>2</quantity>
<productcode>684562</productcode>
<description>DVD "Cruel Intentions"</description>
<unitprice>25</unitprice>
<price>50</price>
</item>
<conditions>
<discount>
<percent>5</percent>
<amount>3.9</amount>
</discount>
<fees>10</fees>
<currency>CHF</currency>
</conditions>
<totalamount>84.1</totalamount>
</order>
When I try to load the stylesheet a Java-Exception is thrown. Below find
the Java code:
XMLReader reader =
XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
InputSource inputSource = new InputSource(new
FileInputStream("ch/qXMLsigner/files/order.xml"));
reader.parse(inputSource);
SAXSource xmlDocument = new SAXSource(reader, inputSource);
transformXMLItem.setEnabled(true);
TransformerFactoryImpl transFactory = new TransformerFactoryImpl();
Source xsltSource = transFactory.getAssociatedStylesheet(xmlDocument,
null, null, null);
And the exception looks like:
Failed while looking for xml-stylesheet PI
java.io.IOException: The system cannot find the path specified
java.io.IOException: The system cannot find the path specified
at java.io.FileInputStream.read(Native Method)
at
org.apache.xerces.impl.XMLEntityManager$RewindableInputStream.read(Unknown
Source)
at
org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at
org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:145)
at net.sf.saxon.event.Sender.send(Sender.java:50)
at
net.sf.saxon.TransformerFactoryImpl.getAssociatedStylesheet(TransformerFactoryImpl.java:171)
at ch.qXMLsigner.viewer.Viewer.actionPerformed(Viewer.java:289)
at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
at
javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1113)
at
javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:943)
at java.awt.Component.processMouseEvent(Component.java:5134)
at java.awt.Component.processEvent(Component.java:4931)
at java.awt.Container.processEvent(Container.java:1566)
at java.awt.Component.dispatchEventImpl(Component.java:3639)
at java.awt.Container.dispatchEventImpl(Container.java:1623)
at java.awt.Component.dispatchEvent(Component.java:3480)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
at java.awt.Container.dispatchEventImpl(Container.java:1609)
at java.awt.Window.dispatchEventImpl(Window.java:1590)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
If anyone could help me I would be very thanksful.
Kind Regards
Michael