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 "Jonathan Mezach (JIRA)" <xe...@xml.apache.org> on 2006/05/18 16:57:06 UTC
[jira] Created: (XERCESJ-1165) Problem resolving namespace prefix
for QName, suspected bug in NamespaceSupport
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: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
[jira] Commented: (XERCESJ-1165) Problem resolving namespace prefix
for QName, suspected bug in NamespaceSupport
Posted by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org>.
[ http://issues.apache.org/jira/browse/XERCESJ-1165?page=comments#action_12412364 ]
Michael Glavassevich commented on XERCESJ-1165:
-----------------------------------------------
The object reference comparison is by design and not a bug. If you look around the Xerces codebase, you'll see these everywhere instead of String.equals(). It's done for performance reasons and works because the String objects are unique (see org.apache.xerces.util.SymbolTable).
Which API in JAXP did you use for schema validation? Are you sure you were actually using Xerces 2.8.0 and not the validator embedded in Java 1.5.0?
> 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: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
[jira] Resolved: (XERCESJ-1165) Problem resolving namespace prefix
for QName, suspected bug in NamespaceSupport
Posted by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org>.
[ http://issues.apache.org/jira/browse/XERCESJ-1165?page=all ]
Michael Glavassevich resolved XERCESJ-1165:
-------------------------------------------
Resolution: Incomplete
Not Xerces, but something derived from it. Java 5 contains a Sun repackaged (com.sun.org.apache.xerces.internal.*) fork of the Xerces codebase. It has quite a different implementation of JAXP 1.3 than the Apache version, including bugs which have never existed in Xerces. If this problem is in Java 5, there's nothing we can do it about it here. You would need to report the problem to Sun to get that fixed. If you actually run into this problem with Xerces 2.8.0, please re-open this issue.
> 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: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
[jira] Commented: (XERCESJ-1165) Problem resolving namespace prefix
for QName, suspected bug in NamespaceSupport
Posted by "Jonathan Mezach (JIRA)" <xe...@xml.apache.org>.
[ http://issues.apache.org/jira/browse/XERCESJ-1165?page=comments#action_12412494 ]
Jonathan Mezach commented on XERCESJ-1165:
------------------------------------------
I've just confirmed that this bug indeed does not exist in Xerces 2.8.0. However, it doesn't seem to be the Java runtime either. It was running in Tomcat 5.0 and apparently it had overriding Xerces libraries. I can't determine which version it is though. But anyway, it's working now. Finally.
> 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: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
[jira] Commented: (XERCESJ-1165) Problem resolving namespace prefix
for QName, suspected bug in NamespaceSupport
Posted by "Jonathan Mezach (JIRA)" <xe...@xml.apache.org>.
[ http://issues.apache.org/jira/browse/XERCESJ-1165?page=comments#action_12412378 ]
Jonathan Mezach commented on XERCESJ-1165:
------------------------------------------
I see. I didn't notice this because for some reason, my debugger (Eclipse) doesn't show me any local variables. But anyway, I am in fact using the validator in Java 5, but isn't that in fact Xerces. As far as I can tell, the Xerces implementation is used when validating. Unfortunately I'm not able to check it right now.
> 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: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org