[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Searching in Sub-children from an Array

Subject: Re: Searching in Sub-children from an Array
From: Florent Georges <darkman_spam@xxxxxxxx>
Date: Mon, 4 Dec 2006 17:50:49 +0100 (CET)
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.