Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

Re: [jdom-interest] Transformation Issue

Jason Shapiro

2007-01-19

Replies:

Thanks - I'm now able to see what the difference is:
 
The DOCTYPE, declared in the "xsl:output" element is produces two slightly different Strings (depending on whether I'm in Tomcat with JDK 4 or Websphere with JDK 5). The difference being whether or not there is a space between the System ID and the Public ID
 
The correct version (in Tomcat):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
The incorrect version (in Websphere):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
It looks like this was a known issue and eventually fixed(?)
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6259810
 
Thanks again for your help!
-Jason

Mattias Jiderhamn wrote:
Why not try to use some other output than JDOM (like a StreamResult) and then compare the output from the two configurations?
Since JDOM complains in one case but not the other, there has to be a difference.

At 2007-01-17 23:14, Jason Shapiro wrote:
I switched versions of WebSphere (to 9.0.2.17) and am now getting a more detailed stack trace (any ideas?)
 
javax.xml.transform.TransformerException: org.jdom.IllegalAddException: A DocType cannot be added after the root element
 at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2379)
 at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2245)
 at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1334)
 at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:738)
 at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1251)
 at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1229)
 at org.jdom.transform.XSLTransformer.transform(XSLTransformer.java:234)
 
Caused by: org.jdom.IllegalAddException: A DocType cannot be added after the root element
 at org.jdom.ContentList.documentCanContain(ContentList.java:169)
 at org.jdom.ContentList.add(ContentList.java:205)
 at org.jdom.ContentList.add(ContentList.java:140)
 at java.util.AbstractList.add(AbstractList.java:102)
 at org.jdom.Document.addContent(Document.java:319)
 at org.jdom.DefaultJDOMFactory.addContent(DefaultJDOMFactory.java:177)
 at org.jdom.input.SAXHandler.startDTD(SAXHandler.java:711)
 at org.jdom.transform.JDOMResult$DocumentBuilder.startDTD(JDOMResult.java:592)
 at org.apache.xml.serializer.ToHTMLSAXHandler.startElement(ToHTMLSAXHandler.java:524)
 at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:626)
 at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:393)
 at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:176)
 at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2374)

Jason Shapiro wrote:
I'm running into a strange issue and am hoping someone here has some advice on how to best troubleshoot the problem. 

 
I have a very simple XSLT operation (producing HTML), using the XSLTransformer class:

 
XSLTransformer transformer = new XSLTransformer(xsl);
Document doc2 = transformer.transform(doc);

 
When I run this in a JDK 1.4 / Tomcat configuration, the Document is returned that looks exactly as I would expect it (an HTML document).  When I use the same code in a JDK 5 / WebSphere configuration, the Document object doesn't contain any elements (so when I try to display with an "toString" or "XMLOutputter", I get the following exception message: 'A DocType cannot be added after the root element').  

 
My guess is that this is ultimately related to some Xalan / Transformer issue, but I'm not sure what the best way is to determine what's being used (vs. what should be used).

 
Any advice is appreciated.

 
Regards,
Jason


Access over 1 million songs - Yahoo! Music Unlimited.
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com


Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.