You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Bernd Koecke <bk...@viae.de> on 2000/05/24 11:21:39 UTC

Possible Bug in xalan

Hi all,

a few weeks ago I send a few lines about a possible bug in xalan, but I
send it via a Mail-Link of the website. I doesn't know that it was send
to this list. Now I am on the list and I saw your answers in the
archive. Thanks. 

Because of the downtime of the Bug-Tracking-System, here is my problem
with xalan:

I use the Java-version of xalan for the Transformation of
Business-Documents and for the Creation of those docs from non
XML-Sources. For this I collect Data from different sources into one
DOM. To do this I tried to use the Feature of the XSLTProcessor to give
him a DOM-Node as the startingpoint of the XSLTResultTarget. But this
doesn't work, because of the way the StylesheetRoot-Class creates a new
FormatterToDOM-Object. If I send an Element or a DocumentFragment as
the startingpoint, the FormatterToDOM-Object was created with a new
generated Document, because I use a XercesLiaison, so setting the
DocumentFactory makes no difference. When the Processor processes the
Stylesheet it wants to add an Element to the Result. To do this it
calls the startElement-Method of the FormatterToDOM-Object. In this
Method the new Element was created from m_doc which is a fresh new
Document. After this the append-Method tries to insert the new Node as
a child of the given startingpoint. Now you get a 'DOM 0005 Wrong
Document'-Message, because in any situation, the new Element and the
startingpoint can never be from the same Document, because the Document
which creates the new Element was newly created at the Creation of the
FormatterToDOM-Object.

My solution is to give the Owner-Document of the startingpoint to the
new Formatter and not a new one. But now a little new problem occurs.
After the call to append(elem) in FormatterToDOM.startElement(...) the
new Element elem is pushed to the stack and not the value of
m_currentNode. After the Insertion of the first Element in the
ResultTarget the startingpoint was lost, because it was the value of
m_currentNode and it wasn't saved and it was overwritten by the new
Element. So I push m_currentElement to the Stack and now I'm able to
insert more than one Element as direct subnodes of the startingpoint.
But now I've got one more entry in the stack, so I have to modify the
code in endElement, because now the top-Element of the Stack is
valuable and I have to use it.

If a Document is used as the ResultTarget it works as well.

I think in the original code it is never possible to successfull
process a Stylesheet with an Element- or DocumentFragment-Node as a
startingpoint. I try this with two versions of xalan (1.0.1 and 0.20.0)
and if I don't misunderstood something, my modification to the code
might be usefull for you. But if I'm wrong could you tell me where I
stumble?

Thanks in advance

Bernd

--
Bernd Köcke               mailto:bk@viae.de
viae AG                   http://www.viae.de/
Haid-und-Neu-Straße 7     Tel.: +49 (0)721 9658 555
76131 Karlsruhe           Fax:  +49 (0)721 9658 556