xsl-list
[Top] [All Lists]

RE: Re: [xsl] Need help with function to split string and return concatenated string

2010-05-07 08:41:15
Thank you, Syd and David.
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk>
Sent:     Fri, 07 May 2010 02:48:24 +0100
To:       xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Cc:       cknell(_at_)onebox(_dot_)com
Subject:  Re: [xsl] Need help with function to split string and return 
concatenated string

On 06/05/2010 23:41, cknell(_at_)onebox(_dot_)com wrote:
I'm still knocking the rust off my brain and I've go to the point where I 
wish to split the value of an attribute and concatenate the pieces to return 
a second string.

I have attributes in my input document which represent latitude and 
longitude. They are presented this way:

34.56.12 N

Where the digits to the left of the first period represent degrees, the 
digits between the two periods represent minutes, and the digits between the 
second period and the space represent seconds.

The output I'm looking for given the input above is

34deg 56min 12sec N

While I used to be a wiz with regular expression when I regularly programmed 
in perl, I have lost it. I would appreciate some guidance.

My idea is to create a function that would perform this string manipulation 
so that I could use something like this in my stylesheet:

<Data><xsl:value-of select="coord(@latitude)"/></Data>
<Data><xsl:value-of select="coord(@longitude)"/></Data>

My input would look like:

<location latitude="34.56.12 N" longitude="125.6.15 E"/>

Thanks.


something like

<xsl:function name="x:f">
   <xsl:param name="x"/>
    <xsl:value-of
select="replace($x,
                  '([0-9]*)\.([0-9]*)\.([0-9]*) ([A-Z])',
                 '$1deg $2min $3sec $4')"/>
</xsl:function>

David



--~------------------------------------------------------------------
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>
  • RE: Re: [xsl] Need help with function to split string and return concatenated string, cknell <=