What should I write in my stylesheet (XSL) so that it
gets the XML DOM reference in an XSL variable????
You can't do this in XSLT alone. You need to write some code.
Is the work in above going to be more than using the
importNode(...) and insertBefore(...) function from
Document and Node classes respectively to merge the
XMLs???
If you can merge them before passing them to XSLT, you can use those
approaches. You can't use them within XSLT; there is a basic assumption
that each source document is immutable for the duration of the
stylesheet's execution.
I see two possible approaches here.
1) This one I'm sure would work: Write an extension function (see Xalan's
documentation on extension functions), and architect some way in your own
code for that function to find the DOM(s) you want to access. Pass the
Document nodes to Xalan as the return values of this function, and we'll
wrapper it and Do The Right Thing. Possible efficiency issue: If you
expect to access the same DOM multiple times, you should probably call
your extension only once and assign the returned value to an XSLT
variable.
For information about writing Xalan extensions, see
http://xml.apache.org/xalan-j/extensions.html
2) I'm not sure of this one since I haven't tried it in a long time,
but... it's possible to pass a DOM node into Xalan as a parameter, via
the TrAX APIs, before running the stylesheet. Essentially, this is
equivalent to assigning the object to a variable before stylesheet
processing starts -- though of course your stylesheet has to be written to
expect and use that parameter. The thing I'm not certain of is whether
this will recognize the DOM node and automatically give Xalan full access
to the DOM tree (convert it to a nodeset), or if Xalan will treat it as a
"non-XSLT object" and force you to pass it through an extension before you
can see its contents. Can't hurt to try...
For information about parameters, see
http://xml.apache.org/xalan-j/usagepatterns.html#params
______________________________________
Joe Kesselman / IBM Research
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list