[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Searching in Sub-children from an Array
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! 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
|