Garvin Riensche wrote:
Hi
<xsl:when test="doc('factbase.xml')/facts/class[(_at_)id eq $id
and @owner eq $owner and @name eq $name]">
This will return false because $id is empty. My quesion
is, is there a default value that I can put in the select
of <xsl:variable name="id" select"?????"/> so that the
test above will return true?
I think that if you can use XSLT 2.0, the more straight
forward would be to defined your predicates as functions:
<xsl:function name="my:equals" as="xs:boolean">
<xsl:param name="lhs" as="attribute()"/>
<xsl:param name="rhs" as="item()?"/>
<xsl:sequence select="
if ( empty($rhs) ) then
true()
else
$lhs eq $rhs"/>
</xsl:function>
<xsl:function name="my:matches" as="xs:boolean">
<xsl:param name="elem" as="element()"/>
<xsl:param name="id" as="item()?"/>
<xsl:param name="owner" as="item()?"/>
<xsl:param name="name" as="item()?"/>
<xsl:sequence select="
my:equals($elem/@id, $id)
and my:equals($elem/@owner, $owner)
and my:equals($elem/@name, $name)"/>
</xsl:function>
and then in your code:
<xsl:if test="my:matches(the-elem, 'id', 'owner', 'name')">
If the values to test against are global parameters, just
use:
<xsl:function name="my:matches" as="xs:boolean">
<xsl:param name="elem" as="element()"/>
<xsl:sequence select="
my:equals($elem/@id, $id)
and my:equals($elem/@owner, $owner)
and my:equals($elem/@name, $name)"/>
</xsl:function>
and:
<xsl:if test="my:matches(the-elem)">
Regards,
--drkm
___________________________________________________________________________
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !
Profitez des connaissances, des opinions et des expériences des internautes sur
Yahoo! Questions/Réponses
http://fr.answers.yahoo.com
--~------------------------------------------------------------------
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>
--~--