You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Donald Ball <ba...@webslingerZ.com> on 2002/01/22 22:58:13 UTC

trouble with xml:lang, bug in xalan?

hey guys. i'm having trouble using the lang() xslt function in xalan. i've
got an i18n xml file like so:

<survey:survey xmlns:survey="http://surveyZ.webslingerZ.com/xml/objects/1.0">
  <survey:label xml:lang="en">Test English</survey:label>
  <survey:label xml:lang="it">Testo Italiano</survey:label>
</survey:survey>

and i'm trying to select the english label, very simply:

<xsl:template match="survey:survey">
  <xsl:for-each select="survey:label[lang('en')]">
    <xsl:value-of select="."/>
  </xsl:for-each>
</xsl:template>

but it fails to match anything. i wrote a more complex debugging template:

<xsl:template match="survey:survey">
        <tr>
          <td>
            Default: <xsl:value-of select="$defaultLang"/><br/>
            Target: <xsl:value-of select="$targetLang"/><br/>
            <br/>
            <xsl:for-each select="survey:label">
              Label: <xsl:value-of select="."/>
              (<xsl:value-of select="@xml:lang"/>)<br/>
              <xsl:for-each select="@*">
                Attr name: <xsl:value-of select="name(.)"/><br/>
                Attr local name: <xsl:value-of
select="local-name(.)"/><br/>
                Attr value: <xsl:value-of select="."/><br/>
              </xsl:for-each>
              <xsl:if test="lang($defaultLang)">Default<br/></xsl:if>
              <xsl:if test="lang($targetLang)">Target<br/></xsl:if>
            </xsl:for-each>
          </td>
        </tr>
</xsl:template>

where defaultLang='en' and targetLang='it', and i note:

1. <xsl:value-of select="@xml:lang"/> returns an empty string, even though
the survey:label elements clearly have xml:lang attributes!

2. local-name(@xml:lang) returns 'xml:lang'. shouldn't it return "lang"?

i'm using SAX2 to generate the xml in question; is it possible that i'm
using it incorrectly? or have i uncovered a possible bug in xalan? i'm
using 2.2D13. thanks.

- donald