-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
6
-
x86
-
linux
FULL PRODUCT VERSION :
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
Java HotSpot(TM) Client VM (build 1.6.0_02-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux ronny 2.6.21-2-686 #1 SMP Wed Jul 11 03:53:02 UTC 2007 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Take a look at the API doc of org.w3c.dom.Document.setXmlVersion() :
http://java.sun.com/javase/6/docs/api/org/w3c/dom/Document.html#setXmlVersion(java.lang.String)
There it reads:
----------
DOM applications may use the DOMImplementation.hasFeature(feature, version) method with parameter values "XMLVersion" and "1.0" (respectively) to determine if an implementation supports [XML 1.0]. DOM applications may use the same method with parameter values "XMLVersion" and "1.1" (respectively) to determine if an implementation supports [XML 1.1].
----------
The problem is that whatever version I try as parameter DOMImplementation.hasFeature() always returns false. This is reproduceable with all Java versions. According to the release notes, Sun Java supports XML 1.1 since Java 1.5 (see here http://java.sun.com/j2se/1.5.0/docs/guide/xml/jaxp/JAXP-Compatibility_150.html#new).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and execute the provided source code. Try with all available Java versions. Notice that DOMImplementation.hasFeature() always returns false.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected DOMImplementation.hasFeature("XMLVersion", "1.0") to return true on Java 1.4 and later.
I expected DOMImplementation.hasFeature("XMLVersion", "1.1") to return true on Java 1.5 and later.
ACTUAL -
I saw DOMImplementation.hasFeature() always returning false when using the feature "XMLVersion".
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.DOMException;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
public class XmlVersionTest {
public XmlVersionTest() {
try {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.newDocument();
DOMImplementation domImplementation = documentBuilder.getDOMImplementation();
System.out.println("DOMImplementation: " + domImplementation.getClass().getName());
if (domImplementation.hasFeature("XMLVersion", "1.0")) {
System.out.println("XMLVersion 1.0 is supported.");
} else {
System.out.println("XMLVersion 1.0 is NOT supported!");
}
if (domImplementation.hasFeature("XMLVersion", "1.1")) {
System.out.println("XMLVersion 1.1 is supported.");
document.setXmlVersion("1.1");
} else {
System.out.println("XMLVersion 1.1 is NOT supported!");
}
} catch (DOMException ex) {
ex.printStackTrace();
} catch (ParserConfigurationException ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) {
new XmlVersionTest();
}
}
---------- END SOURCE ----------
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
Java HotSpot(TM) Client VM (build 1.6.0_02-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux ronny 2.6.21-2-686 #1 SMP Wed Jul 11 03:53:02 UTC 2007 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Take a look at the API doc of org.w3c.dom.Document.setXmlVersion() :
http://java.sun.com/javase/6/docs/api/org/w3c/dom/Document.html#setXmlVersion(java.lang.String)
There it reads:
----------
DOM applications may use the DOMImplementation.hasFeature(feature, version) method with parameter values "XMLVersion" and "1.0" (respectively) to determine if an implementation supports [XML 1.0]. DOM applications may use the same method with parameter values "XMLVersion" and "1.1" (respectively) to determine if an implementation supports [XML 1.1].
----------
The problem is that whatever version I try as parameter DOMImplementation.hasFeature() always returns false. This is reproduceable with all Java versions. According to the release notes, Sun Java supports XML 1.1 since Java 1.5 (see here http://java.sun.com/j2se/1.5.0/docs/guide/xml/jaxp/JAXP-Compatibility_150.html#new).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and execute the provided source code. Try with all available Java versions. Notice that DOMImplementation.hasFeature() always returns false.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected DOMImplementation.hasFeature("XMLVersion", "1.0") to return true on Java 1.4 and later.
I expected DOMImplementation.hasFeature("XMLVersion", "1.1") to return true on Java 1.5 and later.
ACTUAL -
I saw DOMImplementation.hasFeature() always returning false when using the feature "XMLVersion".
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.DOMException;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
public class XmlVersionTest {
public XmlVersionTest() {
try {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.newDocument();
DOMImplementation domImplementation = documentBuilder.getDOMImplementation();
System.out.println("DOMImplementation: " + domImplementation.getClass().getName());
if (domImplementation.hasFeature("XMLVersion", "1.0")) {
System.out.println("XMLVersion 1.0 is supported.");
} else {
System.out.println("XMLVersion 1.0 is NOT supported!");
}
if (domImplementation.hasFeature("XMLVersion", "1.1")) {
System.out.println("XMLVersion 1.1 is supported.");
document.setXmlVersion("1.1");
} else {
System.out.println("XMLVersion 1.1 is NOT supported!");
}
} catch (DOMException ex) {
ex.printStackTrace();
} catch (ParserConfigurationException ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) {
new XmlVersionTest();
}
}
---------- END SOURCE ----------