From mike at saxonica.com Fri Apr 3 16:23:28 2009 From: mike at saxonica.com (Michael Kay) Date: Fri Apr 3 16:23:38 2009 Subject: [jdom-interest] Doctype cannot be added after a root element In-Reply-To: <49D697FC.3000205@atosorigin.com> References: <20081217224209.23340@gmx.net> <49D697FC.3000205@atosorigin.com> Message-ID: <44EA888B66E64CAB88022AFD3BF3DE62@Sealion> > Mickael, is there a reason why Saxon does not notify the DTD > through SAXResult? Saxon ignores xsl:output entirely unless it is serializing the result tree; and writing to a SAXResult does not count as serializing. (There are various other aspects of xsl:output that MIGHT make sense with a SAXResult, for example indent="yes" and cdata-section-elements. It's never really occurred to me that anyone would expect this to happen. I've certainly never seen a spec that suggests it should.) Michael Kay http://www.saxonica.com/ From laurent.bihanic at atosorigin.com Fri Apr 3 16:27:30 2009 From: laurent.bihanic at atosorigin.com (Laurent Bihanic) Date: Fri Apr 3 16:27:37 2009 Subject: [jdom-interest] JDOM XSLT TransformerConfigurationException In-Reply-To: <277825.97829.qm@web59614.mail.ac4.yahoo.com> References: <277825.97829.qm@web59614.mail.ac4.yahoo.com> Message-ID: <49D69B62.6030100@atosorigin.com> Hi, Your XSL file is probably corrupted. Running a similar code I get the following error : Error at xsl:for-each on line 14 of eof.xsl: Namespace prefix ns has not been declared Exception in thread "main" org.jdom.transform.XSLTransformException: Could not construct XSLTransformer: Failed to compile stylesheet. 1 error detected. ... Caused by: javax.xml.transform.TransformerConfigurationException: Failed to compile stylesheet. 1 error detected. at com.icl.saxon.PreparedStyleSheet.prepare(PreparedStyleSheet.java:134) at com.icl.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:120) at org.jdom.transform.XSLTransformer.(XSLTransformer.java:133) ... 2 more Which is normal as the namespace declaration for the "ns" prefix is indeed missing. Laurent Jack Bush a ?crit : > 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: > > > > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > > > > > > > >

Transformed State Detail

> > > > > > > > > > > > select="*/ns:html/ns:body/ns:div[@id='content']/ns:table[@class='sresults']/ns:tr/ns:td/ns:a*"> > > > > > > > > > > > >
Area LinkArea Name
> > > > > >
> >
> > > > 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 From laurent.bihanic at atosorigin.com Fri Apr 3 16:39:05 2009 From: laurent.bihanic at atosorigin.com (Laurent Bihanic) Date: Fri Apr 3 16:39:14 2009 Subject: [jdom-interest] Validating a JDOMSource with line numbers? In-Reply-To: <21639302.post@talk.nabble.com> References: <21639302.post@talk.nabble.com> Message-ID: <49D69E19.1080103@atosorigin.com> Hi, A JDOM Document does not retain the system Id nor the line numbers of the original document (same for the encoding). If you want this information, you should use a StreamSource. Regards, Laurent ondra.cifka a ?crit : > Hello, > > I validate a JDOMSource using a schema-based Validator and display > validation errors using an ErrorHandler. But the getSystemId() of the > SAXParseException returns null and getLineNumber() returns -1. How can I get > systemId and lineNumber for the errors? > > Thanks > Ondra