[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: JDOM XSLT TransformerException (newbie)
Hi Michael,
By replacing the FileReader with InputStream the following codes has finally allow me to read and transformed state.xml to state.html but only when there is an Internet Online connection:
19. SAXBuilder stateBuilder = new SAXBuilder("org.ccil.cowan.tagsoup.Parser", false); 20. stateBuilder.setValidation(false); 21. FileInputStream stateIS = new FileInputStream("E:\\state.xml"); 22. BufferedInputStream stateBIS = new BufferedInputStream(stateIS); 23. Document stateOriginaljdomDocument = stateBuilder.build(stateBIS); 24. TransformerFactory stateFactory = TransformerFactory.newInstance(); 25. Transformer stateTransformer = stateFactory.newTransformer(new StreamSource("E:\\stateStyleSheet.xsl")); 26. JDOMSource stateSource = new JDOMSource(stateOriginaljdomDocument); 27. JDOMResult stateResult = new JDOMResult(); 28. stateTransformer..transform(stateSource, stateResult); ...... Offline javax.xml.transform.TransformerException: org.jdom.JDOMException: DTD parsing error: www.w3.org at org.apache.xalan.transformer.TransformerImpl.fatalError(TransformerImpl.java:738) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:712) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1126) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1104) at XMLProject.main(generateXML.java:28) Caused by: org.jdom.JDOMException: DTD parsing error: www.w3.org at org.jdom.transform.JDOMSource$DocumentReader.parse(JDOMSource.java:525) at org.apache.xml.dtm.ref.DTMManagerDefault.getDTM(DTMManagerDefault.java:478) at org.apache.xalan.transformer..TransformerImpl.transform(TransformerImpl.java:655) ... 3 more
It appears that the transformation process is trying to validate DTD even though I have turned validation off during parsing. Can you confirm whether the validation attempt is occurring during parsing or transformation step? And how to prevent it from recurring?
At the sametime, the content of state.html is:
<?xml version="1.0" encoding="UTF-8"?> This means that the stateStyleSheet..xsl below is not able to use XPath search to retrieve both Area Link and Area Name from state.xml:
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>Transformed State Detail</h2> <table border="1"> <tr bgcolor="lightblue"> <th align="left">Area Link</th> <th align="left">Area Name</th> </tr> <xsl:for-each select="/html/body/div[@id='content']/table[@class='sresults']/tr/td/a"> <tr> <td><xsl:value-of select="@href"/></td> <td><xsl:value-of select="@title"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
Again, the following XPath search statements have found Area Link, Area Name from state.xml:
XPath stateXpath = XPath.newInstance("/ns:html/ns:body/ns:div[@id='content']/ns:table[@class='sresults']/ns:tr/ns:td/ns:a"); In short, how to include the implicit/explicit/both namespace to accurately pick up these values from within stateStyleSheet.xsl?
Many thanks again for your valuable advice, Jack From: Michael Kay <mike@s...> To: Jack Bush <netbeansfan@y...>; Robert Koberg <rob@k...> Cc: xml-dev@l... Sent: Monday, 5 January, 2009 10:19:14 PM Subject: RE: JDOM XSLT TransformerConfigurationException Well, for some reason it looks as if you are trying to parse using TagSoup but the stack trace shows you are actually parsing using Xerces.
Michael Kay
http://www.saxonica.com/
Stay connected to the people that matter most with a smarter inbox.. http://au.rd.yahoo.com/galaxy/mail/tagline2/*http://au.docs.yahoo.com/mail/smarterinbox.
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] |
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|