Re: [xsl] Got xml base path in the xslt file

Subject: Re: [xsl] Got xml base path in the xslt file
From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
Date: Wed, 16 Sep 2009 08:45:45 +0530
I could think of following strategy to tackle this problem.

You could put XML and XSL files into different folders. Then you could
pass the directory location of XML files, into your stylesheet as a
parameter. Something like following:

<xsl:param name="xmlBase" />

<xsl:for-each select="document(concat($xmlBase, '/', $fileName))">
   ...

I have not tested this, though.

On Wed, Sep 16, 2009 at 7:59 AM, Dongsheng Song
<dongsheng.song@xxxxxxxxx> wrote:
> Hi all,
> I use a xsl file to merge multiple xml files, B the master xml file like
this:
>
> <doc>
> B  B  B  B <doc id="Intro" />
> B  B  B  B <doc id="Configuration" />
> B  B  B  B <doc id="Index" />
> </doc>
>
>
> The xsl file like this:
>
> <xsl:for-each select="doc/doc">
> B  B <xsl:variable name="fileName"><xsl:value-of select="@id"
> /><xsl:text>.xml</xsl:text></xsl:variable>
>
> B  B <xsl:for-each select="document($fileName)">
> B  B  B  B <xsl:copy-of select="doc/div"/>
> B  B </xsl:for-each>
> </xsl:for-each>
>
> Because the file path is relative of B the xsl file for 'document'
> function, I have to put xsl and xml files together.
> Can I got the base path of master xml file, so I can store xsl and xml
> file separately?
>
> Regards,
> Dongsheng Song


--
Regards,
Mukul Gandhi

Current Thread