You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Andreas Junghans <an...@isb-ka.de> on 2000/08/24 11:03:49 UTC
[Q] How to declare xml:lang attribute in a schema?
Hi there!
Does anyone know how I can declare the xml:lang attribute in a schema?
I've tried several ways and ended up with one I _think_ should be
accepted by Xerces:
-- test_xmlns.xsd
<?xml version="1.0" encoding="ISO-8859-1"?>
<schema
xmlns="http://www.w3.org/1999/XMLSchema"
xmlns:tst="test"
targetNamespace="test"
elementFormDefault="qualified"
>
<complexType name="test" content="empty">
<anyAttribute namespace="http://www.w3.org/XML/1998/namespace"/>
</complexType>
<element name="test" type="tst:test"/>
</schema>
-- test_xmlns.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<test
xmlns="test"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xsi:schemaLocation="test test_xmlns.xsd"
xml:lang="en"
/>
--
Xerces-J 1.1.3 produces the following exception:
org.xml.sax.SAXParseException: Attribute "ANY---xml:lang" must be
declared for e
lement type "test".
If I change the namespace for anyAttribute to something else I get this
exception (which is perfectly acceptable):
org.xml.sax.SAXParseException: Attribute "xml:lang" must be declared for
element
type "test".
The different exceptions show that Xerces seems to recognize the XML
namespace, but still doesn't accept the lang attribute. I've taken a
look at the schema for schemas to see how they declare xml:lang for
documentation elements. What I've found looks most strange to me (and
doesn't work with Xerces):
<element name="documentation"
xmlns:x="http://www.w3.org/XML/1998/namespace">
<complexType content="mixed">
<any minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
<attribute name="source" type="uriReference"/>
<attributeGroup ref="x:specialAttrs"/>
</complexType>
</element>
Any ideas? Maybe I'm doing something wrong?
TIA
Andreas
PS It doesn't change anything if I put the complex type definition
inside the element definition. It also doesn't work to use ##any for the
namespace of anyAttribute.
--
Andreas Junghans
- Anwendungsentwickler -
ISB GmbH Tel: +49 (0)721/82800-0
Karlstraße 52-54 Fax: +49 (0)721/82800-82
76133 Karlsruhe mailto:andreas.junghans@isb-ka.de
Germany http://www.isb-ka.de