DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17979>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17979

Transformations using DOMSource apply templates differently than with StreamSource

[EMAIL PROTECTED] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|Xalan                       |org.apache.xml.dtm



------- Additional Comments From [EMAIL PROTECTED]  2003-03-14 14:52 -------
The problem seems to arise from the line:

   translationResult = transformMessageToText(xslTransformer, new DOMSource
                         (xmlBuilder.parse(inputStream).getDocumentElement()));

The result of xmlBuilder.parse is a Document node, while the call to 
getDocumentElement gets the outermost Element of the document.  Xalan-J 
Interpretive creates a root node in the XPath data model only for the Document 
or a DocumentFragment, so your input ends up having no root node!  The input 
doesn't match your template rule for "/", and so the default rules end up 
applying - that includes matching element nodes, visiting their children, and 
copying text nodes to the output, which was the behaviour you complained about.

I think that behaviour of Xalan-J Interpretive is probably wrong; I think it 
should probably always manufacture a root node, though perhaps there's some 
historical reason why the current behaviour was chosen.  Someone else might be 
able to explain.  Regardless, you should be able to work around the problem in 
the meanwhile by writing:

  translationResult = transformMessageToText(xslTransformer, new DOMSource
                         (xmlBuilder.parse(inputStream)));

I hope that helps.

Reply via email to