Subject: Re: [xsl] Searching in Sub-children from an Array From: Florent Georges <darkman_spam@xxxxxxxx> Date: Mon, 4 Dec 2006 17:50:49 +0100 (CET) |
Houman Khorasani wrote: Hi > There is somewhere in the xml document a <steps> element that > contains several Ids: > <Steps>111,222,333,444</Steps> Something like the following can help you. Warning: not tested! <xsl:key name="my:id" match="*[@id]" use="@id"/> <xsl:function name="my:resolve-path" as="element()*"> <xsl:param name="root" as="node()"/> <xsl:param name="path" as="xs:string"/> <xsl:variable name="steps" select="tokenize($path, ',')"/> <xsl:if test="exist($steps)"> <xsl:sequence select=" my:resolve-path-1(key('my:id', $steps[1], $root), $steps)"/> </xsl:if> </xsl:function> <xsl:function name="my:resolve-path-1" as="element()*"> <xsl:param name="current" as="element()"/> <xsl:param name="steps" as="xs:string*"/> <xsl:sequence select=" $current, if ( exist($steps) ) then my:resolve-path-1($current/*[@id eq $steps[1]], $steps[position() gt 1]) else ()"/> </xsl:function> You can then get the resolved path (that is, a sequence of elements, whose the ids are the same as in steps, in the same order) by: <xsl:sequence select="my:resolve-path(/, steps)"/> 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Searching in Sub-children, Florent Georges | Thread | [xsl] Finding Duplicates with XPath, Rick Quatro |
Re: [xsl] Searching in Sub-children, David Carlisle | Date | [xsl] Finding Duplicates with XPath, Rick Quatro |
Month |