Issues when validating language strings

Darko Miletic <[email protected]>
Newsgroups gmane.comp.gnome.lib.xslt
Message-ID <[email protected]>
According to the schema standard xs:language type is defined as follows
(see http://www.w3.org/TR/xmlschema11-2/#language):

<xs:simpleType id="language" name="language
<http://www.filigris.com/products/docflex_xml/xsddoc/examples/html/xslt20/schemas/XMLSchema_xsd/simpleTypes/language.html>">

<xs:restriction base="xs:token
<http://www.filigris.com/products/docflex_xml/xsddoc/examples/html/xslt20/schemas/XMLSchema_xsd/simpleTypes/token.html>">
<xs:pattern id="language.pattern"
value="[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*"/>
</xs:restriction>
</xs:simpleType>

According to that definition if we put 'aa-bb-cc' as a value of xml:lang
or any custom attribute of type xs:language it should be accepted as
valid one.

However when using libxslt that is not the case. Definition of language
type in libxslt permits only one section with - (like aa-bb, dd-cc,
en-US etc.). It is as if it uses this regex for validation:

[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})

Here are the sample files that demonstrate the issue:

--- test.xml ---
<?xml version="1.0" encoding="UTF-8" ?>
 - <rootelxmlns="*http://dummy.libxml2.validator*"
xmlns:xsi="*http://www.w3.org/2001/XMLSchema-instance*"
xsi:schemaLocation="*http://dummy.libxml2.validator test.xsd*">
       <samplelanguage="*aa-bb-cc*">custom language</sample>
  <samplelanguage="*en-US*"xml:lang="*aa-bb-cc*">English US</sample>
</rootel>

--- test.xsd --
<?xml version="1.0"?>
<xs:schema id="rootel"
           targetNamespace="http://dummy.libxml2.validator"
           xmlns="http://dummy.libxml2.validator"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           attributeFormDefault="qualified"
           elementFormDefault="qualified">
  <xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2001/xml.xsd" />          
  <xs:element name="rootel">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="sample" nillable="true">
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:string">
                <xs:attribute name="language" form="unqualified"
type="xs:language" />
                <xs:attribute ref="xml:lang" use="optional"/>
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

Save these files in the same directory and execute following command to
demonstrate the issue:

xmllint --noout --schema test.xsd test.xml

Any thoughts? This looks like a bug to me.

-- 
Darko Miletic

_______________________________________________
xslt mailing list, project page http://xmlsoft.org/XSLT/
[email protected]
http://mail.gnome.org/mailman/listinfo/xslt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.