Subject: Re: Q - Parsing & Manipulating Strings from XSL
From: Ahsan Ali <doubleletter@xxxxxxxxx>
Date: Mon, 30 May 2005 08:29:37 +0400
|
Thanks for the reply.. However, the earlier solution looks simple
enough for my needs...
I have another question: Another number is returned as type string.
This represents time in minutes. For e.g for '315', I want to do is
format it as 5 hrs 15 mins.
The formula is:
mins = ( (315 mod 60) div 100 ) * 60
hrs = 315 - (315 mod 60)
How can I do this in Xquery ? This data is returned in a <JrnyTm></JrnyTm>
tag.
Should I try to format the number twice and apply the formula ?
Regards, Ahsan
On 5/30/05, Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote:
> > Furthermore, in the same repsonse, I have a string of the format
> > YYYYNYY [chars may be either Y or N], also respresented as a free
> > format string. This represents the days of the week starting from
> > Sunday... Now I need to take each char, and replace it with a <TD
> > color="green">S</TD> if it is Y, and <TD>S</TD> if it is N.
> >
> > Anyway I can do that in XSL ?
>
> One can use the str-map template/function of FXSL.
>
> In XSLT 2.0 one would write something like this:
>
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:f="http://fxsl.sf.net/"
> xmlns:testmap="f:testmap"
> exclude-result-prefixes="f xs testmap"
> >
> <xsl:import href="../f/func-str-map.xsl"/>
>
> <xsl:output omit-xml-declaration="yes" indent="yes"/>
> <!-- to be applied on any xml source -->
>
> <xsl:variable name="vFunMap" as="element()">
> <testmap:testmap/>
> </xsl:variable>
>
> <xsl:template match="/">
> <xsl:sequence select="f:str-map($vFunMap, 'YYYYNYY')"/>
> </xsl:template>
>
> <xsl:template name="wrapChars" match="testmap:*"
> mode="f:FXSL">
> <xsl:param name="arg1"/>
>
> <TD>
> <xsl:if test="$arg1 = 'Y'">
> <xsl:attribute name="color">green</xsl:attribute>
> </xsl:if>
> <xsl:text>S</xsl:text>
> </TD>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
> This approach has the advantage that f:str-map($vFunMap, 'YYYYNYY')
> can be part of an XPath expression.
>
>
> Cheers,
> Dimitre Novatchev.
>
>
>
>
>
>
>
> On 5/29/05, Ahsan Ali <doubleletter@xxxxxxxxx> wrote:
> > Hi,
> >
> > I'm working on a (airline related) project in which I have following
dilemma:
> >
> > A soap response contains a complex hierarchy of data, in which, if
> > the departure time is 00:45 hours then it is represented as 45 ! To
> > make matters worse, the schema defines it as a string. I have no
> > influence over the schema since I'm querying a webservice. So I need
> > to pad that 45 with 0s and of course add that colon. Is there a way I
> > can do that in XSL ?
> >
> > Furthermore, in the same repsonse, I have a string of the format
> > YYYYNYY [chars may be either Y or N], also respresented as a free
> > format string. This represents the days of the week starting from
> > Sunday... Now I need to take each char, and replace it with a <TD
> > color="green">S</TD> if it is Y, and <TD>S</TD> if it is N.
> >
> > Anyway I can do that in XSL ?
> >
> > My current solution is to access the above fields from the asp page,
> > and manipulate it in VBScript ! This is ugly and expensive as I need
> > to make a query for every _type_ of task...
> >
> > Any help is appreciated....
> >
> > Best Regards,
> >
> > Ahsan
| Current Thread |
Dimitre Novatchev - 29 May 2005 20:01:15 -0000
- Ahsan Ali - 30 May 2005 04:29:59 -0000 <=
|
|