xsl-list
[Top] [All Lists]

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

2009-09-07 06:22:48

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


That makes a new temporary document with a root node and a text node
child, which is rather inefficient, you should use teh form with teh
select on teh xsl:variable


  <xsl:variable name="refName"
  select="//meta[(_at_)id='judgementNo']/@href" />


which defines refName to be the selected attribute directly.

However that selects the meta element in no-namespace and you want the
element meta in the namespace http://www.metalex.org/1.0 so either set
the xpath default namespace or add
xmlns:m="http://www.metalex.org/1.0"; to xsl:stylesheet and then use


  <xsl:variable name="refName"
  select="//m:meta[(_at_)id='judgementNo']/@href" />

If you know where teh meta element will be using something more specific
than // woul dbe a good idea as well.


Do you intend to change the namespace of all elements?

      <xsl:template match="*">
              <xsl:element name="{node-name(.)}">

That generates a new element with the same local name, but in teh
default namespace of the stylesheet (which is no namespace in your case)
rather than the defaulr namespace of the source.  If you do not intent
to change namespace, you can write

      <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>



as

<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

--~------------------------------------------------------------------
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>
--~--