Re: [xslt] key() in match pattern of xsl:key

On Sun, 11 Dec 2005, Daniel Veillard wrote:

>   Just send the input XSL and input XML as attachments and describe what
> you're testing, that will be sufficient if no code change is needed then
> (i.e. assuming the ouptut from the current version works as you expect).

I've moved the XSL and XML from my previous post to attachments.  I 
believe the description is really one sentence:

Check that the match pattern of an xsl:key may contain a forward reference 
to another xsl:key.


<?xml version="1.0" encoding="iso-8859-1"?>

<?xml version="1.0" encoding="iso-8859-1"?>


<xsl:output method="text" />

<xsl:key name="keyA" match="A" use="." />
<xsl:key name="keyAnotB" match="A[ not( key( 'keyB', . ) ) ]" use = "." />
<xsl:key name="keyB" match="B" use="." />
<xsl:variable name="AnotB" select="//A[ not( key( 'keyB', . ) ) ]" />

<xsl:template match="/">
  <xsl:for-each select="//A">
    <xsl:call-template name="print_membership" />
  <xsl:for-each select="//B">
    <xsl:call-template name="print_membership" />
  <xsl:for-each select="$AnotB">
    <xsl:call-template name="print_membership" />

<xsl:template name="print_membership">
  <xsl:text>  </xsl:text><xsl:value-of select="." />
  <xsl:text>: A=</xsl:text>
  <xsl:value-of select="count( key( 'keyA', . ) )" />
  <xsl:text>, B=</xsl:text>
  <xsl:value-of select="count( key( 'keyB', . ) )" />
  <xsl:text>, AnotB=</xsl:text>
  <xsl:value-of select="count( key( 'keyAnotB', . ) )" />


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]