Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Searching in Sub-children from an Array

From: Florent Georges <darkman_spam@-------->
To:
Date: 12/4/2006 4:58:00 PM
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


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent