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: Wed, 26 Sep 2007 09:48:28 +0200
Senthil Nathan wrote:
Hi,
I'm sorry for posting the message several times. I got mailer-daemon's
whenever I post it. something wrong with my message content type
earlier.
No problem. Sometimes it is good to wait a while and see whether or not your message shows on the list. Also, you can start subsequent messages with something like "new try, perhaps it is a copy, but the first gave me an error" or something like that.


----> Sorry. I dont want to use the command line.

Consider downloading and using Kernow. It is meant for this kind of thing: running multiple xslt stylesheets against multiple documents.

-----> I'm now writing a cpp program using libxslt api's over libxml api's. I have the pointer to the dom tree for "merge.xslt" and another dom tree for "merge.xml". Using these api's I could apply the xslt on the xml.

But the content of the merge.xml is, which merge.xslt needs, is the 2
files which needs to be merged.

Instead, I would like to pass the DOM trees for these 2 files for
applying merge.xslt on it.

I see, but aren't you making something that's supposed to be simple awkwardly hard? It is a nice challenge to do something like this, but really, I have no knowledge of the inner workings of libxslt. I am sure I can find out when I'd create my own C++ project and when I use the original sources of libxslt, but unfortunately I lack the time and the interest to do so (I like to move on and use Saxon rather, which is XSLT 2.0, if that has a missing feature, I kindly ask Michael and more often than not he shows me how to do it with the product that's already there).


---> so, otherwise how do I merge several xml files using the xslt
library api's in cpp.
And is there any examples can you send me, which would read the
document URI's and use it for merging xml's.

Thanks for helping this far and trying to understand my problem.
Thanks a lot.

Well, the easiest thing I can think of is something like the following. Place this in 'merge-catalog.xml':


<mergable-docs base-uri="file:///c:/temp/">
  <doc uri="my-relative-uri.xml" />
  <doc uri="my-relative-uri-2.xml" />
</mergable>

Then, in your xslt you would do something like this:

<xsl:variable name="mergethese" select="document('merge-catalog.xml')" />

<xsl:template match="/" >
   <xsl:variable name="base-uri" select="$mergethese/mergable/@base-uri" />
   <xsl:for-each select="$mergethese/mergable/doc">
       <xsl:apply-templates select="document(concat($base-uri, @uri))" />
   </xsl:for-each>
</xsl:template>

<xsl:template match="somenode-from-mergabledoc" >
......
</


Then you are very flexible and you can do whatever you want. Of course, if all you want to do is just to concatenate the documents, instead of apply-templates, you can also use xsl:copy-of.with a supplied root-element around the bunch.


HTH,
Cheers,
-- Abel Braaksma

Current Thread