Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


using XSL variable

From: "BosXSL" <thechait@-----.--->
To: 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) &gt;= 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) &gt;= 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>



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent