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

Re: How to substitute a string based on number

Subject: Re: How to substitute a string based on number
From: Mailer Mailer <maillistboxes@xxxxxxxxx>
Date: Tue, 30 Oct 2001 04:21:08 -0800 (PST)
xsl substitute string
Hey It worked... :-)
Thanks a million to all the guys who gave the answer
for this.

-Deep


--- Joerg Pietschmann <joerg.pietschmann@xxxxxx>
wrote:
> Hi Deep,
> 
> Mailer Mailer <maillistboxes@xxxxxxxxx> wrote:
> > How can I substitute a string based on a number,
> e.g.
> > 
> > 1 --- Jaunary
> > 2 --- February
> [...]
> > In wrox book an implementation is given but it
> seems
> > to be MS specific. The implementation is
> [...] 
> > <xsl:variable name="monthnames"
> > select="msxml:node-set($monthnames.tf)"/>
> 
> It is MSXML specific but only slightly. Other
> processors
> have a similar extension function node-set(), look
> it
> up in the procesor specific dokumentation.
> 
> Depending on the problem you want to solve, you
> probably
> don't need this extension function. Try the
> following style
> sheet:
>   <?xml version="1.0" encoding="ISO-8859-1"?>
>   <xsl:stylesheet version="1.0"
>     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>     xmlns:data="uri:some.uri.you.control"
>     exclude-result-prefixes="data">
> 
>     <data:monthnames.tf>
>      <mnth name="January"/>
>      <mnth name="February"/>
>      <mnth name="March"/>
>      <!-- snip, to keep the example short -->
>     </data:monthnames.tf>
>     
>     <xsl:template match="month">
>       <xsl:value-of
>
select="document('')/*/data:monthnames.tf/*[number()]/@name">
>     </xsl:template>
>     <xsl:template match="node()"/>
>   </xsl:stylesheet>
> 
> This should output the name of the month for each
> month element
> in your source XML which has a month number as its
> content. Well,
> at least if you complete the monthnames array
> properly. The technique
> is based on the fact that elements with a non-XSLT
> namespace are
> allowed in style sheets
> (http://www.w3.org/TR/xslt.html#stylesheet-element,
> last paragraph), and that document('') reads the
> stylesheet itself.
> The "exclude-result-prefixes" ensures that the data
> namespace is
> not copied through into the output.
> 
> HTH
> J.Pietschmann
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 


__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.