-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
beta
-
generic
-
generic
-
Verified
Name: eaR10174 Date: 09/05/2003
The method TypeInfo.getTypeName() does not return null in case when there is no
declaration for the attribute (see test.java below). According to the TypeInfo
javadoc
If the document's schema is an XML DTD [XML 1.0], the values are computed as follows:
* If this type is referenced from an Attr node, typeNamespace is null and typeName
represents the [attribute type] property in the [XML Information set] . If there is no
declaration for the attribute, typeName is null.
the method should return null.
The bug appears in jdk1.5.0beta-b18 and affects a new JCK1.5 test:
api/org_w3c/dom/TypeInfo/index.html#GetTypeNamespace[GetTypeName002]
------------------------------------test.java-----------------------------
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.InputSource;
import org.w3c.dom.Document;
import org.w3c.dom.TypeInfo;
import org.w3c.dom.Element;
import org.w3c.dom.Attr;
import java.io.StringReader;
public class test {
String data = "<?xml version='1.0'?>\n"
+ "<!DOCTYPE root [\n"
+ " ELEMENT root ANY\n"
+ "]>\n"
+ "<root attr=\"test\"/>\n";
DocumentBuilder docBuilder = null;
public static void main(String argv[]) {
new test().run();
}
public void run() {
try {
DocumentBuilderFactory docBF = DocumentBuilderFactory.newInstance();
docBuilder = docBF.newDocumentBuilder();
Document document = parse(data);
Element root = document.getDocumentElement();
Attr attr = root.getAttributeNode("attr");
TypeInfo type = attr.getSchemaTypeInfo();
String typeName = type.getTypeName();
if (typeName != null) {
System.out.println("Expected: null; returned: " + typeName);
}
} catch (Exception e) {
e.printStackTrace();
return;
}
}
private Document parse(String xmlData) throws Exception {
StringReader in = new StringReader(xmlData);
InputSource source = new InputSource(in);
return docBuilder.parse(source);
}
}
--------------------------------------------------------------------------
% java -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b17)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b17, mixed mode)
Expected: null; returned: CDATA
--------------------------------------------------------------------------
======================================================================
###@###.### 2003-09-05
The method TypeInfo.getTypeName() does not return null in case when there is no
declaration for the attribute (see test.java below). According to the TypeInfo
javadoc
If the document's schema is an XML DTD [XML 1.0], the values are computed as follows:
* If this type is referenced from an Attr node, typeNamespace is null and typeName
represents the [attribute type] property in the [XML Information set] . If there is no
declaration for the attribute, typeName is null.
the method should return null.
The bug appears in jdk1.5.0beta-b18 and affects a new JCK1.5 test:
api/org_w3c/dom/TypeInfo/index.html#GetTypeNamespace[GetTypeName002]
------------------------------------test.java-----------------------------
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.InputSource;
import org.w3c.dom.Document;
import org.w3c.dom.TypeInfo;
import org.w3c.dom.Element;
import org.w3c.dom.Attr;
import java.io.StringReader;
public class test {
String data = "<?xml version='1.0'?>\n"
+ "<!DOCTYPE root [\n"
+ " ELEMENT root ANY\n"
+ "]>\n"
+ "<root attr=\"test\"/>\n";
DocumentBuilder docBuilder = null;
public static void main(String argv[]) {
new test().run();
}
public void run() {
try {
DocumentBuilderFactory docBF = DocumentBuilderFactory.newInstance();
docBuilder = docBF.newDocumentBuilder();
Document document = parse(data);
Element root = document.getDocumentElement();
Attr attr = root.getAttributeNode("attr");
TypeInfo type = attr.getSchemaTypeInfo();
String typeName = type.getTypeName();
if (typeName != null) {
System.out.println("Expected: null; returned: " + typeName);
}
} catch (Exception e) {
e.printStackTrace();
return;
}
}
private Document parse(String xmlData) throws Exception {
StringReader in = new StringReader(xmlData);
InputSource source = new InputSource(in);
return docBuilder.parse(source);
}
}
--------------------------------------------------------------------------
% java -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b17)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b17, mixed mode)
Expected: null; returned: CDATA
--------------------------------------------------------------------------
======================================================================
###@###.### 2003-09-05