Welcome!

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

RSS Feed Item

Re: JDOM XSLT TransformerConfigurationException

Hi Michael and Robert,
 
Thanks for reponding to this question.
 
You are right about it my Java application is having diffulty reading stateStyleSheet.xsl. I have overcame it by moving it to a new project and suspects that the order of jar files in CLASSPATH were in the wrong order. Nevertheless, I now encountered another issue this time:
 
java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.
        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?
 
Many thanks again,
 
Jack

From: Michael Kay <[email protected]>
To: Jack Bush <[email protected]>; [email protected]
Sent: Saturday, 3 January, 2009 1:02:10 AM
Subject: RE: JDOM XSLT TransformerConfigurationException

I would suspect that
 
new StreamSource("stateStyleSheet.xsl")
 
isn't finding the stylesheet.
 
Try supplying an absolute URI, or using the constructor
 
new StreamSource(new File("stateStyleSheet.xsl"))
 
Michael Kay
http://www.saxonica.com/


From: Jack Bush [mailto:[email protected]]
Sent: 02 January 2009 13:54
To: [email protected]
Subject: JDOM XSLT TransformerConfigurationException

Hi All,

I am getting the following exception when trying to do simple transformation (newbie in JDOM XSLT) using either XSLTransformer/TrAX in JDOM:

 

javax.xml.transform.TransformerConfigurationException: java.io.EOFException: no more input

at com.icl.saxon.PreparedStyleSheet.prepare(PreparedStyleSheet.java:121)

at com.icl.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:120)

at com.icl.saxon.TransformerFactoryImpl..newTransformer(TransformerFactoryImpl.java:72)

at standaloneClientRemoteInvestmentBean.JDOMTrAXPojoInvestmentBean.retrieveAreaZipcode(JDOMTrAXPojoInvestmentBean.java:68)

at standaloneClientRemoteInvestmentBean.JDOMTrAXPojoInvestmentBean.main(JDOMTrAXPojoInvestmentBean.java:37)

Caused by: java.io..EOFException: no more input

at com.icl.saxon.aelfred.XmlParser.popInput(XmlParser.java:4083)

at com.icl.saxon.aelfred.XmlParser.pushURL(XmlParser.java:3620)

at com.icl.saxon.aelfred.XmlParser.doParse(XmlParser.java:159)

at com.icl.saxon.aelfred.SAXDriver.parse(SAXDriver.java:320)

at com.icl.saxon.om.Builder.build(Builder.java:265)

at com.icl.saxon.PreparedStyleSheet.prepare(PreparedStyleSheet..java:111)

... 4 more

 

Below is the stateStyleSheet:

<?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="/ns:html/ns:body/ns:div[@id='content']/ns:table[@class='sresults']/ns:tr/ns:td/ns: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>

 

The Java program that calls this stateStyleSheet is as follows:

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

    org.jdom.Document stateDocument = statesaxBuilder.build("state.xml");

    TransformerFactory factory = TransformerFactory.newInstance();

    Transformer transformer = factory.newTransformer(new StreamSource("stateStyleSheet.xsl"));

    JDOMSource source = new JDOMSource(stateDocument);

    JDOMResult result = new JDOMResult();

    transformer.transform(source, result);

    Document tranformedDocument = result.getDocument();

    ......

 

Could this exception have been caused by incorrectly formatted stateStyleSheet? The search path "/ns:html/ns:body/ns:div[@id='content']/ns:table[@class='sresults']/ns:tr/ns:td/ns:a" has successfully worked in XPath such as the following lines:

 

    XPath statePath = XPath.newInstance("/ns:html/ns:body/ns:div[@id='content']/ns:table [@class='sresults']/ns:tr/ns:td/ns:a");

    statePath.addNamespace("ns", http://www.w3.org/1999/xhtml);

 

Whether including namespace ("ns") or not doesn't make any difference.

I am running JDK1.6, Netbeans 6.1, JDOM 1.1, Saxon 6.5, TagSoup 1.2 on Windows XP platform.

Your assistance would be much appreciated.

Many thanks,

Jack



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/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
The current age of digital transformation means that IT organizations must adapt their toolset to cover all digital experiences, beyond just the end users’. Today’s businesses can no longer focus solely on the digital interactions they manage with employees or customers; they must now contend with non-traditional factors. Whether it's the power of brand to make or break a company, the need to monitor across all locations 24/7, or the ability to proactively resolve issues, companies must adapt to...
We are seeing a major migration of enterprises applications to the cloud. As cloud and business use of real time applications accelerate, legacy networks are no longer able to architecturally support cloud adoption and deliver the performance and security required by highly distributed enterprises. These outdated solutions have become more costly and complicated to implement, install, manage, and maintain.SD-WAN offers unlimited capabilities for accessing the benefits of the cloud and Internet. ...
Business professionals no longer wonder if they'll migrate to the cloud; it's now a matter of when. The cloud environment has proved to be a major force in transitioning to an agile business model that enables quick decisions and fast implementation that solidify customer relationships. And when the cloud is combined with the power of cognitive computing, it drives innovation and transformation that achieves astounding competitive advantage.
DXWorldEXPO LLC announced today that "IoT Now" was named media sponsor of CloudEXPO | DXWorldEXPO 2018 New York, which will take place on November 11-13, 2018 in New York City, NY. IoT Now explores the evolving opportunities and challenges facing CSPs, and it passes on some lessons learned from those who have taken the first steps in next-gen IoT services.
Founded in 2000, Chetu Inc. is a global provider of customized software development solutions and IT staff augmentation services for software technology providers. By providing clients with unparalleled niche technology expertise and industry experience, Chetu has become the premiere long-term, back-end software development partner for start-ups, SMBs, and Fortune 500 companies. Chetu is headquartered in Plantation, Florida, with thirteen offices throughout the U.S. and abroad.
DXWorldEXPO LLC announced today that ICC-USA, a computer systems integrator and server manufacturing company focused on developing products and product appliances, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. DXWordEXPO New York 2018, colocated with CloudEXPO New York 2018 will be held November 11-13, 2018, in New York City. ICC is a computer systems integrator and server manufacturing company focused on developing products and product appliances to meet a wide range of ...
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...
SYS-CON Events announced today that DatacenterDynamics has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY. DatacenterDynamics is a brand of DCD Group, a global B2B media and publishing company that develops products to help senior professionals in the world's most ICT dependent organizations make risk-based infrastructure and capacity decisions.
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.
@DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22nd international CloudEXPO | first international DXWorldEXPO and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time t...