Hi.
I have a issue with the DOM processing and couldn't find related topics in
the archives. Perhaps someone could provide some help.
As part a web service (I use Axis), I am extracting a branch of the SOAP
body and using it as input to Xalan.
I am using a DOMSource initialized with my root element parent node, as
required by DOMSource's constructor. It lloks like this:
Element base = ... (find the element which is to be used as the
root);
DOMSource xml = new DOMSource( base.getParentNode() );
base's parent node is a simple element, whith a single child, base itself.
The transformation runned smothly, but the results showed the although the
base element was correctly matched and processed, the template matching "/"
was not processed. According to DOMSource javadoc, it should have been.
I tried to use a new element instead of the actual parent, as in
Node fakeRoot = base.getOwnerDocument().createElement("dummy");
fakeRoot.appendChild(base);
DOMSource xml = new DOMSource( fakeRoot );
The result was exactly the same: the "/" templated was not executed, its
child (the base element) was executed instead. In despair, a tried to usa a
DocumentFragment instead, as in:
Node fakeRoot = base.getOwnerDocument().createDocumentFragment();
fakeRoot.appendChild(base);
DOMSource xml = new DOMSource( fakeRoot );
Now everything worked as expected, the "/" template was executed and the
output was OK.
Can somebody explain me why this is so? Shouldn't all three solutions
produce the same result? I'm trying to understand what I did wrong and why
only the third solution worked, because similar situations will appear in
other web services.
Thank in advance,
=============================================
Marcelo Jaccoud Amaral
Petrobras - IT - e-business Division
mailto:jaccoud [at] petrobras.com.br
=============================================
There are only 10 kinds of people in the world: those who understand binary
and those who don't.