[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: JDOM XSLT TransformerConfigurationException

  • From: Jack Bush <netbeansfan@y...>
  • To: Michael Kay <mike@s...>, Robert Koberg <rob@k...>
  • Date: Sun, 4 Jan 2009 02:57:39 -0800 (PST)

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 <mike@s...>
To: Jack Bush <netbeansfan@y...>; xml-dev@l...
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:netbeansfan@y...]
Sent: 02 January 2009 13:54
To: xml-dev@l...
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/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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.