Subject: Re: [xsl] matching elements of a list From: Rolf Schumacher <mailinglist@xxxxxxxxx> Date: Wed, 09 May 2007 00:00:17 +0200 |
I should learn about key(...) and lists, Michael, in order to understand how this will work. However, I've got to check for cycles ... Michael Kay wrote: > This is a recursive query, and is therefore beyond the scope of XPath alone: > it needs recursive functions. But it's easy in XSLT (untested!): > > <xsl:key name="k" match="ln" use="@s"/> > > <xsl:function name="my:children" as="xs:string*"> > <xsl:param name="parent" as="xs:string"/> > <xsl:sequence select="key('k', $parent)/@d"/> > </xsl:function> > > <xsl:function name="my:descendants" as="xs:string*"> > <xsl:param name="parent" as="xs:string"/> > <xsl:variable name="children" select="my:children($parent)"/> > <xsl:sequence select="$children, for $c in $children return > my:descendants($c)"/> > </xsl:function> > > A bit harder if you need to add a check for cycles, but still doable. > > Michael Kay > http://www.saxonica.com/ > > >> -----Original Message----- >> From: Rolf Schumacher [mailto:mailinglist@xxxxxxxxx] >> Sent: 08 May 2007 06:01 >> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx >> Subject: [xsl] matching elements of a list >> >> do I have reached the limits of xpath? >> >> if several linked lists are contained in one document how to >> match all nodes belonging to a specific start node? >> >> The following example may illustrate my question: >> >> Input: >> <root> >> <st ix="a"/> >> <st ix="b"/> >> <el ix="c"/> >> <el ix="d"/> >> <el ix="e"/> >> <el ix="f"/> >> <el ix="g"/> >> >> <ln s="a" d="g"/> >> <ln s="g" d="f"/> >> >> <ln s="b" d="e"/> >> <ln s="e" d="c"/> >> <ln s="c" d="d"/> >> </root> >> >> disired output: >> >> a: g f >> b: e c d >> >> How to accomplish that by XSLT (2.0)? >> Even your answer "I know for sure that there is not elegant way" >> or "You got to extend the processor by some Java function" >> would help.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] matching elements of a li, Michael Kay | Thread | RE: [xsl] matching elements of a li, Michael Kay |
Re: [xsl] matching elements of a li, Rolf Schumacher | Date | RE: [xsl] matching elements of a li, Michael Kay |
Month |