folks i have the following xml file
Now i want to transform it using XSL but problem is, in some book tags, number of authors is 2, in other number of authors is 3... how can i do in XSL so that i dont have to hardcoat it e-g
The above code returns the first author only.. if i do
It becomes hardcoated and rong as well since some books have 3 authors and some have 2,.. is there any way to do it better?
Code:
<?xml version="1.0" version="utf-8"?> <main> <book> <author>A1</author> <author>A2</author> <year>2000</year> </book> <book> <author>b1</author> <author>b2</author> <author>b3</author> <year>2001</year> </book> </main>
Code:
<xsl:for-each select="main/book"> <xsl:sort select="year"/> <p>Author::<xsl:value-of select="author"/></p> <p>Year::<xsl:value-of select="year"/></p>
The above code returns the first author only.. if i do
Code:
<p>Author::<xsl:value-of select="author[1]"/></p> <p>Author::<xsl:value-of select="author[2]"/></p> <p>Author::<xsl:value-of select="author[3]"/></p>
Comment