Name: erR10175 Date: 01/20/2004
If an element is declared using anonymous simple type the method TypeInfo.getTypeNamespace()
returns 'http://apache.org/xml/xmlschema/1.0/anonymousTypes', but expected the
targetNamespace of the the schema.
The documentation of the interface org.w3c.dom.TypeInfo reads:
"If the document's schema is an XML Schema [XML Schema Part 1] , the values are computed
as follows using the post-schema-validation infoset contributions (also called
PSVI contributions):
...
If the [validity] property exists and is "valid":
1. ...
2. ...
3. ...
4. If the [type definition anonymous] exists:
1. If it is false, then ...
2. Otherwise, expose the namespace and local name of the corresponding anonymous
type name. "
This implies that the namespace in the TypeInfo for an element should be the value of the
the targetNamespace attribute of the schema.
This bug affects new test in JCK 1.5
api/org_w3c/dom/TypeInfo/index.html#TypeInfo[GetTypeName008]
The bug is found in jdk1.5.0/beta/b32a and is not reproducible with jdk1.5.0/beta/b30.
To reproduce the bug place test.java, test.xsd and test.xml to your current
directory, then compile and run test.java as shown in the logs below:
------------------------------------------ test.java
import org.w3c.dom.Document;
import org.w3c.dom.TypeInfo;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory;
class test {
static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
public static void main(String[] args) throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setValidating(true);
dbf.setAttribute(SCHEMA_LANGUAGE, XMLConstants.W3C_XML_SCHEMA_NS_URI);
dbf.setAttribute(SCHEMA_SOURCE, "test.xsd");
Document document = dbf.newDocumentBuilder().parse("test.xml");
TypeInfo type = document.getDocumentElement().getSchemaTypeInfo();
String typeNS = type.getTypeNamespace();
if (!"testNS".equals(typeNS)) {
System.out.println("returned namespace is " + typeNS
+ ", but expected testNS");
} else {
System.out.println("OK");
}
}
}
----------------------------------------------------
------------------------------------------- test.xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:testNS="testNS"
targetNamespace="testNS" elementFormDefault="qualified">
<xsd:element name="test5">
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:element>
</xsd:schema>
----------------------------------------------------
------------------------------------------- test.xml
<?xml version='1.0'?>
<test5 xmlns="testNS"/>
----------------------------------------------------
------------------------------------------------ log with jdk1.5.0/beta/b32a
$javac test.java && java -cp . -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32a)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32a, mixed mode)
returned namespace is http://apache.org/xml/xmlschema/1.0/anonymousTypes, but expected testNS
----------------------------------------------------
------------------------------------------------ log with jdk1.5.0/beta/b30
$javac test.java && java -cp . -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b30)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b30, mixed mode)
OK
----------------------------------------------------
======================================================================
If an element is declared using anonymous simple type the method TypeInfo.getTypeNamespace()
returns 'http://apache.org/xml/xmlschema/1.0/anonymousTypes', but expected the
targetNamespace of the the schema.
The documentation of the interface org.w3c.dom.TypeInfo reads:
"If the document's schema is an XML Schema [XML Schema Part 1] , the values are computed
as follows using the post-schema-validation infoset contributions (also called
PSVI contributions):
...
If the [validity] property exists and is "valid":
1. ...
2. ...
3. ...
4. If the [type definition anonymous] exists:
1. If it is false, then ...
2. Otherwise, expose the namespace and local name of the corresponding anonymous
type name. "
This implies that the namespace in the TypeInfo for an element should be the value of the
the targetNamespace attribute of the schema.
This bug affects new test in JCK 1.5
api/org_w3c/dom/TypeInfo/index.html#TypeInfo[GetTypeName008]
The bug is found in jdk1.5.0/beta/b32a and is not reproducible with jdk1.5.0/beta/b30.
To reproduce the bug place test.java, test.xsd and test.xml to your current
directory, then compile and run test.java as shown in the logs below:
------------------------------------------ test.java
import org.w3c.dom.Document;
import org.w3c.dom.TypeInfo;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory;
class test {
static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
public static void main(String[] args) throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setValidating(true);
dbf.setAttribute(SCHEMA_LANGUAGE, XMLConstants.W3C_XML_SCHEMA_NS_URI);
dbf.setAttribute(SCHEMA_SOURCE, "test.xsd");
Document document = dbf.newDocumentBuilder().parse("test.xml");
TypeInfo type = document.getDocumentElement().getSchemaTypeInfo();
String typeNS = type.getTypeNamespace();
if (!"testNS".equals(typeNS)) {
System.out.println("returned namespace is " + typeNS
+ ", but expected testNS");
} else {
System.out.println("OK");
}
}
}
----------------------------------------------------
------------------------------------------- test.xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:testNS="testNS"
targetNamespace="testNS" elementFormDefault="qualified">
<xsd:element name="test5">
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:element>
</xsd:schema>
----------------------------------------------------
------------------------------------------- test.xml
<?xml version='1.0'?>
<test5 xmlns="testNS"/>
----------------------------------------------------
------------------------------------------------ log with jdk1.5.0/beta/b32a
$javac test.java && java -cp . -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32a)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32a, mixed mode)
returned namespace is http://apache.org/xml/xmlschema/1.0/anonymousTypes, but expected testNS
----------------------------------------------------
------------------------------------------------ log with jdk1.5.0/beta/b30
$javac test.java && java -cp . -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b30)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b30, mixed mode)
OK
----------------------------------------------------
======================================================================