xsl-list
[Top] [All Lists]

Re: Legal Match ?

2003-03-14 10:39:12
Hi Karl,

Is this a legal match?
<xsl:apply-templates select="z:row[(_at_)CreditStatus='$CREDIT_STATUS;']"/>

Where $CREDIT_STATUS is a global variable.

It wouldn't matter whether you had a $CREDIT_STATUS global variable or
not -- the 's around $CREDIT_STATUS mean that you're just selecting
those z:row elements whose CreditStatus attribute has the string value
"$CREDIT_STATUS;".

If you meant:

  <xsl:apply-templates select="z:row[(_at_)CreditStatus = $CREDIT_STATUS]"/>

then yes, that's legal, and it *selects* (not matches) those z:row
elements whose CreditStatus attribute's value is the same as the value
of the $CREDIT_STATUS variable.

If so... what does the template rule look like? Something like:

<xsl:template match="z:row[(_at_)CreditStatus='$CREDIT_STATUS;']>
....
</xsl:template match>

You're not allowed to refer to variables within the match attribute of
<xsl:template> in XSLT 1.0 (XSLT 2.0 lifts this restriction). But as
long as you only apply templates to the z:row elements that you're
interested in, that shouldn't matter; you can match them with a
variety of templates, but it's most likely that you'll want to do:

<!-- match all z:row elements -->
<xsl:template match="z:row">...</xsl:template>

or:

<!-- match those z:row elements with a CreditStatus attribute -->
<xsl:template match="z:row[(_at_)CreditStatus]">...</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>