Subject: [xsl] Simple Xsl Problem From: Nischal <nischal_muthana@xxxxxxxxx> Date: Sun, 9 Nov 2003 13:59:23 -0800 (PST) |
Hi All I have an xml file like the following: <Parent> <Orders> <Order1> <ItemName>TV</ItemName> <ItemModel>Sony</ItemModel> <ItemPrice>423424</ItemPrice> </Order1> <Order1> <ItemName>VCR</ItemName> <ItemModel>Mitsubishi</ItemModel> <ItemPrice>1233213</ItemPrice> </Order1> <Order2> <ItemLocation>San Francisco</ItemLocation> <ItemTime>200310101010</ItemTime> </Order2> <Order3> <ItemPrice>1000</ItemPrice> </Order3> </Orders> </Parent> I trying to build a generic xsl transform which would pick up all the unique Orders(Order1's, Order2's and Order3's and so on...) and build a table like below. Order1 ItemName ItemModel ItemPrice TV Sony 423424 VCR Mitsubishi 1233213 Order2 ItemLocation ItemTime San Francisco 200310101010 Order3 ItemPrice 1000 All of this I am trying to build a generic xsl template. Questions: 1. I wasn't able to get the unique node names and get the child nodes to print out them. Can someone help me in how to approach this. Here is my stupid xsl I started off with and got stuck. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:template match="/"> <xsl:variable name="Test" select="/Parent/Orders/*"/> <xsl:call-template name="Test"> <xsl:with-param name="OrderName" select="$Test"/> </xsl:call-template> </xsl:template> <xsl:template name="Test"> <xsl:param name="OrderName"/> <xsl:for-each select="$OrderName"> <p> <xsl:variable name="pos" select="position()" /> <xsl:choose> <xsl:when test="not($pos = 1)"> <xsl:choose> <xsl:when test="name() = preceding-sibling::*[$OrderName]"> <table> <tr><xsl:value-of select="name()"/></tr> <tr> <td><xsl:value-of select="string(preceding-sibling::*[$OrderName])" /></td> </tr> <tr> <xsl:value-of select="string($OrderName)"/> </tr> </table> <xsl:text> </xsl:text> </xsl:when> <xsl:otherwise> <table> <tr> <xsl:value-of select="string($OrderName)"/> </tr> </table> </xsl:otherwise> </xsl:choose> </xsl:when> </xsl:choose> </p> </xsl:for-each> </xsl:template> Appreciate your time. Thanks Nischal __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Re: Re: Can not convert #, arun prasath | Thread | Re: [xsl] Simple Xsl Problem, J.Pietschmann |
[xsl] Re: Re: Can not convert #STRI, Dimitre Novatchev | Date | [xsl] count doesnt get incremented, suresh reddy |
Month |