xsl-list
[Top] [All Lists]

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

2007-09-14 08:49:17
Hi Abel,
I have been using libxslt, libxml2 and its api's. I know that the xslt file and 
the xml file will be parsed by libxslt and the stylesheet will be applied over 
that. (There is a thread before this, where I have said abt merge.xslt and 
merge.xml)

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.

Mike Suggested as below, but I'm not sure how to do that.

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

merge.xslt is calling 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>

How do I pass the DOM tree, instead of $file1 and $file2 in document( )?

Can anyone help me out of this.

Thanks
Senthil Nathan R


On 9/14/07, Abel Braaksma <abel(_dot_)online(_at_)xs4all(_dot_)nl> wrote:
Hi Senthil,

Libxslt has its own specific list. Please use that one for libxslt
specific questions.
If you do a search in the archive (through google, they are re-indexing
it):
http://www.google.nl/search?hl=nl&sa=X&oi=spell&resnum=0&ct=result&cd=1&q=site:http://mail.gnome.org/archives/xslt/+command+line&spell=1

And if it is not there, there's of course the documentation and faq
section for libxslt.

List archives libxslt: http://mail.gnome.org/archives/xslt/
FAQ: http://xmlsoft.org/XSLT/FAQ.html
Command line: http://xmlsoft.org/XSLT/xsltproc2.html

From the FAQ, if you want a document node set as a parameter, since
they are using xpath instructions that get interpreted at root level, it
shouldn't be too hard to make your xpath look something like this on the
command line: document('http://myfile.bla.bla.xml'), possibly with a
selective xpath statement.

Cheers,
-- Abel Braaksma

PS: you would have gotten this information (sparsely but clear enough)
with just issuing the command "xsltproc" on the commandline.


Senthil Nathan wrote:
But, I'm using libxslt. So any samples like how to pass the DOM trees
as parameters to stylesheet in libxslt??

Thanks
Senthil

On 9/14/07, Abel Braaksma <abel(_dot_)online(_at_)xs4all(_dot_)nl> wrote:

Senthil Nathan wrote:

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.



If you can use Saxon, it goes like this (from the documentation pages):

A param preceded by a leading plus sign (+) is interpreted as a filename
or directory. The content of the file is parsed as XML, and the
resulting document node is passed to the stylesheet as the value of the
parameter. If the parameter value is a directory, then all the
immediately contained files are parsed as XML, and the resulting
sequence of document nodes is passed as the value of the parameter. For
example, +lookup=lookup.xml sets the value of the stylesheet parameter
lookup to the document node at the root of the tree representing the
parsed contents of the file lookup.xml.


Cheers,
-- Abel Braaksma


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--