Re: [xsl] XSL and localization

Subject: Re: [xsl] XSL and localization
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 6 Oct 2004 15:03:54 +0100
> Is this possible and how ?

Unfortunately it is processor dependent. 

If 

document(concat('locale/',/*/@lang,'/test_locale.xml'))

doesn't exist then strictly speaking it's an error but the xslt spec
allows the system to recover in which case it simply returns an empty
node set in which case you can test for that with
<xsl:if
test="not(document(concat('locale/',/*/@lang,'/test_locale.xml'))">
do something else

however your system may stop with an error instead. Saxon for example
has a top level switch to control recoverable errors

-w0 silently ignore error and do recovery action
 
what you want here

-w1 (the default) make a warning but do the recovery action
   
or maybe you want the warning

-w2 stop with a fatal error and produce no result tree

you don't want that.


If you want to be sure to avoid processor dependency or you need to use
a processor that makes this a fatal error, make an xml file that
reflects the list of available file names (there are tools to do this
automatically, but just simply editing a directory listing also works)
then consult that with document() before trying to use document() to get
the locale file.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread