Problem resolving namespace prefix for QName, suspected bug in NamespaceSupport
-------------------------------------------------------------------------------
Key: XERCESJ-1165
URL: http://issues.apache.org/jira/browse/XERCESJ-1165
Project: Xerces2-J
Type: Bug
Components: XML Schema API
Versions: 2.8.0
Environment: Windows XP SP2, JRE 1.5.0_06
Reporter: Jonathan Mezach
I think I found a bug in the NamespaceSupport class which is part of Xerces2-J.
I'm working on a project which involves elements which have a QName as type.
Let me just write some XML to clarify:
<xbrli:xbrl xmlns:iso4217="http://www.xbrl.org/2003/iso4217">
<xbrli:unit id="EUR">
<xbrli:measure>iso4217:EUR</xbrli:measure>
</xbrli:unit>
</xbrli:xbrl>
I'm trying to validate this using JAXP with the Xerces implementation. The
schema for the measure element is as follows:
<xsd:element name="measure" type="QName"/>
Now, when the validation is run an exception is thrown which reads as follows:
UndeclaredPrefix: Cannot resolve 'iso4217:EUR' as a QName: the prefix 'iso4217'
is not declared.
This is quite strange because the namespace prefix is clearly declared at the
top level element. So I decided to have a debug through the code and found that
the problem is in the NamespaceSupport class. At the bottom of the
getActualValue method of the QNameDV class the method getURI is called on the
ValidationContext that was passed to it. This eventually calls the
getURI(String) method on the NamespaceSupport class. The code here reads as
follows:
1. // find prefix in current context
2. for (int i = fNamespaceSize; i > 0; i -= 2) {
3. if (fNamespace[i - 2] == prefix) {
4. return fNamespace[i - 1];
5. }
6. }
7.
8. // prefix not found
9. return null;
The fNamespace instance variable is a String array and the prefix argument is a
String as well. This leads me to conclude that line 3 of the above code should
have been written as follows:
if (fNamespace[i -2].equals(prefix)) {
String comparison in Java is done using the equals method rather than the
equals operator as far as I know.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]