xsl-list
[Top] [All Lists]

Re: How to fetch desired data

2005-12-30 05:53:36
Hi Jim,

Thanks for your reply.
'<xsl:' is prefixed just for example purpose. Pls ignore it.

By using substring-before comma I am able to get
<city>Charles Army Street; Boston</city>

but substring-after comma gives me 'Ma 01779'

I want this also to be split as
<state>Ma</state>
<zip>01779</zip>

How can I use substring-after to first store 'Ma 01779' into some
variable and then I can use substring-before and substring-after space
to get the values in different tags.

Pls suggest.


-Rob
On 12/30/05, James Fuller <jim(_dot_)fuller(_at_)ruminate(_dot_)co(_dot_)uk> 
wrote:
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


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



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