Re: [xsl] Variable Problems

Subject: Re: [xsl] Variable Problems
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Wed, 07 Sep 2005 12:56:06 +0200
Tempore 11:09:50, die 09/07/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit James Game <jgame@xxxxxxxxxxxxxxxxxxxxxxx>:

Hi Joris (don't know what happened with previous post)

This is an example of data I have pulled from another source and I will be
looking for the same structure.  The fields are obviously named slightly
different but you get the idea.  This is the output I receive once run
through Oxygen using Xalan.

Im not too sure where the XML / XSL disagree (original post)- could you
point that out for me.


In your xslt, there ithis statement:

<xsl:variable name="price" select="price" />

This will put the 'price' element (the child node of the context node) in a variable called 'price'.

But there aren't any 'price' elements in your XML.


TRy this stylesheet:


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:output method="xml" />


<xsl:template match = "/" > <DATAPACKET Version="2.0"> <xsl:call-template name="CDSMetaData"/> <ROWDATA> <xsl:apply-templates/> </ROWDATA> </DATAPACKET> </xsl:template>

<xsl:template name="CDSMetaData">
	<METADATA>
		<FIELDS>
			<FIELD attrname="id" fieldtype="string" WIDTH="255"/>
			<FIELD attrname="price" fieldtype="string" WIDTH="255"/>
			<FIELD attrname="address1" fieldtype="string" WIDTH="255"/>
			<FIELD attrname="address2" fieldtype="string" WIDTH="255"/>
			<FIELD attrname="typedesc" fieldtype="string" WIDTH="255"/>
			<FIELD attrname="image" fieldtype="string" WIDTH="255"/>
			<FIELD attrname="bullets" fieldtype="string" WIDTH="255"/>
		</FIELDS>
	</METADATA>
</xsl:template>
		
<xsl:template match="desc">
<ROW>
	<xsl:apply-templates/>
</ROW>
</xsl:template>

<xsl:template match="detail">
	<xsl:attribute name="{@name}"><xsl:apply-templates/></xsl:attribute>
</xsl:template>

<xsl:template match="section[@name='bullets']/d">
	<xsl:attribute name="starpoint{position()}"><xsl:apply-templates/></xsl:attribute>
</xsl:template>

<xsl:template match="section[@name='pics']/g">
	<xsl:attribute name="image{position()}"><xsl:apply-templates/></xsl:attribute>
</xsl:template>

</xsl:stylesheet>


regards, -- Joris Gillis (http://users.telenet.be/root-jg/me.html) Gaudiam omnibus traderat W3C, nec vana fides

Current Thread