[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Variable Problems

Subject: Variable Problems
From: "James Game" <james_game2002@xxxxxxxxxxxxx>
Date: Tue, 06 Sep 2005 15:16:06 +0000
variable problems
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.