Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: using XSL variable using XSL variableTo: NULL Date: 9/1/2005 7:54:00 AM Hi:
I have a problem using xsl variable. I'm trying to create a table for
product comparison. There will be 2-4 products to compare. You don't
know there are 2 ro 3 or 4. It depends on XML, so the table column is
dynamic.
The problem is I'm trying to append a variable $xmltag. It doesn't
interpret as I want. I have tried my ways using +, quote, [].
<xsl:copy-of select="content[1]/$xmltag"/>
If anyone knows how to do it, please help.
----------------This is my xslt file-----------------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html"/>
<xsl:template match="xml" xml:space="preserve">
<a href="#">RETURN TO LIST</a>
<table cellpadding="0" cellspacing="0" width="100%" border="1">
<tr>
<td>Model</td>
<td>first</td>
<td>second</td>
<xsl:if test="count(content) >= 3"><td>third</td></xsl:if>
<xsl:if test="count(content) = 4"><td>forth</td></xsl:if>
</tr>
<xsl:call-template name="createRow">
<xsl:with-param name="xmlname">Avarage Price</xsl:with-param>
<xsl:with-param name="xmltag">AveragePrice</xsl:with-param>
</xsl:call-template>
</table>
</xsl:template>
<xsl:template name="createRow">
<xsl:param name="xmlname"/>
<xsl:param name="xmltag"/>
<tr>
<td><xsl:value-of select="$xmlname"/></td>
<td><xsl:copy-of select="content[1]/$xmltag"/></td>
<td><xsl:value-of select="content[2]/$xmltag"/></td>
<xsl:if test="count(content) >= 3"><td><xsl:value-of
select="content[3]/$xmltag"/></td></xsl:if>
<xsl:if test="count(content) = 4"><td><xsl:value-of
select="content[4]/$xmltag"/></td></xsl:if>
</tr>
</xsl:template>
</xsl:stylesheet>
------------------ XML -----------------------
<xml CollectionTitle="Collection Title" CollectionID="1234" >
<content>
<ContentID>86</ContentID>
<ContentType>2</ContentType>
<TitleTag>This is a title</TitleTag>
<ProductName>Dark brown L-shape table</ProductName>
<ProductSubSubType>L-shape</ProductSubSubType>
<ProductSubType>Table</ProductSubType>
<ProductType>Office Furniture</ProductType>
<ManufacturerID>55</ManufacturerID>
<ProductSummary>This is a product summary of the L-shape table. It is
great and very comfortable.</ProductSummary>
<FullText>Duis autem vel eum iriure dolor in hendrerit in vulputate
velit esse molestie consequat, vel illum dolore eu feugiat nulla
facilisis.</FullText>
<ManufacturersDescription>This manufacturer produces high-quality
office furniture such as table, desk, chair,
etc.</ManufacturersDescription>
<AveragePrice>350</AveragePrice>
<Weight>20</Weight>
<Depth>40</Depth>
<Width>180</Width>
<Height>200</Height>
</content>
<content>
<ContentID>75</ContentID>
<ContentType>1</ContentType>
<TitleTag>This is a title2</TitleTag>
<ProductName>Black L-shape table</ProductName>
<ProductSubSubType>L-shape</ProductSubSubType>
<ProductSubType>Table</ProductSubType>
<ProductType>Office Furniture</ProductType>
<ManufacturerID>55</ManufacturerID>
<ProductSummary>This is a product summary of the L-shape table. It is
great and very comfortable.</ProductSummary>
<FullText>Duis autem vel eum iriure dolor in hendrerit in vulputate
velit esse molestie consequat, vel illum dolore eu feugiat nulla
facilisis.</FullText>
<ManufacturersDescription>This manufacturer produces high-quality
office furniture such as table, desk, chair,
etc.</ManufacturersDescription>
<AveragePrice>360</AveragePrice>
<Weight>20</Weight>
<Depth>40</Depth>
<Width>180</Width>
<Height>200</Height>
</content>
</xml>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
