Re: [xsl] global xsl:variable problem, value not being set

Subject: Re: [xsl] global xsl:variable problem, value not being set
From: Adam Retter <adam.retter@xxxxxxxxxxxxxx>
Date: Mon, 7 Sep 2009 11:11:24 +0100
Ashok,

You are missing your namespace declarations and prefixes in the XSLT
document.

Try -


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:ml="http://www.metalex.org/1.0";>
     <xsl:output indent="yes" method="xml" encoding="UTF-8"/>

 <xsl:variable name="refName">
     <xsl:value-of select="//ml:meta[@id='judgementNo']/@href" />
 </xsl:variable>

Cheers Adam.

2009/9/7 ashok _ <listmanster@xxxxxxxxx>:
> I am not sure what i am doing wrong ... but i am setting a global
> xsl:variable which I then refer to within the template but in the
> output transform the variable is always blank,
>
> My Xslt [1] , and the Xml being transformed [2].  The original xml
> file is quite big, but i have trimmed it down to demonstrate the
> problem. I guess I am missing something simple :-(
>
> (Using saxon 9)
>
> [1] -- Xslt -- refName is always set to blank
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>      <xsl:output indent="yes" method="xml" encoding="UTF-8"/>
>
>  <xsl:variable name="refName">
>      <xsl:value-of select="//meta[@id='judgementNo']/@href" />
>  </xsl:variable>
>
>      <xsl:template match="/">
>              <xsl:apply-templates/>
>      </xsl:template>
>
>
>      <xsl:template match="*">
>              <xsl:element name="{node-name(.)}">
>                      <xsl:for-each select="@*">
>                              <xsl:attribute name="{name(.)}">
>                                      <xsl:value-of select="."/>
>                              </xsl:attribute>
>                      </xsl:for-each>
>                      <xsl:apply-templates/>
>              </xsl:element>
>      </xsl:template>
>
>
>      <xsl:template match="*[@name='ref']">
>                      <metavalue>
>                              <xsl:attribute
> name="test"><xsl:value-of select="$refName"
> /></xsl:attribute>
>                      </metavalue>
>              </xsl:template>
> </xsl:stylesheet>
>
>
> [2] Xml file being transformed :
>
> <?xml version="1.0" encoding="UTF-8"?><root
> xmlns="http://www.metalex.org/1.0"; name="root" id="d3e1">
>  <container id="judgement" class="Sect1" name="body">
>    <mcontainer name="meta">
>       <mcontainer id="references_d3e151" name="references"
> source="#bungeni">
>          <meta name="TLCConcept" id="judgementNo"
> href="/ontology/concept/judgement/Judgement/653/07" showAs="653/07"/>
>       </mcontainer>
>    </mcontainer>
>    <hcontainer __BungeniMetaEditable="false" id="header"
> class="Sect2" name="Header">
>       <htitle id="d3e7" name="heading" class="5f">THE SUPREME COURT
> OF APPEAL REPUBLIC OF XXXXXX</htitle>
>       <container id="d5e10" name="fixing_hcontainer">
>          <block name="p" id="d3e10" class="Standard">Judgement No
> :<inline name="ref" class="mJudgementNo" href="839" id="d5e12">14 of
> 2007</inline>
>          </block>
>       </container>
>       <container id="d5e16" name="fixing_hcontainer">
>          <block name="p" id="d3e19" class="P3">Case number:<inline
> name="ref" class="mCaseNo" href="5166" id="d5e18">653/07</inline>
>          </block>
>       </container>
>    </hcontainer>
>  </container>
> </root>
>
>



--
Adam Retter

skype :adam.retter
http://www.adamretter.org.uk

Current Thread