[jira] Created: (WSCOMMONS-87) SchemaBuilder handleSimpleType does not find default namespace which gives a NPE
SchemaBuilder handleSimpleType does not find default namespace which gives a NPE Key: WSCOMMONS-87 URL: http://issues.apache.org/jira/browse/WSCOMMONS-87 Project: WS-Commons Issue Type: Bug Components: XmlSchema Environment: WinXP home, jdk 1.5.0_06, also reported as xfire-617 Reporter: Marc Gagnon This issue was reported on axis2's user list and later in xfire as issue xfire-617. I've been able to reproduce the issue in XmlSchema independently of xfire (see attached files). To reproduce, get XmlSchema (I used 1.0.3, same behavior as 1.0.1) and unzip IncludeTest.java in the tests directory, unzip the xsd files in test-resources and run the unit tests. One test case is ok: the one which defines a default namespace in the included file. The other test case fails because there is no default namespace defined, just like in OTA_SimpleTypes.xsd Sample xsd from the attachement: schema targetNamespace=http://soapinterop.org/xsd; xmlns=http://www.w3.org/2001/XMLSchema; xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xsd1=http://soapinterop.org/xsd; xmlns:xsd2=http://soapinterop.org/xsd2; elementFormDefault=qualified include schemaLocation=includeAux.xsd/ /schema includeAux= schema xmlns=http://www.w3.org/2001/XMLSchema; xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xs=http://www.w3.org/2001/XMLSchema; xmlns:xsd1=http://soapinterop.org/xsd2; elementFormDefault=qualified xs:simpleType name=PaymentCardCodeType xs:union xs:simpleType xs:restriction base=UpperCaseAlphaLength1to2/ /xs:simpleType /xs:union /xs:simpleType xs:simpleType name=UpperCaseAlphaLength1to2 xs:restriction base=xs:string xs:pattern value=[A-Z]{1,2}/ /xs:restriction /xs:simpleType /schema This example is ok, remove line xmlns=http://www.w3.org/2001/XMLSchema; in the file above and it will fail. It seems to me that this declaration should be considered implicit and this should be handled in ShemaBuilder.handleSimpleType -- 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]
[jira] Updated: (WSCOMMONS-87) SchemaBuilder handleSimpleType does not find default namespace which gives a NPE
[ http://issues.apache.org/jira/browse/WSCOMMONS-87?page=all ] Marc Gagnon updated WSCOMMONS-87: - Attachment: XmlSchemaTestInclude.zip I attached the test files mentioned in the previous comment. Also, here is some background information about the origin of the problem. (this is a copy of an email I sent originally on the axis2 users liste and on the Google OTA implementers forum). --- I observed the same issue with another toolkit (axis2). Reference: http://marc.theaimsgroup.com/ (search for xsd:include, message title [Axis2] WSDL2Java does not handle xsd:include correctly) I am willing to switch to xfire if this issue gets solved! I agree on a previous comment: the issue lies in the Apache SchemaBuilder. The problem is with the following construct found in the OTA file OTA_SimpleTypes.xsd: ... xs:simpleType name=PaymentCardCodeType xs:annotation xs:documentation xml:lang=enThe 2 digit code used that references the credit card used./xs:documentation /xs:annotation xs:union xs:simpleType xs:restriction base=UpperCaseAlphaLength1to2 .. The base mentioned above is defined a few lines later in the same file: ... xs:simpleType name=UpperCaseAlphaLength1to2 ... Note that the shema does not use a fully qualified name -- base=UpperCase... In most other restriction base types of the same file, a fully qualified name is used: ... xs:simpleType name=TransactionActionType xs:annotation xs:documentation xml:lang=enTo specify the type of action requested when more than one function could be handled by the message. /xs:documentation /xs:annotation xs:restriction base=xs:string xs:enumeration value=Book/ ... In this case, base=xs:string. Looking at the code where the NPE happens, we see that a fully qualified name is mandatory: Look at class SchemaBuilder, method handleSimpleType: ... XmlSchemaSimpleType handleSimpleType(XmlSchema schema, Element simpleEl, Element schemaEl) { ... if (restrictionEl.hasAttribute(base)) { String name = restrictionEl.getAttribute(base); String[] temp = Tokenizer.tokenize(name, :); String namespace = ; if (temp.length != 1) { namespace = temp[0]; } //let it crash because its mean being refered //to unregistered namespace namespace = schema.namespaces.get(namespace).toString(); name = Tokenizer.lastToken(name, :)[1]; restriction.baseTypeName = new QName(namespace, name); //simpleType.name = name; } else if (inlineSimpleType != null) { ... The comment in this code clearly states that a fully qualified name is required when defining a restriction base type definition for a simple type. Now, what is the good behavior in this situation? To summarize, from a WSDL definition using OTA shema, we have a xsd:include of a message like OTA_HotelAvailRQ.xsd. This message includes basic types like OTA_SimpleTypes.xsd which defines UpperCaseAlphaLength1to2 which is used as a base to define PaymentCardCodeType. We need to follow the namespace definitions closely in this scenario in order to understand what the code should have done instead of the NPE. Our understanding must also be valid agains the W3C specification... Let's start with the WSDL (I'm using the files.ZIP attachement): In types, we find: schema xmlns=http://www.w3.org/2001/XMLSchema; xmlns:client=http://xmlns.oracle.com/OTA_HotelAvail; xmlns:ns1=http://www.opentravel.org/OTA/2003/05; xmlns:plnk=http://schemas.xmlsoap.org/ws/2003/05/partner-link/; import namespace=http://www.opentravel.org/OTA/2003/05; schemaLocation=xsd/OTA_HotelAvailRQ.xsd/ /schema The default namespace is therefore http://www.opentravel.org/OTA/2003/05; The import declares the same namespace. Now, in file OTA_HotelAvailRQ.xsd: xs:schema xmlns=http://www.opentravel.org/OTA/2003/05; xmlns:xs=http://www.w3.org/2001/XMLSchema; targetNamespace=http://www.opentravel.org/OTA/2003/05; elementFormDefault=qualified version=1.005 id=OTA2006A ... xs:include schemaLocation=OTA_SimpleTypes.xsd/ Again, the default namespace is http://www.opentravel.org/OTA/2003/05;, this is also the target namespace. Finally, look at the OTA_SimpleTypes.xsd file: ?xml version=1.0 encoding=UTF-8? xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema; elementFormDefault=qualified version=2.002 id=OTA2003A2006A Here, only the xs namespace is defined for internal references like xs:string. The real question is: Which namespaces should be known and valid when dealing with this inclusion coming from OTA_HotelAvailRQ? In the OTA messages, the high level messages use the targetNamespace to set the namespace. By design, all more primitive types are in separated schemas which are included and they do not define a namespace. This is a documented OTA practice: see OTA 2006A, XML Schema Design Best Practicesversion 3.04 June 2006,page 15, section 4.6.2 No namespace for common XML schema files. The rationale states that the messages which includes simple types will 'coerce' the content in the RQ or RS schema. This looks fine and seems logical.
[jira] Commented: (WSCOMMONS-87) SchemaBuilder handleSimpleType does not find default namespace which gives a NPE
[ http://issues.apache.org/jira/browse/WSCOMMONS-87?page=comments#action_12433397 ] Marc Gagnon commented on WSCOMMONS-87: -- Hum, I should had a closer look at the existing issues: http://issues.apache.org/jira/browse/WSCOMMONS-78 Is about the same issue and seems fixed. Maybe my test case attache should be added to the test suite? Otherwise, there is no point with this bug report - duplicate of #78. Sorry. SchemaBuilder handleSimpleType does not find default namespace which gives a NPE Key: WSCOMMONS-87 URL: http://issues.apache.org/jira/browse/WSCOMMONS-87 Project: WS-Commons Issue Type: Bug Components: XmlSchema Environment: WinXP home, jdk 1.5.0_06, also reported as xfire-617 Reporter: Marc Gagnon Attachments: XmlSchemaTestInclude.zip This issue was reported on axis2's user list and later in xfire as issue xfire-617. I've been able to reproduce the issue in XmlSchema independently of xfire (see attached files). To reproduce, get XmlSchema (I used 1.0.3, same behavior as 1.0.1) and unzip IncludeTest.java in the tests directory, unzip the xsd files in test-resources and run the unit tests. One test case is ok: the one which defines a default namespace in the included file. The other test case fails because there is no default namespace defined, just like in OTA_SimpleTypes.xsd Sample xsd from the attachement: schema targetNamespace=http://soapinterop.org/xsd; xmlns=http://www.w3.org/2001/XMLSchema; xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xsd1=http://soapinterop.org/xsd; xmlns:xsd2=http://soapinterop.org/xsd2; elementFormDefault=qualified include schemaLocation=includeAux.xsd/ /schema includeAux= schema xmlns=http://www.w3.org/2001/XMLSchema; xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xs=http://www.w3.org/2001/XMLSchema; xmlns:xsd1=http://soapinterop.org/xsd2; elementFormDefault=qualified xs:simpleType name=PaymentCardCodeType xs:union xs:simpleType xs:restriction base=UpperCaseAlphaLength1to2/ /xs:simpleType /xs:union /xs:simpleType xs:simpleType name=UpperCaseAlphaLength1to2 xs:restriction base=xs:string xs:pattern value=[A-Z]{1,2}/ /xs:restriction /xs:simpleType /schema This example is ok, remove line xmlns=http://www.w3.org/2001/XMLSchema; in the file above and it will fail. It seems to me that this declaration should be considered implicit and this should be handled in ShemaBuilder.handleSimpleType -- 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]
[jira] Commented: (WSCOMMONS-78) Including a schema without namespace into a schema with namespace is not possible
[ http://issues.apache.org/jira/browse/WSCOMMONS-78?page=comments#action_12433398 ] Marc Gagnon commented on WSCOMMONS-78: -- Hi, I am sorry to report that I created a duplicate log, http://issues.apache.org/jira/browse/WSCOMMONS-87 But please, have a look anyway at the included test case which could be added to the test suite. Thank you. Including a schema without namespace into a schema with namespace is not possible - Key: WSCOMMONS-78 URL: http://issues.apache.org/jira/browse/WSCOMMONS-78 Project: WS-Commons Issue Type: Bug Components: XmlSchema Reporter: Jochen Wiedmann Attachments: XmlSchema-include-handling.patch, XmlSchema-include-handling2.patch, XmlSchema-Include-Without-Namespace.patch The XML Schema specification states in 4.2.1 Assembling a schema for a single target namespace from multiple schema definition documents: 2 One of the following must be true: ... 2.3 SII has no targetNamespace [attribute] (but SII' does). 3 The appropriate case among the following must be true: ... 3.2 If clause 2.3 above is satisfied, then the schema corresponding to the included item's parent schema must include not only definitions or declarations corresponding to the appropriate members of its own [children], but also components identical to all the - schema components- of I, except that anywhere the - absent- target namespace name would have appeared, the - actual value- of the targetNamespace [attribute] of SII' is used. In particular, it replaces - absent- in the following places: 3.2.1 The {target namespace} of named schema components, both at the top level and (in the case of nested type definitions and nested attribute and element declarations whose code was qualified) nested within definitions; 3.2.2 The {namespace constraint} of a wildcard, whether negated or not; In other words, it is possible to include a schema without namespace, as if it had the namespace of the including schema. Unfortunately this fails with XmlSchema, as the attached patch demonstrates. The patch includes a simple test case and could be applied, if this bug is fixed. Suggested resolution, as realized in JaxMeXS: If such a schema is being parsed, then mutable instances of QName should be created, which would always return the target namespace of the schema. -- 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]
svn commit: r441628 - in /webservices/commons/trunk/modules/XmlSchema/src/test: java/tests/ test-resources/WSCOMMONS-87/
Author: jochen Date: Fri Sep 8 13:02:15 2006 New Revision: 441628 URL: http://svn.apache.org/viewvc?view=revrev=441628 Log: Added the WSCOMMONS-87 test case. Added: webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/WSCOMMONS-87/ webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/WSCOMMONS-87/includeAux.xsd webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/WSCOMMONS-87/includeAuxNoDefaultNS.xsd webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/WSCOMMONS-87/includeBase.xsd webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/WSCOMMONS-87/includeBaseNoDefaultNS.xsd Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/IncludeTest.java Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/IncludeTest.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/IncludeTest.java?view=diffrev=441628r1=441627r2=441628 == --- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/IncludeTest.java (original) +++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/IncludeTest.java Fri Sep 8 13:02:15 2006 @@ -16,6 +16,7 @@ import org.apache.ws.commons.schema.XmlSchemaElement; import org.apache.ws.commons.schema.XmlSchemaObjectCollection; import org.apache.ws.commons.schema.XmlSchemaInclude; +import org.xml.sax.InputSource; /* * Copyright 2004,2005 The Apache Software Foundation. @@ -132,4 +133,29 @@ assertNotNull(schemaCol.getTypeByQName(new QName(http://tns.demo.org;, XdwsGroupId))); } +/** + * Schema included defined xmlns=http://www.w3.org/2001/XMLSchema; + * @throws Exception + */ +public void testSchemaInclude() throws Exception{ +String uri = Resources.asURI(WSCOMMONS-87/includeBase.xsd); +InputSource isource = new InputSource(new FileInputStream(uri)); +isource.setSystemId(uri); +XmlSchemaCollection schemaCol = new XmlSchemaCollection(); +XmlSchema schema = schemaCol.read(isource, null); +assertNotNull(schema); +} + +/** + * Schema included does not define xmlns=http://www.w3.org/2001/XMLSchema; + * @throws Exception + */ +public void testSchemaIncludeNoDefaultNS() throws Exception{ +String uri = Resources.asURI(WSCOMMONS-87/includeBaseNoDefaultNS.xsd); +InputSource isource = new InputSource(new FileInputStream(uri)); +isource.setSystemId(uri); +XmlSchemaCollection schemaCol = new XmlSchemaCollection(); +XmlSchema schema = schemaCol.read(isource, null); +assertNotNull(schema); +} } Added: webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/WSCOMMONS-87/includeAux.xsd URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/WSCOMMONS-87/includeAux.xsd?view=autorev=441628 == --- webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/WSCOMMONS-87/includeAux.xsd (added) +++ webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/WSCOMMONS-87/includeAux.xsd Fri Sep 8 13:02:15 2006 @@ -0,0 +1,23 @@ +schema +xmlns=http://www.w3.org/2001/XMLSchema; +xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/; +xmlns:xsd=http://www.w3.org/2001/XMLSchema; +xmlns:xs=http://www.w3.org/2001/XMLSchema; +xmlns:xsd1=http://soapinterop.org/xsd2; +elementFormDefault=qualified + +xs:simpleType name=PaymentCardCodeType +xs:union + xs:simpleType +xs:restriction base=UpperCaseAlphaLength1to2/ + /xs:simpleType +/xs:union + /xs:simpleType + + xs:simpleType name=UpperCaseAlphaLength1to2 +xs:restriction base=xs:string + xs:pattern value=[A-Z]{1,2}/ +/xs:restriction + /xs:simpleType + +/schema Added: webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/WSCOMMONS-87/includeAuxNoDefaultNS.xsd URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/WSCOMMONS-87/includeAuxNoDefaultNS.xsd?view=autorev=441628 == --- webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/WSCOMMONS-87/includeAuxNoDefaultNS.xsd (added) +++ webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/WSCOMMONS-87/includeAuxNoDefaultNS.xsd Fri Sep 8 13:02:15 2006 @@ -0,0 +1,27 @@ +!-- +schema +xmlns=http://www.w3.org/2001/XMLSchema; == Removed this line +xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/; +-- +schema +xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/; +xmlns:xsd=http://www.w3.org/2001/XMLSchema; +
[jira] Resolved: (WSCOMMONS-87) SchemaBuilder handleSimpleType does not find default namespace which gives a NPE
[ http://issues.apache.org/jira/browse/WSCOMMONS-87?page=all ] Jochen Wiedmann resolved WSCOMMONS-87. -- Resolution: Duplicate Test case applied SchemaBuilder handleSimpleType does not find default namespace which gives a NPE Key: WSCOMMONS-87 URL: http://issues.apache.org/jira/browse/WSCOMMONS-87 Project: WS-Commons Issue Type: Bug Components: XmlSchema Environment: WinXP home, jdk 1.5.0_06, also reported as xfire-617 Reporter: Marc Gagnon Attachments: XmlSchemaTestInclude.zip This issue was reported on axis2's user list and later in xfire as issue xfire-617. I've been able to reproduce the issue in XmlSchema independently of xfire (see attached files). To reproduce, get XmlSchema (I used 1.0.3, same behavior as 1.0.1) and unzip IncludeTest.java in the tests directory, unzip the xsd files in test-resources and run the unit tests. One test case is ok: the one which defines a default namespace in the included file. The other test case fails because there is no default namespace defined, just like in OTA_SimpleTypes.xsd Sample xsd from the attachement: schema targetNamespace=http://soapinterop.org/xsd; xmlns=http://www.w3.org/2001/XMLSchema; xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xsd1=http://soapinterop.org/xsd; xmlns:xsd2=http://soapinterop.org/xsd2; elementFormDefault=qualified include schemaLocation=includeAux.xsd/ /schema includeAux= schema xmlns=http://www.w3.org/2001/XMLSchema; xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xs=http://www.w3.org/2001/XMLSchema; xmlns:xsd1=http://soapinterop.org/xsd2; elementFormDefault=qualified xs:simpleType name=PaymentCardCodeType xs:union xs:simpleType xs:restriction base=UpperCaseAlphaLength1to2/ /xs:simpleType /xs:union /xs:simpleType xs:simpleType name=UpperCaseAlphaLength1to2 xs:restriction base=xs:string xs:pattern value=[A-Z]{1,2}/ /xs:restriction /xs:simpleType /schema This example is ok, remove line xmlns=http://www.w3.org/2001/XMLSchema; in the file above and it will fail. It seems to me that this declaration should be considered implicit and this should be handled in ShemaBuilder.handleSimpleType -- 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]
[XmlSchema] Problem in how schema includes are handled
Hi, When I run a this [1] particular test case in Woden, which has a included schema in it, I get runtime errors (see stacktrace below). I somehow feel that this is the same reason which is causing the recent Axis2 build break as reported here [2]. [1] http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Chameleon-2G/getBalance.wsdl [2] http://marc.theaimsgroup.com/?l=axis-devm=115774121107672w=2 The schema is read like this: XmlSchemaCollection xsc = new XmlSchemaCollection(); xsc.setBaseUri( baseURIOfWSDL ); XmlSchema schemaDef = new XmlSchema(xsc); //Setting the prefixes explicitly NamespaceMap prefixmap = new NamespaceMap( namespaceMapFromWSDL ); schemaDef.setNamespaceContext(prefixmap); schemaDef = xsc.read ( wsdlInputSource , null ); //wsdlInputSource is of type org.xml.sax.InputSource ... And I get the following stack trace after running the above piece of code: Exception in thread main java.lang.IllegalStateException: The prefix tns is not bound. at org.apache.ws.commons.schema.SchemaBuilder.getRefQName(SchemaBuilder.java:515) at org.apache.ws.commons.schema.SchemaBuilder.getRefQName(SchemaBuilder.java:496) at org.apache.ws.commons.schema.SchemaBuilder.handleElement(SchemaBuilder.java:1390) at org.apache.ws.commons.schema.SchemaBuilder.handleSequence(SchemaBuilder.java:956) at org.apache.ws.commons.schema.SchemaBuilder.handleComplexType(SchemaBuilder.java:584) at org.apache.ws.commons.schema.SchemaBuilder.handleElement(SchemaBuilder.java:1417) at org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:143) at org.apache.ws.commons.schema.SchemaBuilder.build(SchemaBuilder.java:67) at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:294) at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:286) at org.apache.woden.internal.OMWSDLReader.parseSchemaInline(OMWSDLReader.java:1211) at org.apache.woden.internal.OMWSDLReader.parseTypes(OMWSDLReader.java:245) at org.apache.woden.internal.OMWSDLReader.parseDescription(OMWSDLReader.java:163) at org.apache.woden.internal.OMWSDLReader.readWSDL(OMWSDLReader.java:103) at WSDLReader.main(WSDLReader.java:30) . Am I missing some thing here? Thanks, Oshani - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]