Altova MapForce 2023 Basic Edition

Returns true if the context node has an xml:lang attribute with a value that either matches exactly the testlang argument, or is a subset of it. Otherwise, the function returns false.




XQuery, XSLT 2.0, XSLT 3.0.








The language code to check, for example, "en".



The following XML contains para elements with different values for the xml:lang attribute.


  <para xml:lang="en">Good day!</para>
  <para xml:lang="fr">Bonjour!</para>  
  <para xml:lang="de-AT">Grüss Gott!</para>
  <para xml:lang="de-DE">Guten Tag!</para>
  <para xml:lang="de-CH">Grüezi!</para>


The mapping illustrated below filters only the German paragraphs, regardless of the country variant, with the help of the lang function.


XSLT 2.0 mapping

In the mapping above, for each para in the source, an item is created in the target, conditionally. The condition is provided by a filter which passes on to the target only those nodes where the lang function returns true. That is, only those nodes that have the xml:lang attribute set to "de" (or a subset of "de") will satisfy the filter's condition. Consequently, the mapping output is as follows:


  <item>Grüss Gott!</item>
  <item>Guten Tag!</item>


Note that the lang function operates in the context of each para, because of the parent connection between para and item, see also The Mapping Context.

© 2016-2022 Altova GmbH