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

RE: How to use an XML-based LUT with XSLT?

Subject: RE: How to use an XML-based LUT with XSLT?
From: Taras Tielkes <taras@xxxxxxx>
Date: Thu, 27 Sep 2001 17:26:50 +0200
xslt document key error message
Oops,

The example at the end of my message should use the correct key name:

<xsl:value-of select="key('translate-error', ActualErrorCode)"/>

// tt

> -----Original Message-----
> From: Taras Tielkes [mailto:taras@xxxxxxx]
> Sent: Thursday, September 27, 2001 5:19 PM
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject: RE:  How to use an XML-based LUT with XSLT?
> 
> 
> Hi Xavier,
> 
> As far as I understand, your XML source, and the XML 
> containing the mapping
> table are separate files.
> XSLT has a function to access external XML documents, it's called
> "document()".
> You could adapt your value-of element to something like:
> 
> <xsl:value-of
> select="document('errors.xml')/Table/Message[@Code=ActualErrorCode]"/>
> 
> Even better would be to cache the errors in hashmap using 
> keys.(Note that
> the XSL processor is not required to use a hashmap, although 
> it's likely)
> 
> <xsl:key	name="translate-error"
> 		match="document('errors.xml')/Table/Message"
> 		use="@code"/>
> 
> Now you can use something like:
> 
> <xsl:value-of select="key('errors', ActualErrorCode)"/>
> 
> Regards,
> 
> // tt
> 
> > -----Original Message-----
> > From: Xavier Defrang [mailto:xavier@xxxxxxxxxxxx]
> > Sent: Thursday, September 27, 2001 4:50 PM
> > To: Mulburrytech's XSL Mailing List
> > Subject:  How to use an XML-based LUT with XSLT?
> > 
> > 
> > 
> > Hello folks,
> > 
> > I've written a XSL document to transform XML into XHTML (yes, 
> > that's a big
> > surprize!).  The document contains some error codes and I'd like to
> > transform these numerical codes into an actual human-readable 
> > message so I
> > built a small XML document as follow :
> > 
> > <?xml version="1.0" standalone="yes"?>
> > <Table>
> > 	<Message Code="...">User-friendly error message</Message>
> > 	...
> > </Table>
> > 
> > Now I'd like to change my XSLT so I could look-up into the Table to
> > substitute numerical error codes by text messages with 
> > something like :
> > 
> > <xsl:value-of select="/Table/Message[@Code=ActualErrorCode]"/> 
> > 
> > Now the question is how do I "link" this table to my input 
> > DOM so I can
> > reach the Message elements from within my XSLT?  Is there any 
> > possibility
> > to that with plain XSLT? (I don't want to use any engine-dependant
> > extensions)
> > 
> > Maybe should I make a <xsl:choose>-based template matching 
> > the elements
> > containing these codes?
> > 
> > Thanks in advance,
> > 
> > Xavier Defrang
> > Perceval R&D Team
> > xavier@xxxxxxxxxxxx
> > 
> > -------------------------------------------------
> >  Perceval Technologies SA/NV  Tel: +32-2-6409194
> >  Rue Tenbosch, 9              Fax: +32-2-6403154
> >  B-1000 Brussels         http://www.perceval.net
> >  BELGIUM                       info@xxxxxxxxxxxx
> > -------------------------------------------------
> > 
> > 
> >  XSL-List info and archive:  
> http://www.mulberrytech.com/xsl/xsl-list
> > 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

 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.