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

Subject: Re: [xsl] merging xml's using XSLT, merge.xslt
From: "Senthil Nathan" <rsennat@xxxxxxxxx>
Date: Fri, 14 Sep 2007 11:57:13 +0530
Hi Michael,
How about the other option of passing DOM's as parameters to stylesheet.

> > You could supply the two input DOMs to the stylesheet as
> > parameters, and replace the calls on document() by references
> > to the parameters.

Any sample of doing the same would be helpful.

Thanks
Senthil

On 9/13/07, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> The URIResolver is a concept that applies to Java processors implementing
> the JAXP interface, it allows you to intercept calls on document() and
> redirect them under application control. I don't know if libxslt has
> anything similar.
>
> Michael Kay
> http://www.saxonica.com/
>
> > -----Original Message-----
> > From: Senthil Nathan [mailto:rsennat@xxxxxxxxx]
> > Sent: 13 September 2007 10:31
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx; mike@xxxxxxxxxxxx
> > Subject: RE: [xsl] merging xml's using XSLT, merge.xslt
> >
> > Hi,
> > Could you please tell me more about those options.
> > Specifically about, using an URIResolver which returns the
> > DOM tree to the document request in the stylesheet.
> >
> > As of now, I have been using it as,
> > merge.xml is as,
> >    <merge xmlns="http://informatik.hu-berlin.de/merge";>
> >       <file1>f1.xml</file1>
> >       <file2>f2.xml</file2>
> >    </merge>
> >
> > Now I have been using libxslt. In which I do it as, (there is
> > some more behind the scenes, but just for information).
> >         cur = xsltParseStylesheetFile((const xmlChar *)"merge.xslt");
> >         doc = xmlParseFile("merge.xml");
> >         res = xsltApplyStylesheet(cur, doc, params);
> >
> > Thanks
> > Senthil
> >
> > --------------------------------------------------------------
> > ---------------
> > Date: Wed, 12 Sep 2007 09:25:50 +0100
> > To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> > From: "Michael Kay" < mike@xxxxxxxxxxxx>
> > Subject: RE: [xsl] merging xml's using XSLT, merge.xslt
> > Message-ID: <00af01c7f516$86d59b60$6401a8c0@turtle >
> >
> > You could supply the two input DOMs to the stylesheet as
> > parameters, and replace the calls on document() by references
> > to the parameters.
> >
> > Alternatively you could use the stylesheet unchanged, and
> > write a URIResolver that returns the DOM tree in response to
> > the document request for file1 or file2.
> >
> > Michael Kay
> > http://www.saxonica.com/
> >
> > > -----Original Message-----
> > > From: Senthil Nathan [mailto:rsennat@xxxxxxxxx]
> > > Sent: 12 September 2007 06:49
> > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > > Subject: [xsl] merging xml's using XSLT, merge.xslt
> > >
> > > Hi All,
> > > I'm trying to merge 2 or more XML's to form a single XML using
> > > "merge.xslt"
> > > from the foll. link,
> > > http://www2.informatik.hu-berlin.de/~obecker/XSLT/#merge
> > >
> > > I'm doing this using libxslt. And I face a problem from the
> > XSLT front
> > > that, I need to specify the files that I'm going to merge
> > within the
> > > merge tags as,  <merge xmlns="http://informatik.hu-berlin.de/merge";>
> > >     <file1>file1.xml </file1>
> > >     <file2>file2.xml</file2>
> > >  </merge>
> > >
> > > Suppose if I have the DOM tree of those files in memory,
> > how should I
> > > need to use merge.xslt to merge the trees in memory??
> > >
> > > Actually in merge.xslt, the files specified are accessed as,
> > > <xslt:call-template name="m:merge">
> > >     <xslt:with-param name="nodes1"
> > > select="document($file1,/*) /node()" />
> > >     <xslt:with-param name="nodes2"
> > > select="document($file2,/*)/node()" />  </xslt:call-template>
> > >
> > > So, is it possible to use merge.xslt for merging DOM trees of
> > > file1.xml, file2.xml.
> > >
> > > Thanks
> > > Senthil

Current Thread