Subject: [xsl] RE: xsl-list Digest 24 Sep 2004 05:10:00 -0000 Issue 187 From: "Paria Heidari" <pheidari@xxxxxxxxxxxxxx> Date: Fri, 24 Sep 2004 08:59:58 -0400 |
This is the xslt that I have which is working with hard-coded 'CUSTOMER' value. Now I need to make this value a dynamic value that will be passed to me from the program. Maybe I am confused about something... ----------------------------- <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="customers"> <html> <body> <table cellpadding="5" cellspacing="2" border="0" width="100%"> <xsl:call-template name="printHeaders"/> <xsl:apply-templates select="CUSTOMER"/> </table> </body> </html> </xsl:template> <xsl:template match="CUSTOMER"> <xsl:call-template name="printNode"/> </xsl:template> <xsl:template name="printHeaders"> <tr bgcolor="#4D5D97"> <xsl:variable name="spanA" select="count(CUSTOMER[1]/child::*[count(child::*)=0])"/> <td colspan="{$spanA}"> <xsl:text> </xsl:text> </td> <xsl:for-each select="CUSTOMER[1]/child::*[count(child::*) > 0]"> <xsl:for-each select="child::*[1]"> <xsl:variable name="spanB" select="count(child::*)"/> <td colspan="{$spanB}" valign="top"> <font face="Arial" size="3" color="white"> <b><xsl:value-of select="name()"/></b> </font> </td> </xsl:for-each> </xsl:for-each> </tr> <tr bgcolor="#4D5D97"> <xsl:for-each select="CUSTOMER[1]/child::*[count(child::*)=0]"> <td valign="top"> <font face="Arial" size="3" color="white"> <b><xsl:value-of select="name()"/></b> </font> </td> </xsl:for-each> <xsl:for-each select="CUSTOMER[1]/child::*[count(child::*) > 0]"> <xsl:for-each select="child::*[1]"> <xsl:for-each select="child::*"> <td valign="top"> <font face="Arial" size="3" color="white"> <b><xsl:value-of select="name()"/></b> </font> </td> </xsl:for-each> </xsl:for-each> </xsl:for-each> </tr> </xsl:template> <xsl:template name="printValues"> <xsl:for-each select="child::*"> <xsl:if test="count(child::*)=0"> <td> <font face="Arial" size="3" color="black"> <xsl:value-of select="."/> </font> </td> </xsl:if> <xsl:if test="count(child::*) > 0"> <xsl:variable name="span" select="count(descendant::*)-1"/> <td colspan="{$span}" valign="top"> <table cellpadding="5" cellspacing="2" border="0" width="100%"> <xsl:for-each select="child::*"> <tr> <xsl:if test="count(child::*) = 0"> <td><xsl:text> </xsl:text></td> </xsl:if> <xsl:for-each select="child::*"> <td> <font face="Arial" size="3" color="black"> <xsl:value-of select="."/> </font> </td> </xsl:for-each> </tr> </xsl:for-each> </table> </td> </xsl:if> </xsl:for-each> </xsl:template> <xsl:template name="printNode"> <tr bgcolor="#FFFFFF"> <xsl:if test="position() mod 2 = 0"> <xsl:attribute name="bgcolor">#E7ECF0</xsl:attribute> </xsl:if> <xsl:call-template name="printValues"/> </tr> </xsl:template> </xsl:stylesheet> -------------------------------- How can I modify my above xslt to use the passed in variable instead of hard-coded 'CUSTOMER' value? Thanks, Paria -----Original Message----- From: David Carlisle [mailto:davidc@xxxxxxxxx] Sent: Friday, September 24, 2004 8:55 AM To: Paria Heidari Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: xsl-list Digest 24 Sep 2004 05:10:00 -0000 Issue 187 > Could you please tell me what should I use for my <xsl:apply-template... > and <xsl:template match... ? So why do you need any parameter at all? You just need <xsl:template match="x"> <html> <head>...</head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="CUSTOMERS"> ... </xsl:template> <xsl:template match="SUPPLIERS"> ... </xsl:template> ... What exactly is the problem that you have? This situation is no different from saying that uou want to process XHTML input and you don't know whether there will be an <em> or a <br/> etc in the source, basically it doesn't matter what there is, you just put in templates for anything that might be there. If it is there the template will be used, if it isn't there it won't do any harm. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ --+------------------------------------------------------------------ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx> --+--
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: xsl-list Digest 24 Sep 20, David Carlisle | Thread | [xsl] Re: xsl-list Digest 24 Sep 20, David Carlisle |
[xsl] Re: xsl-list Digest 24 Sep 20, David Carlisle | Date | Re: [xsl] applying templates to all, David Carlisle |
Month |