Subject: RE: Line Breaks
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 26 Sep 2005 14:38:13 +0100
|
In 2.0, use
<xsl:for-each select="tokenize(BulletPoints, '\*')">
<bullet><xsl:value-of select="normalize-space()"/></bullet>
</xsl:for-each>
In 1.0, write a recursive template that grabs the stuff before the first
"*", outputs a bullet (if non-empty), and calls itself to process the rest
of the string. Use substring-before() and substring-after().
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: James Game [mailto:jgame@xxxxxxxxxxxxxxxxxxxxxxx]
> Sent: 26 September 2005 13:42
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Line Breaks
>
> Hi
>
> I would like to separate the data listed in the BulletPoints
> section of my
> XML (see below). Fortunately there is an * symbol seperating
> each line of
> data that I need. This data is then used to fill a
> predertimed set of Rows
> for each tag so I will need to create tags for each new line created.
>
> If anyone could point me in the right direction it would be much
> appreciated.
> James
>
> XML
>
> <?xml version="1.0" encoding="utf-8" standalone="yes"?>
> <!--RT Generated XML file-->
> <property>
> <Price>125950.00</Price>
> <Unit />
> <Building />
> <StreetNumber>55</StreetNumber>
> <StreetName>Priors Drive</StreetName>
> <Village>Old Catton</Village>
> <Town>NORWICH</Town>
> <County>Norfolk</County>
> <PostCode>NR6 7LJ</PostCode>
> <BulletPoints><![CDATA[Entrance Lobby * Kitchen * Lounge * 2
> Bedrooms *
> Bathroom * Gas Fired Radiator Central Heating * Sealed Unit
> Double Glazing
> * Gardens * Car Parking * Cul-de-Sac position * (Ref: 46479/MH)
> ]]></BulletPoints>
> <Status>Under offer</Status>
> </property>
>
>
>
> XSL
>
> <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="Price" fieldtype="string"
> WIDTH="255" />
> <FIELD attrname="Unit" fieldtype="string"
> WIDTH="255" />
> <FIELD attrname="Building" fieldtype="string"
> WIDTH="255" />
>
> <FIELD attrname="StreetNumber" fieldtype="string"
> WIDTH="255" />
> <FIELD attrname="StreetName"
> fieldtype="string" WIDTH="255"
> />
> <FIELD attrname="Village" fieldtype="string"
> WIDTH="255" />
> <FIELD attrname="Town" fieldtype="string"
> WIDTH="255" />
> <FIELD attrname="County" fieldtype="string"
> WIDTH="255" />
> <FIELD attrname="PostCode" fieldtype="string"
> WIDTH="255" />
>
> <FIELD attrname="BulletPoints" fieldtype="string"
> WIDTH="255" />
> <FIELD attrname="Status" fieldtype="string"
> WIDTH="255" />
>
> </FIELDS>
> </METADATA>
> </xsl:template>
>
> <xsl:template match="property">
> <xsl:variable name="Price" select="Price" />
> <xsl:variable name="Unit" select="Unit" />
> <xsl:variable name="Building" select="Building" />
> <xsl:variable name="StreetNumber" select="StreetNumber" />
> <xsl:variable name="StreetName" select="StreetName" />
> <xsl:variable name="Village" select="Village" />
> <xsl:variable name="Town" select="Town" />
> <xsl:variable name="County" select="County" />
> <xsl:variable name="PostCode" select="PostCode" />
> <xsl:variable name="BulletPoints" select="BulletPoints" />
> <xsl:variable name="Status" select="Status" />
>
>
> <ROW Price="{$Price}" Unit="{$Unit}" Building="{$Building}"
> StreetNumber="{$StreetNumber}" StreetName="{$StreetName}"
> Village="{$Village}"
> Town="{$Town}" County="{$County}" PostCode="{$PostCode}"
> BulletPoints="{$BulletPoints}" Status="{$Status}" />
>
>
> </xsl:template>
> </xsl:stylesheet>
|