Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 74272 invoked from network); 17 Oct 2010 02:27:18 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 17 Oct 2010 02:27:18 -0000 Received: (qmail 66716 invoked by uid 500); 17 Oct 2010 02:27:18 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 66637 invoked by uid 500); 17 Oct 2010 02:27:18 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 66630 invoked by uid 99); 17 Oct 2010 02:27:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Oct 2010 02:27:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Oct 2010 02:27:08 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0732423889B9; Sun, 17 Oct 2010 02:26:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1023402 [1/9] - in /cxf/trunk: api/src/main/java/org/apache/cxf/databinding/ api/src/main/java/org/apache/cxf/service/model/ common/common/src/main/java/org/apache/cxf/common/xmlschema/ common/common/src/test/java/org/apache/cxf/common/xml... Date: Sun, 17 Oct 2010 02:26:08 -0000 To: commits@cxf.apache.org From: bimargulies@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101017022610.0732423889B9@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bimargulies Date: Sun Oct 17 02:26:06 2010 New Revision: 1023402 URL: http://svn.apache.org/viewvc?rev=1023402&view=rev Log: First round of attempt to use XML Schema 2.0 Modified: cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java cxf/trunk/api/src/main/java/org/apache/cxf/service/model/SchemaInfo.java cxf/trunk/api/src/main/java/org/apache/cxf/service/model/ServiceModelUtil.java cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java cxf/trunk/common/common/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java cxf/trunk/parent/pom.xml cxf/trunk/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/types/CorbaHandlerUtils.java cxf/trunk/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/CorbaUtils.java cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/EnumType.java cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/SchemaAddinsTest.java cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CustomStringType.java cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/AttributeInfo.java cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLUtils.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ArrayVisitor.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/AttributeVisitor.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/DeclaratorVisitor.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/EnumVisitor.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ExceptionVisitor.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/FixedVisitor.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ObjectReferenceVisitor.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/OperationVisitor.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ParamDclVisitor.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ParamDeferredAction.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/SequenceVisitor.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StringVisitor.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/UnionVisitor.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLSchemaManager.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLParameter.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaHelper.java cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLTypes.java cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/utils/WSDLGenerationTester.java cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java Modified: cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java?rev=1023402&r1=1023401&r2=1023402&view=diff ============================================================================== --- cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java (original) +++ cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java Sun Oct 17 02:26:06 2010 @@ -174,7 +174,7 @@ public abstract class AbstractDataBindin schema.setSystemId(systemId); XmlSchema xmlSchema; synchronized (d) { - xmlSchema = col.read(d, systemId, null); + xmlSchema = col.read(d, systemId); schema.setSchema(xmlSchema); schema.setElement(d.getDocumentElement()); } Modified: cxf/trunk/api/src/main/java/org/apache/cxf/service/model/SchemaInfo.java URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/SchemaInfo.java?rev=1023402&r1=1023401&r2=1023402&view=diff ============================================================================== --- cxf/trunk/api/src/main/java/org/apache/cxf/service/model/SchemaInfo.java (original) +++ cxf/trunk/api/src/main/java/org/apache/cxf/service/model/SchemaInfo.java Sun Oct 17 02:26:06 2010 @@ -36,7 +36,7 @@ import org.apache.ws.commons.schema.XmlS import org.apache.ws.commons.schema.utils.NamespaceMap; public final class SchemaInfo extends AbstractPropertiesHolder { - + private String namespaceUri; private boolean isElementQualified; private boolean isAttributeQualified; @@ -45,7 +45,7 @@ public final class SchemaInfo extends Ab // Avoid re-serializing all the time. Particularly as a cached WSDL will // hold a reference to the element. private SoftReference cachedElement; - + public SchemaInfo(String namespaceUri) { this(namespaceUri, false, false); } @@ -55,7 +55,7 @@ public final class SchemaInfo extends Ab this.isElementQualified = qElement; this.isAttributeQualified = qAttribute; } - + public String toString() { StringBuilder buffer = new StringBuilder(this.getClass().getName()); buffer.append(" [namespaceURI: "); @@ -63,10 +63,10 @@ public final class SchemaInfo extends Ab buffer.append("] [systemId: "); buffer.append(systemId); buffer.append("]"); - + return buffer.toString(); } - + public String getNamespaceURI() { return namespaceUri; } @@ -78,7 +78,7 @@ public final class SchemaInfo extends Ab public synchronized void setElement(Element el) { cachedElement = new SoftReference(el); } - + /** * Build and return a DOM tree for this schema. * @return @@ -143,8 +143,8 @@ public final class SchemaInfo extends Ab public void setSchema(XmlSchema schema) { this.schema = schema; - isElementQualified = schema.getElementFormDefault().getValue().equals(XmlSchemaForm.QUALIFIED); - isAttributeQualified = schema.getAttributeFormDefault().getValue().equals(XmlSchemaForm.QUALIFIED); + isElementQualified = schema.getElementFormDefault().equals(XmlSchemaForm.QUALIFIED); + isAttributeQualified = schema.getAttributeFormDefault().equals(XmlSchemaForm.QUALIFIED); } public String getSystemId() { @@ -153,11 +153,11 @@ public final class SchemaInfo extends Ab public void setSystemId(String systemId) { this.systemId = systemId; - } - + } + public XmlSchemaElement getElementByQName(QName qname) { String uri = qname.getNamespaceURI(); - if (schema != null + if (schema != null && schema.getTargetNamespace() != null && schema.getTargetNamespace().equals(uri)) { return schema.getElementByName(qname); @@ -168,11 +168,11 @@ public final class SchemaInfo extends Ab String getNamespaceUri() { return namespaceUri; } - + boolean isElementQualified() { return isElementQualified; } - + boolean isAttributeQualified() { return isAttributeQualified; } Modified: cxf/trunk/api/src/main/java/org/apache/cxf/service/model/ServiceModelUtil.java URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/ServiceModelUtil.java?rev=1023402&r1=1023401&r2=1023402&view=diff ============================================================================== --- cxf/trunk/api/src/main/java/org/apache/cxf/service/model/ServiceModelUtil.java (original) +++ cxf/trunk/api/src/main/java/org/apache/cxf/service/model/ServiceModelUtil.java Sun Oct 17 02:26:06 2010 @@ -44,16 +44,16 @@ public final class ServiceModelUtil { public static Service getService(Exchange exchange) { return exchange.getService(); } - + public static String getTargetNamespace(Exchange exchange) { //all ServiceInfo's will have the same target namespace return getService(exchange).getServiceInfos().get(0).getTargetNamespace(); } - + public static BindingOperationInfo getOperation(Exchange exchange, String opName) { Endpoint ep = exchange.get(Endpoint.class); BindingInfo service = ep.getEndpointInfo().getBinding(); - + for (BindingOperationInfo b : service.getOperations()) { if (b.getName().getLocalPart().equals(opName)) { return b; @@ -73,17 +73,17 @@ public final class ServiceModelUtil { public static BindingOperationInfo getOperationForWrapperElement(Exchange exchange, QName opName, boolean output) { - + Endpoint ep = exchange.get(Endpoint.class); if (ep == null) { return null; } BindingInfo service = ep.getEndpointInfo().getBinding(); - Map wrapperMap = + Map wrapperMap = CastUtils.cast(service.getProperty("ServiceModel.WRAPPER.MAP" - + (output ? "" : "_OUT"), Map.class)); - - + + (output ? "" : "_OUT"), Map.class)); + + if (wrapperMap == null) { wrapperMap = new HashMap(); for (BindingOperationInfo b : service.getOperations()) { @@ -128,7 +128,7 @@ public final class ServiceModelUtil { } return schemaInfo; } - + public static List getOperationInputPartNames(OperationInfo operation) { List names = new ArrayList(); List parts = operation.getInput().getMessageParts(); @@ -141,14 +141,14 @@ public final class ServiceModelUtil { if (schema instanceof XmlSchemaElement && ((XmlSchemaElement)schema).getSchemaType() instanceof XmlSchemaComplexType) { - XmlSchemaElement element = (XmlSchemaElement)schema; + XmlSchemaElement element = (XmlSchemaElement)schema; XmlSchemaComplexType cplxType = (XmlSchemaComplexType)element.getSchemaType(); XmlSchemaSequence seq = (XmlSchemaSequence)cplxType.getParticle(); if (seq == null || seq.getItems() == null) { return names; } - for (int i = 0; i < seq.getItems().getCount(); i++) { - XmlSchemaElement elChild = (XmlSchemaElement)seq.getItems().getItem(i); + for (int i = 0; i < seq.getItems().size(); i++) { + XmlSchemaElement elChild = (XmlSchemaElement)seq.getItems().get(i); names.add(elChild.getName()); } } else { @@ -156,8 +156,8 @@ public final class ServiceModelUtil { } } return names; - } - + } + public static EndpointInfo findBestEndpointInfo(QName qn, List serviceInfos) { for (ServiceInfo serviceInfo : serviceInfos) { Collection eps = serviceInfo.getEndpoints(); @@ -166,8 +166,8 @@ public final class ServiceModelUtil { return ep; } } - } - + } + EndpointInfo best = null; for (ServiceInfo serviceInfo : serviceInfos) { Collection eps = serviceInfo.getEndpoints(); @@ -180,7 +180,7 @@ public final class ServiceModelUtil { } } } - + return best; - } + } } Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java?rev=1023402&r1=1023401&r2=1023402&view=diff ============================================================================== --- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java (original) +++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java Sun Oct 17 02:26:06 2010 @@ -19,22 +19,21 @@ package org.apache.cxf.common.xmlschema; -import java.io.Reader; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; import javax.xml.namespace.QName; -import javax.xml.transform.Source; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.xml.sax.InputSource; -import org.apache.ws.commons.schema.ValidationEventHandler; import org.apache.ws.commons.schema.XmlSchema; import org.apache.ws.commons.schema.XmlSchemaAttribute; +import org.apache.ws.commons.schema.XmlSchemaAttributeGroupRef; +import org.apache.ws.commons.schema.XmlSchemaAttributeOrGroupRef; import org.apache.ws.commons.schema.XmlSchemaCollection; import org.apache.ws.commons.schema.XmlSchemaComplexContentExtension; import org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction; @@ -43,19 +42,16 @@ import org.apache.ws.commons.schema.XmlS import org.apache.ws.commons.schema.XmlSchemaContentModel; import org.apache.ws.commons.schema.XmlSchemaElement; import org.apache.ws.commons.schema.XmlSchemaObject; -import org.apache.ws.commons.schema.XmlSchemaObjectCollection; -import org.apache.ws.commons.schema.XmlSchemaObjectTable; import org.apache.ws.commons.schema.XmlSchemaParticle; import org.apache.ws.commons.schema.XmlSchemaSequence; +import org.apache.ws.commons.schema.XmlSchemaSequenceMember; import org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension; import org.apache.ws.commons.schema.XmlSchemaSimpleContentRestriction; -import org.apache.ws.commons.schema.XmlSchemaSimpleType; import org.apache.ws.commons.schema.XmlSchemaType; import org.apache.ws.commons.schema.extensions.ExtensionRegistry; import org.apache.ws.commons.schema.resolver.URIResolver; import org.apache.ws.commons.schema.utils.NamespaceMap; import org.apache.ws.commons.schema.utils.NamespacePrefixList; -import org.apache.ws.commons.schema.utils.TargetNamespaceValidator; /** @@ -64,7 +60,7 @@ import org.apache.ws.commons.schema.util public class SchemaCollection { private XmlSchemaCollection schemaCollection; - private Map> xmlTypesCheckedForCrossImportsPerSchema + private Map> xmlTypesCheckedForCrossImportsPerSchema = new HashMap>(); @@ -98,17 +94,7 @@ public class SchemaCollection { } public XmlSchemaAttribute getAttributeByQName(QName qname) { - String uri = qname.getNamespaceURI(); - for (XmlSchema schema : schemaCollection.getXmlSchemas()) { - if (uri.equals(schema.getTargetNamespace())) { - XmlSchemaObjectTable attributes = schema.getAttributes(); - XmlSchemaAttribute attribute = (XmlSchemaAttribute)attributes.getItem(qname); - if (attribute != null) { - return attribute; - } - } - } - return null; + return schemaCollection.getAttributeByQName(qname); } public ExtensionRegistry getExtReg() { @@ -121,24 +107,6 @@ public class SchemaCollection { public XmlSchemaType getTypeByQName(QName schemaTypeName) { XmlSchemaType xst = schemaCollection.getTypeByQName(schemaTypeName); - - // HACKY workaround for WSCOMMONS-355 - if (xst == null && "http://www.w3.org/2001/XMLSchema".equals(schemaTypeName.getNamespaceURI())) { - XmlSchema sch = getSchemaByTargetNamespace(schemaTypeName.getNamespaceURI()); - - if ("anySimpleType".equals(schemaTypeName.getLocalPart())) { - XmlSchemaSimpleType type = new XmlSchemaSimpleType(sch); - type.setName(schemaTypeName.getLocalPart()); - sch.addType(type); - xst = type; - } else if ("anyType".equals(schemaTypeName.getLocalPart())) { - XmlSchemaType type = new XmlSchemaType(sch); - type.setName(schemaTypeName.getLocalPart()); - sch.addType(type); - xst = type; - } - } - return xst; } @@ -158,37 +126,16 @@ public class SchemaCollection { schemaCollection.init(); } - public XmlSchema read(Document doc, String uri, ValidationEventHandler veh, - TargetNamespaceValidator validator) { - return schemaCollection.read(doc, uri, veh, validator); - } - - public XmlSchema read(Document doc, String uri, ValidationEventHandler veh) { - return schemaCollection.read(doc, uri, veh); - } - - public XmlSchema read(Document doc, ValidationEventHandler veh) { - return schemaCollection.read(doc, veh); - } - public XmlSchema read(Element elem, String uri) { return schemaCollection.read(elem, uri); } - public XmlSchema read(Element elem) { - return schemaCollection.read(elem); - } - - public XmlSchema read(InputSource inputSource, ValidationEventHandler veh) { - return schemaCollection.read(inputSource, veh); + public XmlSchema read(Document d, String uri) { + return schemaCollection.read(d, uri); } - public XmlSchema read(Reader r, ValidationEventHandler veh) { - return schemaCollection.read(r, veh); - } - - public XmlSchema read(Source source, ValidationEventHandler veh) { - return schemaCollection.read(source, veh); + public XmlSchema read(Element elem) { + return schemaCollection.read(elem); } public void setBaseUri(String baseUri) { @@ -209,7 +156,7 @@ public class SchemaCollection { /** * This function is not part of the XmlSchema API. Who knows why? - * + * * @param namespaceURI targetNamespace * @return schema, or null. */ @@ -239,7 +186,7 @@ public class SchemaCollection { /** * Once upon a time, XmlSchema had a bug in the constructor used in this function. So this wrapper was * created to hold a workaround. - * + * * @param namespaceURI TNS for new schema. * @return new schema */ @@ -250,7 +197,7 @@ public class SchemaCollection { /** * Validate that a qualified name points to some namespace in the schema. - * + * * @param qname */ public void validateQNameNamespace(QName qname) { @@ -282,18 +229,6 @@ public class SchemaCollection { } } - public void addGlobalElementToSchema(XmlSchemaElement element) { - synchronized (this) { - XmlSchema schema = getSchemaByTargetNamespace(element.getQName().getNamespaceURI()); - if (schema == null) { - schema = newXmlSchemaInCollection(element.getQName().getNamespaceURI()); - } - schema.getItems().add(element); - // believe it or not, it is up to us to do both of these adds! - schema.getElements().add(element.getQName(), element); - } - } - public void addCrossImports() { /* * We need to inventory all the cross-imports to see if any are missing. @@ -307,17 +242,14 @@ public class SchemaCollection { /* * We need to visit all the top-level items. */ - for (int x = 0; x < schema.getItems().getCount(); x++) { - XmlSchemaObject item = schema.getItems().getItem(x); + for (XmlSchemaObject item : schema.getItems()) { if (item instanceof XmlSchemaElement) { - addElementCrossImportsElement(schema, item); + addElementCrossImportsElement(schema, (XmlSchemaElement)item); } else if (item instanceof XmlSchemaAttribute) { XmlSchemaAttribute attr = (XmlSchemaAttribute)item; - XmlSchemaUtils.addImportIfNeeded(schema, attr.getRefName()); + XmlSchemaUtils.addImportIfNeeded(schema, attr.getRef().getTargetQName()); XmlSchemaUtils.addImportIfNeeded(schema, attr.getSchemaTypeName()); - if (attr.getSchemaType() != null) { - XmlSchemaUtils.addImportIfNeeded(schema, attr.getSchemaType().getBaseSchemaTypeName()); - } + /* Attributes have simple types and simple types don't have bases. */ } else if (item instanceof XmlSchemaType) { XmlSchemaType type = (XmlSchemaType)item; addCrossImportsType(schema, type); @@ -325,9 +257,9 @@ public class SchemaCollection { } } - private void addElementCrossImportsElement(XmlSchema schema, XmlSchemaObject item) { + private void addElementCrossImportsElement(XmlSchema schema, XmlSchemaElement item) { XmlSchemaElement element = (XmlSchemaElement)item; - XmlSchemaUtils.addImportIfNeeded(schema, element.getRefName()); + XmlSchemaUtils.addImportIfNeeded(schema, element.getRef().getTargetQName()); XmlSchemaUtils.addImportIfNeeded(schema, element.getSchemaTypeName()); // if there's an anonymous type, it might have element refs in it. XmlSchemaType schemaType = element.getSchemaType(); @@ -365,9 +297,10 @@ public class SchemaCollection { private void addCrossImportsType(XmlSchema schema, XmlSchemaType schemaType) { if (schemaType != null) { // the base type might cross schemas. - XmlSchemaUtils.addImportIfNeeded(schema, schemaType.getBaseSchemaTypeName()); + if (schemaType instanceof XmlSchemaComplexType) { XmlSchemaComplexType complexType = (XmlSchemaComplexType)schemaType; + XmlSchemaUtils.addImportIfNeeded(schema, complexType.getBaseSchemaTypeName()); addCrossImports(schema, complexType.getContentModel()); addCrossImportsAttributeList(schema, complexType.getAttributes()); // could it be a choice or something else? @@ -378,19 +311,27 @@ public class SchemaCollection { } private void addCrossImportsSequence(XmlSchema schema, XmlSchemaSequence sequence) { - XmlSchemaObjectCollection items = sequence.getItems(); - for (int x = 0; x < items.getCount(); x++) { - XmlSchemaObject seqItem = items.getItem(x); - if (seqItem instanceof XmlSchemaElement) { - addElementCrossImportsElement(schema, seqItem); + for (XmlSchemaSequenceMember seqMember : sequence.getItems()) { + if (seqMember instanceof XmlSchemaElement) { + addElementCrossImportsElement(schema, (XmlSchemaElement)seqMember); } } } - private void addCrossImportsAttributeList(XmlSchema schema, XmlSchemaObjectCollection attributes) { - for (int x = 0; x < attributes.getCount(); x++) { - XmlSchemaAttribute attr = (XmlSchemaAttribute)attributes.getItem(x); - XmlSchemaUtils.addImportIfNeeded(schema, attr.getRefName()); + private void addCrossImportsAttributeList(XmlSchema schema, + List list) { + for (XmlSchemaAttributeOrGroupRef attr : list) { + QName ref = null; + if (attr instanceof XmlSchemaAttribute) { + ref = ((XmlSchemaAttribute)attr).getRef().getTargetQName(); + } else { + XmlSchemaAttributeGroupRef groupRef = (XmlSchemaAttributeGroupRef) attr; + ref = groupRef.getRef().getTargetQName(); + } + + if (ref != null) { + XmlSchemaUtils.addImportIfNeeded(schema, ref); + } } } @@ -425,18 +366,4 @@ public class SchemaCollection { } } - public static void addGlobalElementToSchema(XmlSchema schema, XmlSchemaElement element) { - synchronized (schema) { - schema.getItems().add(element); - // believe it or not, it is up to us to do both of these adds! - schema.getElements().add(element.getQName(), element); - } - } - - public static void addGlobalTypeToSchema(XmlSchema schema, XmlSchemaType type) { - synchronized (schema) { - schema.getItems().add(type); - schema.addType(type); - } - } } \ No newline at end of file Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java?rev=1023402&r1=1023401&r2=1023402&view=diff ============================================================================== --- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java (original) +++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java Sun Oct 17 02:26:06 2010 @@ -33,41 +33,41 @@ import org.apache.ws.commons.schema.XmlS import org.apache.ws.commons.schema.XmlSchemaAny; import org.apache.ws.commons.schema.XmlSchemaAnyAttribute; import org.apache.ws.commons.schema.XmlSchemaAttribute; +import org.apache.ws.commons.schema.XmlSchemaAttributeOrGroupRef; import org.apache.ws.commons.schema.XmlSchemaComplexContentExtension; import org.apache.ws.commons.schema.XmlSchemaComplexType; import org.apache.ws.commons.schema.XmlSchemaContent; import org.apache.ws.commons.schema.XmlSchemaContentModel; import org.apache.ws.commons.schema.XmlSchemaElement; import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet; +import org.apache.ws.commons.schema.XmlSchemaExternal; import org.apache.ws.commons.schema.XmlSchemaFacet; import org.apache.ws.commons.schema.XmlSchemaForm; import org.apache.ws.commons.schema.XmlSchemaImport; import org.apache.ws.commons.schema.XmlSchemaObject; -import org.apache.ws.commons.schema.XmlSchemaObjectCollection; import org.apache.ws.commons.schema.XmlSchemaParticle; import org.apache.ws.commons.schema.XmlSchemaSequence; +import org.apache.ws.commons.schema.XmlSchemaSequenceMember; import org.apache.ws.commons.schema.XmlSchemaSimpleType; import org.apache.ws.commons.schema.XmlSchemaSimpleTypeContent; import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; import org.apache.ws.commons.schema.XmlSchemaType; /** - * Some functions that avoid problems with Commons XML Schema. + * Some functions that avoid problems with Commons XML Schema. */ public final class XmlSchemaUtils { - public static final XmlSchemaForm QUALIFIED = new XmlSchemaForm(XmlSchemaForm.QUALIFIED); - public static final XmlSchemaForm UNQUALIFIED = new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED); public static final String XSI_NIL = "xsi:nil='true'"; - public static final String XSI_NS_ATTR = WSDLConstants.NP_XMLNS + ":" + public static final String XSI_NS_ATTR = WSDLConstants.NP_XMLNS + ":" + WSDLConstants.NP_SCHEMA_XSI + "='" + WSDLConstants.NS_SCHEMA_XSI + "'"; public static final String XSI_NIL_WITH_PREFIX = XSI_NS_ATTR + " xsi:nil='true'"; private static final Logger LOG = LogUtils.getL7dLogger(XmlSchemaUtils.class); private static final XmlSchemaSequence EMPTY_SEQUENCE = new XmlSchemaSequence(); - + private XmlSchemaUtils() { } - + private static void setNameFromQName(XmlSchemaElement element, QName name) { if (name == null) { element.setName(null); @@ -75,38 +75,51 @@ public final class XmlSchemaUtils { element.setName(name.getLocalPart()); } } - + /** - * Wrapper around XmlSchemaElement.setQName that checks for inconsistency with + * Wrapper around XmlSchemaElement.setQName that checks for inconsistency with * refName. * @param element * @param name */ public static void setElementQName(XmlSchemaElement element, QName name) { - if (name != null && element.getRefName() != null && !element.getRefName().equals(name)) { + if (name != null && element.getRef().getTarget() != null + && !element.getRef().getTargetQName().equals(name)) { LOG.severe("Attempt to set the QName of an element with a reference name"); - throw new + throw new XmlSchemaInvalidOperation("Attempt to set the QName of an element " + "with a reference name."); } - element.setQName(name); + + /* + * An element's namespace must match the containing namespace. + */ + if (!element.getParent().getTargetNamespace().equals(name.getNamespaceURI())) { + LOG.severe("Attempt to set the QName of an element to a namespace that " + + "is outside of the containing schema"); + throw new + XmlSchemaInvalidOperation("Attempt to set the QName of an element to a namespace " + + "that is outside of the containing schema"); + } + + element.setName(name.getLocalPart()); // in CXF, we want them to be consistent. setNameFromQName(element, name); } /** - * Wrapper around XmlSchemaElement.setName that checks for inconsistency with + * Wrapper around XmlSchemaElement.setName that checks for inconsistency with * refName. * @param element * @param name */ public static void setElementName(XmlSchemaElement element, String name) { - if (name != null - && element.getRefName() != null - && !element.getRefName().getLocalPart().equals(name) + if (name != null + && element.getRef().getTarget() != null + && !element.getRef().getTargetQName().getLocalPart().equals(name) && (element.getQName() == null || element.getQName().getLocalPart().equals(name))) { LOG.severe("Attempt to set the name of an element with a reference name."); - throw new + throw new XmlSchemaInvalidOperation("Attempt to set the name of an element " + "with a reference name."); } @@ -114,25 +127,25 @@ public final class XmlSchemaUtils { } /** - * Wrapper around XmlSchemaElement.setRefName that checks for inconsistency with + * Wrapper around XmlSchemaElement.setRefName that checks for inconsistency with * name and QName. * @param element * @param name */ public static void setElementRefName(XmlSchemaElement element, QName name) { if (name != null - && ((element.getQName() != null && !element.getQName().equals(name)) + && ((element.getQName() != null && !element.getQName().equals(name)) || (element.getName() != null && !element.getName().equals(name.getLocalPart())))) { LOG.severe("Attempt to set the refName of an element with a name or QName"); - throw new + throw new XmlSchemaInvalidOperation("Attempt to set the refName of an element " + "with a name or QName."); } - element.setRefName(name); + element.getRef().setTargetQName(name); // cxf conventionally keeps something in the name slot. setNameFromQName(element, name); } - + /** * Return true if a simple type is a straightforward XML Schema representation of an enumeration. * If we discover schemas that are 'enum-like' with more complex structures, we might @@ -146,16 +159,15 @@ public final class XmlSchemaUtils { return false; } XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content; - XmlSchemaObjectCollection facets = restriction.getFacets(); - for (int x = 0; x < facets.getCount(); x++) { - XmlSchemaFacet facet = (XmlSchemaFacet) facets.getItem(x); + List facets = restriction.getFacets(); + for (XmlSchemaFacet facet : facets) { if (!(facet instanceof XmlSchemaEnumerationFacet)) { return false; } } return true; } - + /** * Retrieve the string values for an enumeration. * @param type @@ -164,16 +176,15 @@ public final class XmlSchemaUtils { public static List enumeratorValues(XmlSchemaSimpleType type) { XmlSchemaSimpleTypeContent content = type.getContent(); XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content; - XmlSchemaObjectCollection facets = restriction.getFacets(); - List values = new ArrayList(); - for (int x = 0; x < facets.getCount(); x++) { - XmlSchemaFacet facet = (XmlSchemaFacet) facets.getItem(x); + List facets = restriction.getFacets(); + List values = new ArrayList(); + for (XmlSchemaFacet facet : facets) { XmlSchemaEnumerationFacet enumFacet = (XmlSchemaEnumerationFacet) facet; values.add(enumFacet.getValue().toString()); } return values; } - + /** * Is there an import for a particular namespace in a schema? * @param schema @@ -181,9 +192,8 @@ public final class XmlSchemaUtils { * @return */ public static boolean schemaImportsNamespace(XmlSchema schema, String namespaceUri) { - XmlSchemaObjectCollection inc = schema.getIncludes(); - for (int x = 0; x < inc.getCount(); x++) { - XmlSchemaObject what = inc.getItem(x); + List externals = schema.getExternals(); + for (XmlSchemaExternal what : externals) { if (what instanceof XmlSchemaImport) { XmlSchemaImport imp = (XmlSchemaImport)what; // already there. @@ -194,7 +204,7 @@ public final class XmlSchemaUtils { } return false; } - + /** * Assist in managing the required for imports of peer schemas. * @param schema @@ -202,15 +212,14 @@ public final class XmlSchemaUtils { */ public static void addImportIfNeeded(XmlSchema schema, String namespaceUri) { // no need to import nothing or the XSD schema, or the schema we are fixing. - if ("".equals(namespaceUri) + if ("".equals(namespaceUri) || XmlSchemaConstants.XSD_NAMESPACE_URI.equals(namespaceUri) || schema.getTargetNamespace().equals(namespaceUri)) { return; } - - XmlSchemaObjectCollection inc = schema.getIncludes(); - for (int x = 0; x < inc.getCount(); x++) { - XmlSchemaObject what = inc.getItem(x); + + List externals = schema.getExternals(); + for (XmlSchemaExternal what : externals) { if (what instanceof XmlSchemaImport) { XmlSchemaImport imp = (XmlSchemaImport)what; // already there. @@ -219,12 +228,11 @@ public final class XmlSchemaUtils { } } } - XmlSchemaImport imp = new XmlSchemaImport(); + XmlSchemaImport imp = new XmlSchemaImport(schema); imp.setNamespace(namespaceUri); - inc.add(imp); schema.getItems().add(imp); } - + /** * For convenience, start from a qname, and add the import if it is non-null * and has a namespace. @@ -250,13 +258,13 @@ public final class XmlSchemaUtils { * else, so thus function implements that convention here. It is unclear if * that is a correct structure, and it if changes, we can simplify or * eliminate this function. - * + * * @param name * @param referencingURI * @return */ public static XmlSchemaElement findElementByRefName(SchemaCollection xmlSchemaCollection, - QName name, + QName name, String referencingURI) { String uri = name.getNamespaceURI(); if ("".equals(uri)) { @@ -277,16 +285,16 @@ public final class XmlSchemaUtils { if (content == null) { return null; } - + if (!(content instanceof XmlSchemaComplexContentExtension)) { return null; } - + XmlSchemaComplexContentExtension ext = (XmlSchemaComplexContentExtension)content; - return ext.getBaseTypeName(); + return ext.getBaseTypeName(); } - public static XmlSchemaObjectCollection getContentAttributes(XmlSchemaComplexType type) { + public static List getContentAttributes(XmlSchemaComplexType type) { XmlSchemaContentModel model = type.getContentModel(); if (model == null) { return null; @@ -298,13 +306,13 @@ public final class XmlSchemaUtils { if (!(content instanceof XmlSchemaComplexContentExtension)) { return null; } - + //TODO: the anyAttribute case. XmlSchemaComplexContentExtension ext = (XmlSchemaComplexContentExtension)content; return ext.getAttributes(); } - public static List + public static List getContentAttributes(XmlSchemaComplexType type, SchemaCollection collection) { List results = new ArrayList(); QName baseTypeName = getBaseType(type); @@ -313,22 +321,18 @@ public final class XmlSchemaUtils { // recurse onto the base type ... results.addAll(getContentAttributes(baseType, collection)); // and now process our sequence. - XmlSchemaObjectCollection extAttrs = getContentAttributes(type); - for (int i = 0; i < extAttrs.getCount(); i++) { - results.add((XmlSchemaAnnotated)extAttrs.getItem(i)); - } + List extAttrs = getContentAttributes(type); + results.addAll(extAttrs); return results; } else { // no base type, the simple case. - XmlSchemaObjectCollection attrs = type.getAttributes(); - for (int i = 0; i < attrs.getCount(); i++) { - results.add((XmlSchemaAnnotated)attrs.getItem(i)); - } + List attrs = type.getAttributes(); + results.addAll(attrs); return results; - } + } } - public static List getContentElements(XmlSchemaComplexType type, + public static List getContentElements(XmlSchemaComplexType type, SchemaCollection collection) { List results = new ArrayList(); QName baseTypeName = getBaseType(type); @@ -339,16 +343,19 @@ public final class XmlSchemaUtils { // and now process our sequence. XmlSchemaSequence extSequence = getContentSequence(type); if (extSequence != null) { - for (int i = 0; i < extSequence.getItems().getCount(); i++) { - results.add(extSequence.getItems().getItem(i)); + for (XmlSchemaSequenceMember item : extSequence.getItems()) { + /* + * For now, leave the return type alone. Fix some day. + */ + results.add((XmlSchemaObject)item); } } return results; } else { // no base type, the simple case. XmlSchemaSequence sequence = getSequence(type); - for (int i = 0; i < sequence.getItems().getCount(); i++) { - results.add(sequence.getItems().getItem(i)); + for (XmlSchemaSequenceMember item : sequence.getItems()) { + results.add((XmlSchemaObject)item); } return results; } @@ -366,7 +373,7 @@ public final class XmlSchemaUtils { if (!(content instanceof XmlSchemaComplexContentExtension)) { return null; } - + XmlSchemaComplexContentExtension ext = (XmlSchemaComplexContentExtension)content; XmlSchemaParticle particle = ext.getParticle(); if (particle == null) { @@ -403,12 +410,12 @@ public final class XmlSchemaUtils { /** * Follow a chain of references from element to element until we can obtain * a type. - * + * * @param element * @return */ public static XmlSchemaType getElementType(SchemaCollection xmlSchemaCollection, - String referencingURI, + String referencingURI, XmlSchemaElement element, XmlSchemaType containingType) { assert element != null; @@ -427,22 +434,23 @@ public final class XmlSchemaUtils { if (xmlSchemaCollection.getSchemaByTargetNamespace(referencingURI) == null) { referencingURI = null; } - + if (referencingURI == null && containingType != null) { referencingURI = containingType.getQName().getNamespaceURI(); } - + XmlSchemaElement originalElement = element; - while (element.getSchemaType() == null && element.getRefName() != null) { - XmlSchemaElement nextElement = findElementByRefName(xmlSchemaCollection, - element.getRefName(), - referencingURI); + while (element.getSchemaType() == null && element.getRef().getTarget() != null) { + /* + * This code assumes that all schemas are in the collection. + */ + XmlSchemaElement nextElement = element.getRef().getTarget(); assert nextElement != null; element = nextElement; } if (element.getSchemaType() == null) { - unsupportedConstruct("ELEMENT_HAS_NO_TYPE", - originalElement.getName(), + unsupportedConstruct("ELEMENT_HAS_NO_TYPE", + originalElement.getName(), containingType.getQName(), containingType); } @@ -450,26 +458,26 @@ public final class XmlSchemaUtils { } /** - * If the object is an attribute or an anyAttribute, + * If the object is an attribute or an anyAttribute, * return the 'Annotated'. If it's not one of those, or it's a group, * throw. We're not ready for groups yet. * @param object * @return */ public static XmlSchemaAnnotated getObjectAnnotated(XmlSchemaObject object, QName contextName) { - + if (!(object instanceof XmlSchemaAnnotated)) { - unsupportedConstruct("NON_ANNOTATED_ATTRIBUTE", - object.getClass().getSimpleName(), + unsupportedConstruct("NON_ANNOTATED_ATTRIBUTE", + object.getClass().getSimpleName(), contextName, object); } if (!(object instanceof XmlSchemaAttribute) && !(object instanceof XmlSchemaAnyAttribute)) { - unsupportedConstruct("EXOTIC_ATTRIBUTE", + unsupportedConstruct("EXOTIC_ATTRIBUTE", object.getClass().getSimpleName(), contextName, object); } - + return (XmlSchemaAnnotated) object; } @@ -480,26 +488,29 @@ public final class XmlSchemaUtils { * @return */ public static XmlSchemaParticle getObjectParticle(XmlSchemaObject object, QName contextName) { - + if (!(object instanceof XmlSchemaParticle)) { - unsupportedConstruct("NON_PARTICLE_CHILD", - object.getClass().getSimpleName(), + unsupportedConstruct("NON_PARTICLE_CHILD", + object.getClass().getSimpleName(), contextName, object); } if (!(object instanceof XmlSchemaElement) && !(object instanceof XmlSchemaAny)) { - unsupportedConstruct("GROUP_CHILD", + unsupportedConstruct("GROUP_CHILD", object.getClass().getSimpleName(), contextName, object); } - + return (XmlSchemaParticle) object; } - public static XmlSchemaElement getReferredElement(XmlSchemaElement element, + public static XmlSchemaElement getReferredElement(XmlSchemaElement element, SchemaCollection xmlSchemaCollection) { - if (element.getRefName() != null) { - XmlSchemaElement refElement = xmlSchemaCollection.getElementByQName(element.getRefName()); + if (element.getRef() != null) { + /* + * Calling getTarget works if everything is in the collection already. + */ + XmlSchemaElement refElement = element.getRef().getTarget(); if (refElement == null) { throw new RuntimeException("Dangling reference"); } @@ -511,33 +522,33 @@ public final class XmlSchemaUtils { public static XmlSchemaSequence getSequence(XmlSchemaComplexType type) { XmlSchemaParticle particle = type.getParticle(); XmlSchemaSequence sequence = null; - + if (particle == null) { // the code that uses this wants to iterate. An empty one is more useful than // a null pointer, and certainly an exception. return EMPTY_SEQUENCE; } - + try { sequence = (XmlSchemaSequence) particle; } catch (ClassCastException cce) { unsupportedConstruct("NON_SEQUENCE_PARTICLE", type); } - + return sequence; } public static boolean isAttributeNameQualified(XmlSchemaAttribute attribute, XmlSchema schema) { - if (attribute.getRefName() != null) { + if (attribute.getRef() != null) { throw new RuntimeException("isElementNameQualified on element with ref="); } - if (attribute.getForm().equals(QUALIFIED)) { + if (attribute.getForm().equals(XmlSchemaForm.QUALIFIED)) { return true; } - if (attribute.getForm().equals(UNQUALIFIED)) { + if (attribute.getForm().equals(XmlSchemaForm.UNQUALIFIED)) { return false; } - return schema.getAttributeFormDefault().equals(QUALIFIED); + return schema.getAttributeFormDefault().equals(XmlSchemaForm.QUALIFIED); } /** @@ -549,7 +560,7 @@ public final class XmlSchemaUtils { * all we care about is the default element form of the schema and the local * form of the element.
If, on the other hand, the element is global, * we might need to compare namespaces.
- * + * * @param attribute the attribute * @param global if this element is a global element (complex type ref= to * it, or in a part) @@ -565,14 +576,14 @@ public final class XmlSchemaUtils { if (attribute.getQName() == null) { throw new RuntimeException("getSchemaQualifier on anonymous element."); } - if (attribute.getRefName() != null) { + if (attribute.getRef() != null) { throw new RuntimeException("getSchemaQualified on the 'from' side of ref=."); } - - + + if (global) { return isAttributeNameQualified(attribute, attributeSchema) - || (localSchema != null + || (localSchema != null && !(attribute.getQName().getNamespaceURI().equals(localSchema.getTargetNamespace()))); } else { return isAttributeNameQualified(attribute, attributeSchema); @@ -584,16 +595,16 @@ public final class XmlSchemaUtils { } public static boolean isElementNameQualified(XmlSchemaElement element, XmlSchema schema) { - if (element.getRefName() != null) { + if (element.getRef() != null) { throw new RuntimeException("isElementNameQualified on element with ref="); } - if (element.getForm().equals(QUALIFIED)) { + if (element.getForm().equals(XmlSchemaForm.QUALIFIED)) { return true; } - if (element.getForm().equals(UNQUALIFIED)) { + if (element.getForm().equals(XmlSchemaForm.UNQUALIFIED)) { return false; } - return schema.getElementFormDefault().equals(QUALIFIED); + return schema.getElementFormDefault().equals(XmlSchemaForm.QUALIFIED); } /** @@ -605,7 +616,7 @@ public final class XmlSchemaUtils { * all we care about is the default element form of the schema and the local * form of the element.
If, on the other hand, the element is global, * we might need to compare namespaces.
- * + * * @param element the element. * @param global if this element is a global element (complex type ref= to * it, or in a part) @@ -622,14 +633,14 @@ public final class XmlSchemaUtils { if (qn == null) { throw new RuntimeException("isElementQualified on anonymous element."); } - if (element.getRefName() != null) { + if (element.getRef() != null) { throw new RuntimeException("isElementQualified on the 'from' side of ref=."); } - - + + if (global) { return isElementNameQualified(element, elementSchema) - || (localSchema != null + || (localSchema != null && !(qn.getNamespaceURI().equals(localSchema.getTargetNamespace()))); } else { return isElementNameQualified(element, elementSchema); @@ -644,20 +655,20 @@ public final class XmlSchemaUtils { return particle.getMinOccurs() == 0 && particle.getMaxOccurs() == 1; } - public static void unsupportedConstruct(String messageKey, - String what, + public static void unsupportedConstruct(String messageKey, + String what, QName subjectName, XmlSchemaObject subject) { - Message message = new Message(messageKey, LOG, what, + Message message = new Message(messageKey, LOG, what, subjectName == null ? "anonymous" : subjectName, cleanedUpSchemaSource(subject)); LOG.severe(message.toString()); throw new UnsupportedConstruct(message); - + } - + public static void unsupportedConstruct(String messageKey, XmlSchemaType subject) { - Message message = new Message(messageKey, LOG, subject.getQName(), + Message message = new Message(messageKey, LOG, subject.getQName(), cleanedUpSchemaSource(subject)); LOG.severe(message.toString()); throw new UnsupportedConstruct(message); @@ -667,7 +678,7 @@ public final class XmlSchemaUtils { if (subject == null || subject.getSourceURI() == null) { return ""; } else { - return subject.getSourceURI() + ":" + subject.getLineNumber(); + return subject.getSourceURI() + ":" + subject.getLineNumber(); } } } Modified: cxf/trunk/common/common/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java?rev=1023402&r1=1023401&r2=1023402&view=diff ============================================================================== --- cxf/trunk/common/common/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java (original) +++ cxf/trunk/common/common/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java Sun Oct 17 02:26:06 2010 @@ -58,7 +58,7 @@ import org.junit.Assert; import org.junit.Test; /** - * + * */ public class ImportRepairTest extends Assert { private static final class ListLSInput implements LSInputList { @@ -96,7 +96,7 @@ public class ImportRepairTest extends As //and we cannot get a good version unless we endorse it return; } - + collection = new SchemaCollection(); XmlSchema importingSchema = newSchema(IMPORTING_SCHEMA); XmlSchema baseTypeSchema1 = newSchema(BASE_TYPE_SCHEMA1); @@ -122,8 +122,8 @@ public class ImportRepairTest extends As createImportedAttribute(attributeSchema); - XmlSchemaAttribute importingAttribute = new XmlSchemaAttribute(); - importingAttribute.setRefName(new QName(ATTRIBUTE_SCHEMA, "imported")); + XmlSchemaAttribute importingAttribute = new XmlSchemaAttribute(importingSchema, false); + importingAttribute.getRef().setTargetQName(new QName(ATTRIBUTE_SCHEMA, "imported")); // borrow derivedType1 to make the reference. derivedType1Extension.getAttributes().add(importingAttribute); @@ -188,10 +188,8 @@ public class ImportRepairTest extends As } private void createTypeImportedByElement(XmlSchema elementTypeSchema) { - XmlSchemaComplexType elementImportedType = new XmlSchemaComplexType(elementTypeSchema); + XmlSchemaComplexType elementImportedType = new XmlSchemaComplexType(elementTypeSchema, true); elementImportedType.setName("importedElementType"); - elementTypeSchema.addType(elementImportedType); - elementTypeSchema.getItems().add(elementImportedType); elementImportedType.setParticle(new XmlSchemaSequence()); } @@ -204,100 +202,78 @@ public class ImportRepairTest extends As } private void createAttributeImportingType(XmlSchema importingSchema) { - XmlSchemaAttribute attributeImportingType = new XmlSchemaAttribute(); + XmlSchemaAttribute attributeImportingType = new XmlSchemaAttribute(importingSchema, true); attributeImportingType.setName("importingType"); - importingSchema.getAttributes().add(new QName(ELEMENT_SCHEMA, "importingTypeAttribute"), - attributeImportingType); - importingSchema.getItems().add(attributeImportingType); attributeImportingType.setSchemaTypeName(new QName(ATTRIBUTE_TYPE_SCHEMA, "importedAttributeType")); } private void createImportedAttributeType(XmlSchema attributeTypeSchema) { - XmlSchemaSimpleType attributeImportedType = new XmlSchemaSimpleType(attributeTypeSchema); + XmlSchemaSimpleType attributeImportedType = new XmlSchemaSimpleType(attributeTypeSchema, true); attributeImportedType.setName("importedAttributeType"); - attributeTypeSchema.addType(attributeImportedType); - attributeTypeSchema.getItems().add(attributeImportedType); XmlSchemaSimpleTypeRestriction simpleContent = new XmlSchemaSimpleTypeRestriction(); attributeImportedType.setContent(simpleContent); simpleContent.setBaseTypeName(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "string")); } private void createImportedAttribute(XmlSchema attributeSchema) { - XmlSchemaAttribute importedAttribute = new XmlSchemaAttribute(); + XmlSchemaAttribute importedAttribute = new XmlSchemaAttribute(attributeSchema, true); importedAttribute.setName("imported"); importedAttribute.setSchemaTypeName(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "string")); - attributeSchema.getAttributes().add(new QName(ATTRIBUTE_SCHEMA, "imported"), importedAttribute); - attributeSchema.getItems().add(importedAttribute); } private void createElementWithImportedType(XmlSchema importingSchema) { - XmlSchemaElement elementWithImportedType = new XmlSchemaElement(); + XmlSchemaElement elementWithImportedType = new XmlSchemaElement(importingSchema, true); elementWithImportedType.setName("elementWithImportedType"); elementWithImportedType.setSchemaTypeName(new QName(ELEMENT_TYPE_SCHEMA, "importedElementType")); - importingSchema.getItems().add(elementWithImportedType); - importingSchema.getElements().add(elementWithImportedType.getQName(), elementWithImportedType); } private void createTypeImportingElement(XmlSchema importingSchema) { - XmlSchemaComplexType typeWithElementRef = new XmlSchemaComplexType(importingSchema); + XmlSchemaComplexType typeWithElementRef = new XmlSchemaComplexType(importingSchema, true); typeWithElementRef.setName("typeWithRef"); - importingSchema.addType(typeWithElementRef); - importingSchema.getItems().add(typeWithElementRef); XmlSchemaSequence sequence = new XmlSchemaSequence(); typeWithElementRef.setParticle(sequence); - XmlSchemaElement refElement = new XmlSchemaElement(); - sequence.getItems().add(refElement); - refElement.setRefName(new QName(ELEMENT_SCHEMA, "importedElement")); + XmlSchemaElement refElement = new XmlSchemaElement(importingSchema, false); + refElement.getRef().setTargetQName(new QName(ELEMENT_SCHEMA, "importedElement")); } private void createImportedElement(XmlSchema elementSchema) { - XmlSchemaElement importedElement = new XmlSchemaElement(); + XmlSchemaElement importedElement = new XmlSchemaElement(elementSchema, true); importedElement.setName("importedElement"); importedElement.setSchemaTypeName(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "string")); - elementSchema.getElements().add(new QName(ELEMENT_SCHEMA, "importedElement"), importedElement); - elementSchema.getItems().add(importedElement); } private void createDerivedType2(XmlSchema importingSchema) { XmlSchemaComplexContent complexContent; - XmlSchemaComplexType derivedType2 = new XmlSchemaComplexType(importingSchema); + XmlSchemaComplexType derivedType2 = new XmlSchemaComplexType(importingSchema, true); derivedType2.setName("derivedRestriction"); XmlSchemaComplexContentRestriction restriction = new XmlSchemaComplexContentRestriction(); restriction.setBaseTypeName(new QName(BASE_TYPE_SCHEMA2, "baseType2")); complexContent = new XmlSchemaComplexContent(); complexContent.setContent(restriction); derivedType2.setContentModel(complexContent); - importingSchema.addType(derivedType2); - importingSchema.getItems().add(derivedType2); } private XmlSchemaComplexContentExtension createDerivedType1(XmlSchema importingSchema) { - XmlSchemaComplexType derivedType1 = new XmlSchemaComplexType(importingSchema); + XmlSchemaComplexType derivedType1 = new XmlSchemaComplexType(importingSchema, true); derivedType1.setName("derivedExtension"); XmlSchemaComplexContentExtension extension = new XmlSchemaComplexContentExtension(); extension.setBaseTypeName(new QName(BASE_TYPE_SCHEMA1, "baseType1")); XmlSchemaComplexContent complexContent = new XmlSchemaComplexContent(); complexContent.setContent(extension); derivedType1.setContentModel(complexContent); - importingSchema.addType(derivedType1); - importingSchema.getItems().add(derivedType1); return extension; } private XmlSchemaComplexType createBaseType2(XmlSchema baseTypeSchema2) { - XmlSchemaComplexType baseType2 = new XmlSchemaComplexType(baseTypeSchema2); + XmlSchemaComplexType baseType2 = new XmlSchemaComplexType(baseTypeSchema2, true); baseType2.setName("baseType2"); - baseTypeSchema2.addType(baseType2); - baseTypeSchema2.getItems().add(baseType2); baseType2.setParticle(new XmlSchemaSequence()); return baseType2; } private void createBaseType1(XmlSchema baseTypeSchema1) { - XmlSchemaComplexType baseType1 = new XmlSchemaComplexType(baseTypeSchema1); + XmlSchemaComplexType baseType1 = new XmlSchemaComplexType(baseTypeSchema1, true); baseType1.setName("baseType1"); - baseTypeSchema1.addType(baseType1); - baseTypeSchema1.getItems().add(baseType1); baseType1.setParticle(new XmlSchemaSequence()); } Modified: cxf/trunk/parent/pom.xml URL: http://svn.apache.org/viewvc/cxf/trunk/parent/pom.xml?rev=1023402&r1=1023401&r2=1023402&view=diff ============================================================================== --- cxf/trunk/parent/pom.xml (original) +++ cxf/trunk/parent/pom.xml Sun Oct 17 02:26:06 2010 @@ -72,7 +72,7 @@ 4.0.8 1.6.2 2.4.0 - 1.4.7 + 2.0-SNAPSHOT VALIDATION_AUTO Modified: cxf/trunk/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/types/CorbaHandlerUtils.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/types/CorbaHandlerUtils.java?rev=1023402&r1=1023401&r2=1023402&view=diff ============================================================================== --- cxf/trunk/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/types/CorbaHandlerUtils.java (original) +++ cxf/trunk/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/types/CorbaHandlerUtils.java Sun Oct 17 02:26:06 2010 @@ -42,8 +42,9 @@ import org.apache.cxf.binding.corba.wsdl import org.apache.cxf.service.model.ServiceInfo; import org.apache.ws.commons.schema.XmlSchemaComplexType; import org.apache.ws.commons.schema.XmlSchemaElement; -import org.apache.ws.commons.schema.XmlSchemaGroupBase; import org.apache.ws.commons.schema.XmlSchemaObject; +import org.apache.ws.commons.schema.XmlSchemaParticle; +import org.apache.ws.commons.schema.XmlSchemaSequence; import org.omg.CORBA.ORB; import org.omg.CORBA.TCKind; import org.omg.CORBA.TypeCode; @@ -54,10 +55,10 @@ public final class CorbaHandlerUtils { } public static CorbaObjectHandler createTypeHandler(ORB orb, - QName name, + QName name, QName idlType, CorbaTypeMap typeMap) { - CorbaObjectHandler handler = null; + CorbaObjectHandler handler = null; TypeCode tc = CorbaUtils.getTypeCode(orb, idlType, typeMap); try { while (tc.kind().value() == TCKind._tk_alias) { @@ -112,18 +113,18 @@ public final class CorbaHandlerUtils { break; case TCKind._tk_objref: handler = new CorbaObjectReferenceHandler(name, idlType, tc, type); - break; + break; default: - handler = new CorbaObjectHandler(name, idlType, tc, type); + handler = new CorbaObjectHandler(name, idlType, tc, type); } } return handler; } - + public static CorbaObjectHandler initializeObjectHandler(ORB orb, - QName name, + QName name, QName idlType, CorbaTypeMap typeMap, ServiceInfo serviceInfo) { @@ -132,7 +133,7 @@ public final class CorbaHandlerUtils { } public static CorbaObjectHandler initializeObjectHandler(ORB orb, - QName name, + QName name, QName idlType, CorbaTypeMap typeMap, ServiceInfo serviceInfo, @@ -167,9 +168,9 @@ public final class CorbaHandlerUtils { } return obj; } - + public static void initializeArrayHandler(ORB orb, - CorbaObjectHandler obj, + CorbaObjectHandler obj, CorbaTypeMap typeMap, ServiceInfo serviceInfo, Map seenTypes) { @@ -189,15 +190,15 @@ public final class CorbaHandlerUtils { elementName = anonArrayType.getElemname(); } for (int i = 0; i < arrayBound; ++i) { - CorbaObjectHandler elementObj = + CorbaObjectHandler elementObj = initializeObjectHandler(orb, elementName, arrayElementType, typeMap, serviceInfo, seenTypes); ((CorbaArrayHandler)obj).addElement(elementObj); } } - + public static void initializeExceptionHandler(ORB orb, - CorbaObjectHandler obj, + CorbaObjectHandler obj, CorbaTypeMap typeMap, ServiceInfo serviceInfo, Map seenTypes) { @@ -222,9 +223,9 @@ public final class CorbaHandlerUtils { ((CorbaExceptionHandler)obj).addMember(memberObj); } } - + public static void initializeSequenceHandler(ORB orb, - CorbaObjectHandler obj, + CorbaObjectHandler obj, CorbaTypeMap typeMap, ServiceInfo serviceInfo, Map seenTypes) { @@ -247,22 +248,22 @@ public final class CorbaHandlerUtils { // This is an unbounded sequence. Store a 'template' object that we can use to create // new objects as needed CorbaObjectHandler elementObj = null; - + // Check for a recursive type if (seenTypes.get(seqElementType) != null) { elementObj = seenTypes.get(seqElementType); elementObj.setRecursive(true); ((CorbaSequenceHandler)obj).hasRecursiveTypeElement(true); } else { - elementObj = - initializeObjectHandler(orb, elementName, seqElementType, typeMap, + elementObj = + initializeObjectHandler(orb, elementName, seqElementType, typeMap, serviceInfo, seenTypes); } ((CorbaSequenceHandler)obj).setTemplateElement(elementObj); } for (int i = 0; i < seqBound; ++i) { CorbaObjectHandler elementObj = null; - + // Check for a recursive type if (seenTypes.get(seqElementType) != null) { // Even though this is bounded, if we have a recursive type, we'll still use the @@ -272,16 +273,16 @@ public final class CorbaHandlerUtils { ((CorbaSequenceHandler)obj).hasRecursiveTypeElement(true); ((CorbaSequenceHandler)obj).setTemplateElement(elementObj); } else { - elementObj = + elementObj = initializeObjectHandler(orb, elementName, seqElementType, typeMap, serviceInfo, seenTypes); ((CorbaSequenceHandler)obj).addElement(elementObj); } } } - + public static void initializeStructHandler(ORB orb, - CorbaObjectHandler obj, + CorbaObjectHandler obj, CorbaTypeMap typeMap, ServiceInfo serviceInfo, Map seenTypes) { @@ -314,15 +315,15 @@ public final class CorbaHandlerUtils { seenTypes.remove(obj.getIdlType()); } - + public static void initializeUnionHandler(ORB orb, - CorbaObjectHandler obj, + CorbaObjectHandler obj, CorbaTypeMap typeMap, - ServiceInfo serviceInfo, + ServiceInfo serviceInfo, Map seenTypes) { Union unionType = (Union)obj.getType(); // First handle the discriminator - CorbaObjectHandler discObj = initializeObjectHandler(orb, + CorbaObjectHandler discObj = initializeObjectHandler(orb, new QName("discriminator"), unionType.getDiscriminator(), typeMap, @@ -344,7 +345,7 @@ public final class CorbaHandlerUtils { branchName = new QName("", branch.getName()); } QName branchIdlType = branch.getIdltype(); - CorbaObjectHandler branchObj = + CorbaObjectHandler branchObj = initializeObjectHandler(orb, branchName, branchIdlType, typeMap, serviceInfo, seenTypes); ((CorbaUnionHandler)obj).addCase(branchObj); @@ -370,16 +371,20 @@ public final class CorbaHandlerUtils { if (schemaType instanceof XmlSchemaElement) { stype = ((XmlSchemaElement) schemaType).getSchemaType(); if (stype == null) { - stype = CorbaUtils.getXmlSchemaType(serviceInfo, - ((XmlSchemaElement) schemaType).getRefName()); + stype = CorbaUtils.getXmlSchemaType(serviceInfo, + ((XmlSchemaElement) schemaType) + .getRef().getTargetQName()); } } - + if (stype instanceof XmlSchemaComplexType) { //only one element inside the XmlSchemaComplexType XmlSchemaComplexType ctype = (XmlSchemaComplexType) stype; - XmlSchemaGroupBase group = (XmlSchemaGroupBase) ctype.getParticle(); - el = (XmlSchemaElement) group.getItems().getItem(0); + XmlSchemaParticle group = ctype.getParticle(); + /* This code seems to think that we're guaranteed a sequence here */ + XmlSchemaSequence seq = (XmlSchemaSequence) group; + /* and an element in it, too */ + el = (XmlSchemaElement) seq.getItems().get(0); } else { el = (XmlSchemaElement) schemaType; } @@ -452,7 +457,7 @@ public final class CorbaHandlerUtils { handler = new CorbaStructHandler(name, idlType, tc, type); result = new CorbaStructListener(handler, typeMap, orb, serviceInfo); break; - case TCKind._tk_union: + case TCKind._tk_union: handler = new CorbaUnionHandler(name, idlType, tc, type); result = new CorbaUnionListener(handler, typeMap, orb, serviceInfo); break; @@ -467,11 +472,11 @@ public final class CorbaHandlerUtils { } return result; } - + public static CorbaTypeEventProducer getTypeEventProducer(CorbaObjectHandler handler, ServiceInfo serviceInfo, ORB orb) - throws CorbaBindingException { + throws CorbaBindingException { QName idlType = handler.getIdlType(); TypeCode tc = handler.getTypeCode(); CorbaTypeEventProducer result = null; @@ -541,7 +546,7 @@ public final class CorbaHandlerUtils { } public static boolean isAnonType(XmlSchemaObject schemaObj) { - boolean result = false; + boolean result = false; if ((schemaObj != null) && !(schemaObj instanceof XmlSchemaElement) && !(schemaObj instanceof XmlSchemaComplexType)) { result = true;