[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] merging xml's using XSLT, merge.xslt


Subject: Re: [xsl] merging xml's using XSLT, merge.xslt
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Tue, 25 Sep 2007 18:18:00 +0200

Hi Senthil,

[Why did you send this message four times (probably I received it four times because you also send it to my personal account)? And why did you send it my personal account? Just to the list would be enough, I'm there. And unless for compelling reasons, please don't address me personally but use the public list. I'll read it, really.]


Anyway, I looked up the history, and I am not sure what the problem is. It seemed that, in defiance of the subject line and your comments, you want to give the dom tree, or, a dom document from the command line, which I showed you how. Here's the latest we talked about (which you didn't answer, btw):


But I wanted to know more about "passing parameters to XSLT". I'm merging 2 or more XML's and for which I specify the static file names. Instead I wanted to give the DOM tree as input to the XSLT.

well, you can trick it the easy way like I suggested, because in libxslt every param is an xpatch. If you pass it in a parameter that looks like a correct document('') call you are in fact passing in a DOM tree. That was why I suggested it.
and...

The harder way is by using the API. I don't know in what context you are using libxslt, but when you want to extend the system, you can simply use the API. Probably not so simple, depends on how handy you are with Java or c++. some info can be found here: http://xmlsoft.org/XSLT/html/libxslt-xsltInternals.html and some other info can be found here: http://xmlsoft.org/XSLT/tutorial/libxslttutorial.html#parameters

But from what I read here, it does in code about the same as you can do on the commandline. Depending on how much you want to invest in it, I suggest you take this very specific question to the libxslt list.

In short: a DOM node can only be given to libxslt with an XPath and all possibilities you have there, or you'll have to program the interfaces.

In other words: I have no idea why you are having troubles. The most-used pattern for processing multiple input documents (i.e., for merging, sorting or whatever) is to use a catalog file, which any XSLT can read. Then, from this catalog file, which should be in XML, you can read the document URIs which you can process further using the document() function.


If you use PHP or whatever other language, consider creating a Java bridge to call into Saxon's Java interface. This would be easier in Python or in Ruby, if I remember correctly. How to use the API of Saxon and how to pass on nodes as arguments is extensively described in the Saxon manual

HTH,

Cheers,
-- Abel Braaksma


Senthil Nathan wrote:
Hi Abel,
I'm coming back to this thread after sometime, during which I couldn't
find a solution in libxslt forums. They said its not possible. But you
were saying about using that.

Basically, I have several XML files and I would like to merge using
"merge.xslt" and using the libxslt API's from my code. Actually I can
specify only two files there, which needs to be merged.

So, I thought if I can pass on the DOM tree to merge.xslt, I can merge
any number of xml files. Please let me know, if you have any idea on
using libxslt in this case.

Otherwise, is it possible to use saxon (its api) over libxml2 for
merging DOM trees using "merge.xslt". Please give me the pointers to
do that.

Thanks
Senthil Nathan R


Current Thread
Keywords