[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Q - Parsing & Manipulating Strings from XSL

Subject: Re: Q - Parsing & Manipulating Strings from XSL
From: Ahsan Ali <doubleletter@xxxxxxxxx>
Date: Tue, 31 May 2005 11:42:09 +0400
xsl integer parsing
Thank you for you time, Michael. Much appreciated !

Regards, Ahsan

On 5/31/05, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> Sorry, but you asked for an XQuery solution and I gave you one, then you
> asked for an XSLT translation and I gave you one. If you want to do it the
> hard way in XSLT 1.0 you're going to have to do it yourself.
>
> Michael Kay
> http://www.saxonica.com/
>
>
> > -----Original Message-----
> > From: Ahsan Ali [mailto:doubleletter@xxxxxxxxx]
> > Sent: 31 May 2005 08:12
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: Re:  Q - Parsing & Manipulating Strings from XSL
> >
> > What do you suggest for this then ?? Is there a way around in 1.0 ? I
> > don't mind if its complicated.. I must do it somehow...
> >
> > Thanks,
> >
> > Ahsan
> >
> > On 5/31/05, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> > > These functions are present in XQuery 1.0 and in XSLT 2.0,
> > but not in XSLT
> > > 1.0.
> > >
> > > Michael Kay
> > > http://www.saxonica.com/
> > >
> > >
> > > > -----Original Message-----
> > > > From: Ahsan Ali [mailto:doubleletter@xxxxxxxxx]
> > > > Sent: 31 May 2005 07:29
> > > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > > > Subject: Re:  Q - Parsing & Manipulating Strings from XSL
> > > >
> > > > Allright. I converted the xquery code to the below xsl code:
> > > >
> > > >       <xsl:template match="JrnyTm">
> > > >               <xsl:variable name="onemin" select="
> > > > xdt:dayTimeDuration('PT1M')"/>
> > > >               <xsl:variable name="time" select="xs:integer(.)
> > > > * $onemin"/>
> > > >               <xsl:variable name="hours"
> > > > select="xs:hours-from-duration($time)"/>
> > > >               <xsl:variable name="mins"
> > > > select="xs:minutes-from-duration($time)"/>
> > > >               <xsl:value-of select="concat($hours, ' hrs',
> > > > $mins, ' mins')"/>
> > > >       </xsl:template>
> > > >
> > > > Now the problem is that the xdt namespace is not recognised !
> > > >
> > > > The namespace definition is:
> > > > xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > > xmlns:xdt="http://www.w3.org/2005/04/xpath-datatype"
> > > >
> > > > I get an error:"Namespace
> > 'http://www.w3.org/2005/04/xpath-datatype'
> > > > does not contain any functions."
> > > >
> > > > I'm using the MSXML XSL processor...
> > > >
> > > >
> > > > Regards, Ahsan
> > > >
> > > > On 5/30/05, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> > > > >
> > > > > > Is there way to do this in pure XSLT instead of Xquery ??
> > > > >
> > > > > Of course. Just replace
> > > > >
> > > > >    let $x := EXPR
> > > > >
> > > > > and
> > > > >
> > > > >    declare variable $x := EXPR
> > > > >
> > > > > by
> > > > >
> > > > >    <xsl:variable name="x" select="EXPR"/>
> > > > >
> > > > > and replace
> > > > >
> > > > >    "return X" by
> > > > >
> > > > >    <xsl:value-of select="X"/>
> > > > >
> > > > > Michael Kay
> > > > > http://www.saxonica.com/
> > > > >
> > > > > >
> > > > > > > You've got a choice between using numeric arithmetic or
> > > > > > duration arithmetic.
> > > > > > > It's probably cleanest to use duration arithmetic though
> > > > > > it's a bit verbose.
> > > > > > >
> > > > > > > declare variable $one-minute := xdt:dayTimeDuration('PT1M')
> > > > > > >
> > > > > > > then
> > > > > > >
> > > > > > > let $time := xs:integer(JrnyTm) * $one-minute,
> > > > > > >     $hours := hours-from-duration($time),
> > > > > > >     $minutes := minutes-from-duration($time)
> > > > > > > return
> > > > > > >     concat($hours, ' hrs ', $minutes, ' minutes ')
> > > > > > >
> > > > > >
> > > > > > Regards, Ahsan

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.