Altova Mailing List Archives


Re: [xsl] Passing a list of arguments

From: "Mathieu Malaterre" <mathieu.malaterre@--------->
To:
Date: 11/9/2007 1:29:00 PM
On Nov 9, 2007 2:16 PM, Mukul Gandhi <gandhi.mukul@xxxxxxxxx> wrote:
>
> On 11/9/07, Mathieu Malaterre <mathieu.malaterre@xxxxxxxxx> wrote:
> > test.xml:
> > <?xml version="1.0" encoding="UTF-8"?>
> > <article>
> > </article>
> >
> > test.xsl:
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
> >  <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
> >  <xsl:variable name="sections-list">
> >    <section>
> >      <section>C.8.7.1.1.2</section>
> >      <section>C.8.14.1.1</section>
> >      <!-- ... -->
> >    </section>
> >  </xsl:variable>
> >  <xsl:template match="article">
> >    <xsl:param name="extract-section"/>
> >    <xsl:message>
> >      <xsl:value-of select="$extract-section"/>
> >    </xsl:message>
> >  </xsl:template>
> >  <xsl:template match="/">
> >    <xsl:for-each select="$sections-list">
> >      <xsl:apply-templates select="article">
> >        <xsl:with-param name="extract-section" select="$section"/>
> >      </xsl:apply-templates>
> >    </xsl:for-each>
> >  </xsl:template>
> > </xsl:stylesheet>
>
> You seem to be missing something.
>
> I think, the root template should be:
>
>  <xsl:template match="/">
>    <xsl:for-each select="$sections-list/section/section">
>      <xsl:apply-templates select="article">
>        <xsl:with-param name="extract-section" select="."/>
>      </xsl:apply-templates>
>    </xsl:for-each>
>  </xsl:template>
>
> It's not clear to me what exactly is your requirement. But you seem to
> be writing a wrong XPath expression.


Nevermind, here is something working:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
  <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
  <xsl:variable name="sections-list">
    <section>C.8.7.1.1.2</section>
    <section>C.8.14.1.1</section>
  </xsl:variable>
  <xsl:template name="article">
    <xsl:param name="extract-section"/>
    <el>
      <xsl:value-of select="$extract-section"/>
    </el>
  </xsl:template>
  <xsl:template match="/">
    <e>
      <xsl:for-each select="$sections-list/section">
        <xsl:variable name="arg">
          <xsl:value-of select="."/>
        </xsl:variable>
        <xsl:call-template name="article">
          <xsl:with-param name="extract-section" select="$arg"/>
        </xsl:call-template>
      </xsl:for-each>
    </e>
  </xsl:template>
</xsl:stylesheet>

Thanks anyway,
-- 
Mathieu

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.