Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Language-specific output

From: David Carlisle <davidc@--------->
To:
Date: 2/1/2006 2:54:00 PM
<xsl:choose>
                        <xsl:when test="rdf:Description/dc:rights/rdf:Alt/rdf:li/@xml:lang = $lang">
                            <xsl:value-of select="rdf:Description/dc:rights/rdf:Alt/rdf:li[@xml:lang = $lang]"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="rdf:Description/dc:rights/rdf:Alt/rdf:li[@xml:lang 
                                = 'x-default']"/>
                            </xsl:otherwise>
                    </xsl:choose>
 

could be writen

 <xsl:value-of select="rdf:Description/dc:rights/rdf:Alt/(rdf:li[@xml:lang= $lang],rdf:li[@xml:lang= 'x-default'])[1]

or if you know x-default always comes first in the input (if it is
there) you can simplify further to


<xsl:value-of select="rdf:Description/dc:rights/rdf:Alt/rdf:li[@xml:lang=($lang,'x-default')][last()]

I can't really answer your earlier points as it depends what you are
doing. If you have stylesheet that references a variable that isn't
defined, but you only use that stylesheet in combination with another
stylesheet that does declare the variable that shoudl work.

However it might be that your IDE to aid xslt debugging or whatever is
compiling each stylesheet separtately, and this would fail of course.

I wouldn't use lots of variables for this I'd just use one _document_
(or equivaently one variable) something like
<xsl:variable name="stuff>
<a name="TFilename lang="de">Datei:</a>
<a name="TFilename" lang="en">File:</a>
<a name="TTitle">lang="de">XMP Steckbrief der Datei </a>
...




accessed as $stuff/a[@name=$name and @lang=@lang]

(if this list is big, access could be considerably quickened if you also
defiend an xsl:key for these elements.


If you want your sub-stylesheets to be able to be compiled without error
you only need to add

<xsl:variable name="stuff" select="()"/>

to them, this makes the variable declared as an empty list so it will
type check when used in path expressions. It doesn't matter that it's
not the value you want as when you run it this global variable will have
the value from your top most importing stylesheet which is your lookup
table.


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
________________________________________________________________________


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent