xsl-list
[Top] [All Lists]

Variable Problems

2005-09-06 08:16:06
Hi All

This is my xml:

<?xml version="1.0" encoding="iso-8859-1"?>
<desc>
<detail name="id">1000001</detail>
<detail name="price">Offers in the region of &#163;358,000</detail>
<detail name="address1">Blenheim House, Lincoln Lane</detail>
<detail name="address2">Blackwell</detail>
<detail name="typedesc">  4 Bedroom Detached House</detail>
<detail name="image">999\nikonhse.jpg</detail>

<section name="bullets">
<d>4 Bedrooms</d>
<d>Drawing Room</d>
<d>Dining Room</d>
<d>Fitted Breakfast Kitchen</d>
<d>Family Bathroom</d>
<d>Study</d>
<d>Gas Central Heating</d>
<d>Large Double Garage</d>
</section>

<section name="pics">
<g d="">999\lounge1.jpg</g>
<g d="">999\rdraw.jpg</g>
<g d="">999\garden1.jpg</g>
<g d="">999\rdine2.jpg</g>
<g d="">999\rkitch.jpg</g>
<g d="">999\c1cons1.jpg</g>
<g d="">999\rbed.jpg</g>
<g d="">999\rbath.jpg</g>
<g d="">999\rgarden.jpg</g>
</section>
</desc>

This is my XSL

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
    <xsl:output method = "html" />


    <xsl:key name = "test" match = "detail"
        use = "@name" />
   <xsl:key name = "test2" match = "section"
       use = "@name" />

   <xsl:template match = "/" >
       <DATAPACKET Version="2.0">
           <xsl:call-template name="CDSMetaData"/>
           <ROWDATA>
        <xsl:apply-templates select = "key('test','id')" />
        <xsl:apply-templates select= "key('test','price')" />
        <xsl:apply-templates select= "key('test','address1')" />
        <xsl:apply-templates select= "key('test','address2')" />
        <xsl:apply-templates select= "key('test','typedesc')" />
        <xsl:apply-templates select= "key('test','image')" />
        <xsl:apply-templates select= "key('test2','bullets')" />
        <xsl:apply-templates select= "key('test2','pics')" />
           </ROWDATA>
           </DATAPACKET>
    </xsl:template>

    <xsl:template match = "detail" >
        <xsl:text >
        </xsl:text>
        <xsl:value-of select = "." />
        </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>
       <xsl:variable name="id" select="(id)" />
       <xsl:variable name="price" select="price" />
       <xsl:variable name="address1" select="address1" />
       <xsl:variable name="address2" select="address2" />
       <xsl:variable name="typedesc" select="typedesc" />
       <xsl:variable name="image" select="image" />
       <xsl:variable name="bullets" select="@image"/>


       <ROW id="{$id}"
           price= "{$price}"
           address1= "{$address1}"
           address2= "{$address2}"
           typedesc= "{$typedesc}"
           image= "{$image}"
           bullets= "{$bullets}"/>



</xsl:template>
</xsl:stylesheet>



I am trying to extract all data highlighted in Red on my XML and populate to the rows specified. As you can see the xml structure is not the freindliest (especially to a newb) and i am finding this very hard going. So far i have manged to get the data output but not into the rows. I would appreciate any help you guys can offer pointing me in the right direction.

Many Thanks,
James

_________________________________________________________________
MSN Messenger 7.5 is now out. Download it for FREE here. http://messenger.msn.co.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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



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