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

Re: Reshuffling elements

Subject: Re: Reshuffling elements
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 26 Oct 2004 15:19:00 +0100
xml firstchild
Hi Morten,

> I can extend this to heart's content, by adding more blocks, and
> increasing the DATA[1] to DATA[2], DATA[3] and so on, but I would
> rather have solution for any number of auxiliary links.

If I understand correctly, I think you need:

  <xsl:variable name="categories" select="fmp:COL[5]/fmp:DATA" />
  <xsl:variable name="names" select="fmp:COL[6]/fmp:DATA" />
  <xsl:variable name="urls" select="fmp:COL[7]/fmp:DATA" />
  
  <xsl:for-each select="$categories">
    <xsl:variable name="pos" select="position()" />
    <p>
      <em><xsl:value-of select="." />: </em>
      <xsl:value-of select="$names[$pos]" />
      <xsl:text>, URL: </xsl:text>
      <xsl:value-of select="$urls[$pos]" />
    </p>
  </xsl:for-each>

> When I try the following;
>
>     <xsl:for-each select="fmp:COL[6]/fmp:DATA">
>       <xsl:param name="n_pos" select="position()" />
>
>         <p>
>         <xsl:value-of select="$n_pos" />. 
>          <xsl:value-of select="." />, 
>         <xsl:value-of select="../following-sibling/child[1]" /> 
>         </p>
>     </xsl:for-each>

Note that <xsl:param> isn't legal within <xsl:for-each> (your
processor should give you an error). The path
"../following-sibling/child[1]" says "give me the first <child>
element child of each <following-sibling> element child of my parent".
I think you were aiming for something like:

  ../following-sibling::*/child::*[1]

which means "give me the first child of each following sibling of my
parent" (although that wouldn't give you what you were after either --
see above for a solution).

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.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.