Apache Authors: Elizabeth White, Pat Romanski, Liz McMillan, Christopher Harrold, Janakiram MSV

RSS Feed Item

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);



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"?>
    <h2>Transformed State Detail</h2>
    <table border="1">
      <tr bgcolor="lightblue">
        <th align="left">Area Link</th>
        <th align="left">Area Name</th>

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"


<xsl:template match="/">



<h2>Transformed State Detail</h2>

<table border="1">

<tr bgcolor="lightblue">

<th align="left">Area Link</th>

<th align="left">Area Name</th>


<xsl:for-each select="/html/body/div[@id='content']/table[@class='sresults']/tr/td/a">


<td><xsl:value-of select="@href"/></td>

<td><xsl:value-of select="@title"/></td>









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");
      stateXpath.addNamespace("ns", "http://www.w3.org/1999/xhtml");

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,


From: Michael Kay <[email protected]>
To: Jack Bush <[email protected]>; Robert Koberg <[email protected]>
Cc: [email protected]
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

From: Jack Bush [mailto:[email protected]]
Sent: 05 January 2009 02:38
To: Michael Kay; Robert Koberg
Cc: [email protected]
Subject: Re: JDOM XSLT TransformerConfigurationException

Hi Michael,


The following statements generated state.xml file:


URL stateUrl = new URL("http://www.abc.com");

URLConnection stateconnection = stateUrl.openConnection();

stateisInHtml = stateconnection.getInputStream();

statedisInHtml = new DataInputStream(new BufferedInputStream(stateisInHtml));


statefosOutHtml = new FileOutputStream("state.html");

while ((oneChar=statedisInHtml.read()) != -1)




statefrInHtml = new FileReader("state.html");

statebrInHtml = new BufferedReader(statefrInHtml);

SAXBuilder statesaxBuilder = new SAXBuilder("org.ccil.cowan.tagsoup..Parser", false);

org.jdom.Document statejdomDocument = statesaxBuilder.build(statebrInHtml);

XMLOutputter stateoutputter = new XMLOutputter();

statefwOutXml = new FileWriter("state.xml");

statebwOutXml = new BufferedWriter(statefwOutXml);

stateoutputter.output(statejdomDocument, statebwOutXml);


XPath had no problem looking up state.xml.





From: Michael Kay <[email protected]>
To: Jack Bush <[email protected]>; Robert Koberg <[email protected]>
Cc: [email protected]
Sent: Monday, 5 January, 2009 2:13:33 AM
Subject: RE: JDOM XSLT TransformerConfigurationException

Nevertheless, I now encountered another issue this time:
java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence. 
There's only one explanation of that: the parser is expecting the document to be encoded in UTF-8 but it isn't. To understand why it isn't, you need to examine how the document was created and any transcodings that might have taken place before it reached the parser.

        at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown Source)
        at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
        at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
        at org.apache.xerces.impl.XMLEntityScanner.skipChar(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache..xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces..parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:489)
        at org.jdom...input.SAXBuilder.build(SAXBuilder.java:928)
        at JDOMTrAXPojoInvestmentBean.main(JDOMTrAXPojoInvestmentBean.java:45)
The header of state.xml is as follows:
  <?xml version="1.0" encoding="UTF-8" ?>
  <!DOCTYPE html (View Source for full doctype...)>
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml">

Any ideas on what is the cause of this issue and how to overcome it? Likewise, how to define the correct proper namespace prefix? Is it possible that this document has two namespaces. A default one and one with prefix 'html'? If so, which one should I use?
 It's certainly inelegant to bind the same namespace to two prefixes like this, though it's not incorrect. Again to prevent it happening we need to understand how you created the document.
Michael Kay 

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.

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/ma....

Read the original blog entry...

IoT & Smart Cities Stories
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
Cloud-enabled transformation has evolved from cost saving measure to business innovation strategy -- one that combines the cloud with cognitive capabilities to drive market disruption. Learn how you can achieve the insight and agility you need to gain a competitive advantage. Industry-acclaimed CTO and cloud expert, Shankar Kalyana presents. Only the most exceptional IBMers are appointed with the rare distinction of IBM Fellow, the highest technical honor in the company. Shankar has also receive...
Nicolas Fierro is CEO of MIMIR Blockchain Solutions. He is a programmer, technologist, and operations dev who has worked with Ethereum and blockchain since 2014. His knowledge in blockchain dates to when he performed dev ops services to the Ethereum Foundation as one the privileged few developers to work with the original core team in Switzerland.
Dynatrace is an application performance management software company with products for the information technology departments and digital business owners of medium and large businesses. Building the Future of Monitoring with Artificial Intelligence. Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more busine...
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a m...
Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
Whenever a new technology hits the high points of hype, everyone starts talking about it like it will solve all their business problems. Blockchain is one of those technologies. According to Gartner's latest report on the hype cycle of emerging technologies, blockchain has just passed the peak of their hype cycle curve. If you read the news articles about it, one would think it has taken over the technology world. No disruptive technology is without its challenges and potential impediments t...
If a machine can invent, does this mean the end of the patent system as we know it? The patent system, both in the US and Europe, allows companies to protect their inventions and helps foster innovation. However, Artificial Intelligence (AI) could be set to disrupt the patent system as we know it. This talk will examine how AI may change the patent landscape in the years to come. Furthermore, ways in which companies can best protect their AI related inventions will be examined from both a US and...
Bill Schmarzo, Tech Chair of "Big Data | Analytics" of upcoming CloudEXPO | DXWorldEXPO New York (November 12-13, 2018, New York City) today announced the outline and schedule of the track. "The track has been designed in experience/degree order," said Schmarzo. "So, that folks who attend the entire track can leave the conference with some of the skills necessary to get their work done when they get back to their offices. It actually ties back to some work that I'm doing at the University of San...