http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Overview

Compiler design

Whitespace
xsl:sort
Keys
Comment design

lang()
Unparsed entities

Runtime

Internal DOM
Namespaces

Translet & TrAX

To-do list

Functionality
 

The xml:lang can be used to determine the language for a node or a node-set. The attribute can be used to store language-specific data in an XML document:

    <phrases>
      <greeting xml:lang="en">Hello!</greeting>
      <greeting xml:lang="no">Hei!</greeting>
      <greeting xml:lang="fr">Salut!</greeting>
      <greeting xml:lang="es">Hola!</greeting>
      <greeting xml:lang="de">Sweinhund!</greeting>
    </phrases>
  

The XSL stylesheet can use the lang() function to select the element with the desired language:

    <xsl:template match="greeting">
      <xsl:if test="lang("de")>
        <xsl:value-of select="."/>
        <xsl:text> Grossglucklicher wunche!</xsl:text>
      </xsl:if>
    </xsl:template>
  

Implementation
 

The DOM interface has been given a method that returns the language for a given node. The language is returned as a string (on whatever format is used in the XML document - should be iso), and may be null if no language is defined.

    public String DOM.getLanguage(int node);
  

The BasisLibrary class has a static method that will compare the language of the context node with some other language and return the result as a boolean.

    public static boolean BasisLibrary.testLanguage(String language, DOM dom, int node);
  

The compiled code for the lang() method calls this method in the BasisLibrary and leaves the result on the stack for the calling element.



Copyright © 2001 The Apache Software Foundation. All Rights Reserved.