[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] How to fetch desired data


Subject: Re: [xsl] How to fetch desired data
From: James Fuller <jim.fuller@xxxxxxxxxxxxxx>
Date: Fri, 30 Dec 2005 09:48:27 +0100

rob Jackson wrote:

>Hi All,
>
>
>I am converting a source xml into target xml using XSLT.
>
>My source xml has a field like
><xsl:address>Charles Army Street; Boston, Ma 01779</xsl:address>
>  
>

there is no such thing as an xsl:address instruction in any version of 
XSLT, would suggest u use a different element name (or more precisely a
different namespace).

>I have to display it by breaking it into different fields assuming
>there will be comma
>between city and state and space between state and zip.
>
>Target xml should be like this:
><xsl:city>Charles Army Street; Boston</xsl:city>
><xsl:state>Ma</xsl:state>
><xsl:zip>01779</xsl:zip>
>  
>

once again, u seem to want to put everything in the xsl namespace (using
xsl: prefix).....no need for this.

As for how you would crack/split apart the <address/> element, I would
suggest to use a combination of

string-before() or string-after()

(info here
http://www.zvon.org/xxl/XSLTreference/Output/function_substring-after.html)

or

regex approach with EXSLT at http://www.exslt.org/regexp/index.html

or

if u are using XSLT v2.0 then use its native regex processing capability.

gl, Jim Fuller


Current Thread
Keywords