[xsl] Variable Problems

Subject: [xsl] Variable Problems
From: "James Game" <james_game2002@xxxxxxxxxxxxx>
Date: Tue, 06 Sep 2005 15:16:06 +0000
Hi All

This is my xml:

<?xml version="1.0" encoding="iso-8859-1"?>
<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>Gas Central Heating</d>
<d>Large Double Garage</d>

<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>

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"/>
        <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')" />

    <xsl:template match = "detail" >
        <xsl:text >
        <xsl:value-of select = "." />

<xsl:template name="CDSMetaData">

<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"/>


       <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}"/>


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,

MSN Messenger 7.5 is now out. Download it for FREE here. http://messenger.msn.co.uk

Current Thread