xsl-list
[Top] [All Lists]

Re: Variable Problems

2005-09-07 03:56:06
Tempore 11:09:50, die 09/07/2005 AD, hinc in 
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit James Game 
<jgame(_at_)jigsawinnovations(_dot_)co(_dot_)uk>:

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="{(_at_)name}"><xsl:apply-templates/></xsl:attribute>
</xsl:template>

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

<xsl:template match="section[(_at_)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

--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>