Posted By: NMGod | Oct 28th @ 6:41 AM
page 1 of 1
Comments: 6 | Views: 160

im looking to format something along the lines of this

<a>

   <b>b</b>

   <b>c</b>

</a>

<a>

   <b>b</b>

   <b>c</b>

</a>

<a>

   <b>b</b>

   <b>c</b>

</a>

 

I use the For-each for the <a>'s but im not sure how to show multiples of <b>

ManipUni
ManipUni
Proving QQ for 5 years!

<xsl:for-each select="a">
    <xsl:for-each select="b">
 
    </xsl:for-each>
</xsl:for-each>

 

 

Sven Groot
Sven Groot
My name has 9 letters. Coincidence? I think not...

Or:

 

<xsl:for-each select="a/b">
</xsl:for-each>

 

That will also iterate over all b's in all a's.

ManipUni
ManipUni
Proving QQ for 5 years!

True.

 

Does make reading/following the XSL's logic a little more annoying plus makes it harder to maintain (when you end up adding 'a' after 'a/b' and forget that 'a/b' exists).

ManipUni
ManipUni
Proving QQ for 5 years!

... And this is exactly why you DON'T teach people to use X-Paths like that ...

If you're using for-each, you're doing it wrong.

 

<xsl:template match="a">

    <tr><xsl:apply-templates select="b" /></tr>

</xsl:template>

 

<xsl:template match="b">

    <td><xsl:value-of select="." /></td>

</xsl:template>

page 1 of 1
Comments: 6 | Views: 160
Microsoft Communities