You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by bu...@apache.org on 2003/12/10 13:10:30 UTC

DO NOT REPLY [Bug 25392] New: - QName constants constructed without Schema-specified namespace

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25392>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25392

QName constants constructed without Schema-specified namespace

           Summary: QName constants constructed without Schema-specified
                    namespace
           Product: Axis
           Version: current (nightly)
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: WSDL processing
        AssignedTo: axis-dev@ws.apache.org
        ReportedBy: a_andrieux@hotmail.com


Overview Description: 
---------------------
Problem:
Construction of QNames (in generated enumerated types, at least) is done by
merely passing the constant QName string value to the QName constructor, which
interprets it as a local name, consequently the namespace URI is empty ("").

Example:
given the Schema type UsageType a restriction of xsd:QName,
UsageType.java (wsp) constructs QName instances with String values  
passed to the QName constructor as is ("<prefix>:<local name>") 
instead of being parsed in order to extract the namespace URI (from 
some mapping recorded by the in-memory Schema object model) and 
the local name. 

Example Input Schema
--------------------
	<xs:simpleType name="UsageType">
		[...]
		<xs:restriction base="xs:QName">
			<xs:enumeration value="wsp:Required"/>
			<xs:enumeration value="wsp:Optional"/>
			<xs:enumeration value="wsp:Rejected"/>
			<xs:enumeration value="wsp:Ignored"/>
			<xs:enumeration value="wsp:Observed"/>
		</xs:restriction>
	</xs:simpleType>

The full schema is at: http://schemas.xmlsoap.org/ws/2002/12/policy

Generated Java code:
--------------------
package org.xmlsoap.policy;

public class UsageType implements java.io.Serializable {
    private javax.xml.namespace.QName _value_;
[...]
    public static final javax.xml.namespace.QName _value1 = new
javax.xml.namespace.QName("wsp:Required");
    public static final javax.xml.namespace.QName _value2 = new
javax.xml.namespace.QName("wsp:Optional");

[...]
    public static UsageType fromString(java.lang.String value)
          throws java.lang.IllegalStateException {
        try {
            return fromValue(new javax.xml.namespace.QName(value));
        } catch (Exception e) {
            throw new java.lang.IllegalStateException();
        }
    }
[...]

Consequences:
-------------
  This will lead to run-time deserialization errors, for instance when the 
  prefix-to-namespace assignement is different in the XML document/payload 
  received than in the Schema used to generate the Java code on the 
  receiving side. 
  Also, for the same reasons, the fromString(String) static methods should be 
  deprecated in QName-based enumerated types in favor of methods like:
  fromQName(QName) or from(String nsURI, String localName).


Proposal/Expected Behavior
--------------------------
The code  generator should insert the namespace URI from the prefix read in the
 QName value (in the schema) so that the generated code use it when constructing
the QName. As in:

     new QName("http://schemas.xmlsoap.org/ws/2002/12/policy","Required");

       instead of 
 
    new QName("wsp:Required");

Build Date: 
-----------
I build source from a CVS check out made on 12/10/2003, around 2:00 am