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

Re: Hash / Translation Tables (the right way)

Subject: Re: Hash / Translation Tables (the right way)
From: Hank Ratzesberger <hankr@xxxxxxxx>
Date: Sun, 25 Sep 2011 16:12:20 -0700
Re:  Hash / Translation Tables (the right way)
Thank you everyone.

I will try to remember in the future to say whether I need
to be compatible with 1.0.  Apparently that is an issue
often enough, although even using ant (where I am using this
presently) it's not difficult to specify a 2.0 compatible parser.

--Hank


On 09/25/2011 03:43 PM, G. Ken Holman wrote:
Except that my use of lower-case() earlier wouldn't work in XSLT 1. A
common way to get lower-case in XSLT 1 is with the translate() function.

Please forgive my haste in my earlier answer.

. . . . . . . . . . Ken

At 2011-09-25 18:40 -0400, I wrote:
At 2011-09-25 23:35 +0100, Michael Kay wrote:

Another approach is to have a document months.xml

<months>
<month name='January' abbr='jan' num='01'/>
<month name='February' abbr='feb' num='02'/>
...
</months>

then

document('months.xml')/months/month[@abbr=lower-case($mon)]/@num

(or instead of a separate document you can put the lookup table in a
global variable in the stylesheet; but with XSLT 1.0 this relies on
the node-set() function.)

It can also be done in XSLT 1.0 without extensions by putting the structure in a namespace at the top level of the stylesheet:

<hank:months>
<month name='January' abbr='jan' num='01'/>
<month name='February' abbr='feb' num='02'/>
...
</hank:months>

... and using the document() function:

document('')/*/hank:months/month[@abbr=lower-case($mon)]/@num

I hope this helps.

. . . . . . . . . . . Ken


--
Contact us for world-wide XML consulting and instructor-led training
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers: http://www.CraneSoftwrights.com/legal



--
Louis (Hank) Ratzesberger
sopac.ucsd.edu

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.