|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Variable in XPath
Garvin Riensche wrote: Hi > <xsl:when test="doc('factbase.xml')/facts/class[@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 ___________________________________________________________________________ Dicouvrez une nouvelle fagon d'obtenir des riponses ` toutes vos questions ! Profitez des connaissances, des opinions et des expiriences des internautes sur Yahoo! Questions/Riponses http://fr.answers.yahoo.com
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Cast Your Vote
We need your help – Vote for DataDirect XML Products!
Winners and finalists announced at SOA World Conference in November. Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|







