This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Error message when match=$variable
- To: xsl-list at lists dot mulberrytech dot com
- Subject: RE: [xsl] Error message when match=$variable
- From: timw at 3d3 dot com
- Date: Tue, 4 Sep 2001 14:52:13 +1000
- Reply-To: xsl-list at lists dot mulberrytech dot com
Thank you Jarno,
I've amended my xsl and that part is now working. (the new code is given
below)
Now I've just got to do a test for $german nodes with the same node name()
as in the $english node, so that my translator can do the translations which
are required without re-doing already translated nodes.
I tried adding this code
<xsl:choose>
<xsl:when test="$german/string($currentname) != ''">
<!--xsl:value-of select="$german/string($currentname") /-->
(Already translated)
</xsl:when>
<xsl:otherwise>Please translate</xsl:otherwise>
</xsl:choose>
to the template
<xsl:template match="*">
<xsl:variable name="currentname" select="name()" />
<<xsl:value-of select="$currentname" />><xsl:value-of select="."
/></<xsl:value-of select="$currentname" />>
</xsl:template>
but I am now getting a error.
Error [code:201] [URI:file:/home/data/complang.xsl] [line:23]
[node:attribute 'test']
wrong expression syntax
I had guessed that an X-path cannot accept the syntax with two node-set
variables, so I converted $currentname to a string(as that is how I want it
used).
Can anyone shed any light on how to get around this problem?
Cheers, Tim
XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="english"
select="document('languages/english.xml')/language"></xsl:variable>
<xsl:variable name="german"
select="document('languages/german.xml')/language"></xsl:variable>
<xsl:template match="/">
<html>
<head>
</head>
<body>
<textarea rows="20" cols="100">
<xsl:apply-templates select="$english/*" />
</textarea>
</body>
</html>
</xsl:template>
<xsl:template match="*">
<xsl:variable name="currentname"><xsl:value-of select="name()"
/></xsl:variable>
<<xsl:value-of select="$currentname" />><xsl:value-of select="."
/></<xsl:value-of select="$currentname" />>
<xsl:choose>
<xsl:when test="$german/string($currentname) != ''">
<!--xsl:value-of select="$german/string($currentname)" /-->
(Already translated)
</xsl:when>
<xsl:otherwise>Please translate</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
> -----Original Message-----
> From: Jarno Elovirta
>
> A variableReference cannot be used in a Pattern
>
> > <xsl:variable name="english"
> > select="document(languages/english.xml)/language"></xsl:variable>
>
> You're not looking for the document URL from the english.xml child of
> language child, but rather from a relative URL
> languages/english.xml, so the
> expression inside document() should be in quotes
>
>
> > <xsl:apply-templates select="$english/node()" />
>
> You don't want to process the whitespace, so use $english/*
>
> > <xsl:template match="$english/node()">
>
> Just node() or * will do
>
> > <xsl:value-of select="name()" /> = <xsl:value-of select="." />
>
> The as such will be removed by the XSLT engine during whitespace
> stripping, so wrap it into xsl:text
>
> Jarno
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list