You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by jk...@apache.org on 2007/08/23 13:01:35 UTC
svn commit: r568932 [24/36] - in
/incubator/woden/trunk/java/src/org/apache/woden: ./ ant/ internal/
internal/resolver/ internal/schema/ internal/util/ internal/util/dom/
internal/util/om/ internal/wsdl20/ internal/wsdl20/extensions/
internal/wsdl20/ex...
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java?rev=568932&r1=568931&r2=568932&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java Thu Aug 23 04:01:23 2007
@@ -1,457 +1,457 @@
-/**
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.woden.internal.wsdl20.validation;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.woden.ErrorReporter;
-import org.apache.woden.WSDLException;
-import org.apache.woden.internal.ErrorLocatorImpl;
-import org.apache.woden.internal.wsdl20.Constants;
-import org.apache.woden.schema.ImportedSchema;
-import org.apache.woden.schema.InlinedSchema;
-import org.apache.woden.schema.Schema;
-import org.apache.woden.wsdl20.xml.DescriptionElement;
-import org.apache.woden.wsdl20.xml.ImportElement;
-import org.apache.woden.wsdl20.xml.InterfaceElement;
-import org.apache.woden.wsdl20.xml.InterfaceFaultElement;
-import org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement;
-import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
-import org.apache.woden.wsdl20.xml.TypesElement;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.ws.commons.schema.XmlSchemaObjectTable;
-
-/**
- * The WSDL document validator validates a WSDL XML model against the
- * document assertions specified in the WSDL 2.0 specification.
- */
-public class WSDLDocumentValidator
-{
- /**
- * Validate the document representation of the WSDL document against
- * the WSDL 2.0 specification.
- *
- * @param descElement The WSDL 2.0 XML model description element.
- * @param errorReporter The error reporter to use for any errors.
- * @return True if the WSDL document representation is valid, false otherwise.
- * @throws WSDLException
- */
- public boolean validate(DescriptionElement descElement, ErrorReporter errorReporter) throws WSDLException
- {
- boolean isValid = true;
-
- // Test the description element.
- isValid = testAssertionDescription1006(descElement, errorReporter);
-
- // Test the import elements.
- ImportElement[] imports = descElement.getImportElements();
- int numImports = imports.length;
- for(int i = 0; i < numImports; i++)
- {
- // TODO: Implement methods once import elements are supported.
-// if(!testAssertionImport0001(imports[i], errorReporter))
-// isValid = false;
-// if(!testAssertionImport0003(imports[i], errorReporter))
-// isValid = false;
- }
- if(!validateTypes(descElement.getTypesElement(), errorReporter))
- isValid = false;
-
- if(!validateInterfaces(descElement, descElement.getInterfaceElements(), errorReporter))
- isValid = false;
-
- // 1. Call the validators for specific namespaces
- // - Does this need to be broken up into XML specific and compoent model?
- // 2. Call post validators
- // validateTypes(descElement.getTypesElement(), errorReporter);
-// Description descComponent = descElement.getDescriptionComponent();
-// validateInterfaces(descComponent.getInterfaces(), errorReporter);
-//
- // TODO: validate bindings, services, and extension elements
-
- return isValid;
- }
-
- /**
- * Validate the contents of the types element. This method runs the assertion
- * tests for inline and imported types.
- *
- * @param types The types element of which to validate the contents.
- * @param errorReporter The error reporter.
- * @return True if all the types related assertions pass, false otherwise.
- * @throws WSDLException
- */
- protected boolean validateTypes(TypesElement types, ErrorReporter errorReporter) throws WSDLException
- {
- boolean isValid = true;
-
- // If there is no types element all types assertions are true.
- if(types == null)
- return true;
-
- // Test imported schema assertions.
- ImportedSchema[] importedSchemas = types.getImportedSchemas();
- int numImportedSchemas = importedSchemas.length;
- for(int i = 0; i < numImportedSchemas; i++)
- {
- ImportedSchema schema = (ImportedSchema)importedSchemas[i];
-
- if(!testAssertionSchema1069(schema, errorReporter))
- isValid = false;
-
- if(!testAssertionSchema1070(schema, errorReporter))
- isValid = false;
-
- }
-
- // Test inlined schema assertions.
- InlinedSchema[] inlinedSchemas = types.getInlinedSchemas();
- if(!testAssertionSchema1073(inlinedSchemas, errorReporter))
- isValid = false;
- return isValid;
- }
-
- /**
- * Validate the contents of the interface element. This method runs the assertion
- * tests for interface element components.
- *
- * @param interfaces An array of interface elements for which to validate the contents.
- * @param errorReporter The error reporter.
- * @return True if all the interface related assertions pass, false otherwise.
- * @throws WSDLException
- */
- protected boolean validateInterfaces(DescriptionElement descElement, InterfaceElement[] interfaces, ErrorReporter errorReporter) throws WSDLException
- {
- boolean isValid = true;
-
- int numInterfaceElements = interfaces.length;
- for(int i = 0; i < numInterfaceElements; i++)
- {
- InterfaceElement interfaceElem = interfaces[i];
-
- if(!testAssertionInterface1012(interfaceElem, errorReporter))
- isValid = false;
-
- if(!validateInterfaceFaults(descElement, interfaceElem.getInterfaceFaultElements(), errorReporter))
- isValid = false;
-
- if(!validateInterfaceOperations(descElement, interfaceElem.getInterfaceOperationElements(), errorReporter))
- isValid = false;
- }
-
- return isValid;
- }
-
- /**
- * Validate the InterfaceFault elements.
- *
- * @param descElement The root description element.
- * @param faultElements An array of fault elements.
- * @param errorReporter An error reporter.
- * @return True if the interface fault elements are all valid, false otherwise.
- * @throws WSDLException
- */
- protected boolean validateInterfaceFaults(DescriptionElement descElement, InterfaceFaultElement[] faultElements, ErrorReporter errorReporter) throws WSDLException
- {
- boolean isValid = true;
- int numFaultElements = faultElements.length;
- for(int j = 0; j < numFaultElements; j++)
- {
- InterfaceFaultElement faultElement = faultElements[j];
- if(!testAssertionSchema1066(descElement, faultElement.getElementName(), errorReporter))
- isValid = false;
- }
- return isValid;
- }
-
- /**
- * Validate the InterfaceOperation elements.
- *
- * @param descElement The root description element.
- * @param interfaceOperations An array of interface operation elements.
- * @param errorReporter An error reporter.
- * @return True if the interface operation elements are all valid, false otherwise.
- * @throws WSDLException
- */
- protected boolean validateInterfaceOperations(DescriptionElement descElement, InterfaceOperationElement[] interfaceOperations, ErrorReporter errorReporter) throws WSDLException
- {
- boolean isValid = true;
- int numInterfaceOperations = interfaceOperations.length;
- for(int j = 0; j < numInterfaceOperations; j++)
- {
- InterfaceOperationElement interfaceOperation = interfaceOperations[j];
-
- if(!validateInterfaceMessageReferences(descElement, interfaceOperation.getInterfaceMessageReferenceElements(), errorReporter))
- isValid = false;
- }
- return isValid;
- }
-
- /**
- * Validate the InterfaceMessageReference elements.
- *
- * @param descElement The root description element.
- * @param messageReferences An array of interface message reference elements.
- * @param errorReporter An error reporter.
- * @return True if the interface message reference elements are all valid, false otherwise.
- * @throws WSDLException
- */
- protected boolean validateInterfaceMessageReferences(DescriptionElement descElement, InterfaceMessageReferenceElement[] messageReferences, ErrorReporter errorReporter) throws WSDLException
- {
- boolean isValid = true;
- //WODEN-149 removed assertion Schema-0020 from this method. InterfaceMessageReference assertions to be implemented.
- return isValid;
- }
-
- /**
- * Test assertion Description-1006. Tests whether the target namespace
- * specified is an absolute IRI.
- *
- * @param descElement The description element for which to check the target namespace.
- * @param errorReporter The error reporter.
- * @return True if the assertion passes, false otherwise.
- * @throws WSDLException
- */
- protected boolean testAssertionDescription1006(DescriptionElement descElement, ErrorReporter errorReporter) throws WSDLException
- {
- URI targetNS = descElement.getTargetNamespace();
- if(!targetNS.isAbsolute())
- {
- errorReporter.reportError(new ErrorLocatorImpl(), "Description-1006", new Object[]{targetNS}, ErrorReporter.SEVERITY_ERROR);
- return false;
- }
- return true;
- }
-
- /**
- * Test assertion Schema-1069. An imported schema must contain a
- * target namespace.
- *
- * @param schema The imported schema to check.
- * @param errorReporter The error reporter.
- * @return True if the assertion passes, false otherwise.
- * @throws WSDLException
- */
- protected boolean testAssertionSchema1069(ImportedSchema schema, ErrorReporter errorReporter) throws WSDLException
- {
- XmlSchema schemaDef = schema.getSchemaDefinition();
- // The assertion is true if the schema definition is not available.
- // Problems locating the schema will be reported elseware and are
- // not part of this assertion.
- if(schemaDef == null)
- return true;
-
- String targetNS = schemaDef.getTargetNamespace();
- if(targetNS == null || targetNS.equals(""))
- {
- errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1069", new Object[]{schema.getSchemaLocation()}, ErrorReporter.SEVERITY_ERROR);
- return false;
- }
- return true;
- }
-
- /**
- * Test assertion Schema-1070. An imported schema must specify the
- * same target namespace as the import element.
- *
- * @param schema The imported schema to check.
- * @param errorReporter The error reporter.
- * @return True if the assertion passes, false otherwise.
- * @throws WSDLException
- */
- protected boolean testAssertionSchema1070(ImportedSchema schema, ErrorReporter errorReporter) throws WSDLException
- {
- XmlSchema schemaDef = schema.getSchemaDefinition();
- // The assertion is true if the schema definition is not available.
- // Problems locating the schema will be reported elseware and are
- // not part of this assertion.
- if(schemaDef == null)
- return true;
-
- String importedSchemaTargetNS = schemaDef.getTargetNamespace();
- String specifiedTargetNS = schema.getNamespace().toString();
- if(specifiedTargetNS != null && !specifiedTargetNS.equals(importedSchemaTargetNS))
- {
- errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1070", new Object[]{specifiedTargetNS}, ErrorReporter.SEVERITY_ERROR);
- return false;
- }
- return true;
- }
-
- /**
- * Test assertion Schema-1073. Inlined XML Schemas must not define
- * an element that has already been defined by another inline schema
- * with the same target namespace.
- *
- * @param schema An array containing all the inline schemas in the order in which they are defined.
- * @param errorReporter The error reporter.
- * @return True if the assertion passes, false otherwise.
- * @throws WSDLException
- */
- protected boolean testAssertionSchema1073(InlinedSchema[] schema, ErrorReporter errorReporter) throws WSDLException
- {
- boolean isValid = true;
- int numInlineSchemas = schema.length;
- Hashtable schemas = new Hashtable();
- for(int i = 0; i < numInlineSchemas; i++)
- {
- InlinedSchema iSchema = schema[i];
- URI iSchemaNs = iSchema.getNamespace();
- // If the namespace isn't defined this assertion doesn't apply.
- if(iSchemaNs == null)
- continue;
- String ns = iSchemaNs.toString();
-
- if(schemas.containsKey(ns))
- {
- List schemaList = (List)schemas.get(ns);
- XmlSchemaObjectTable elements = iSchema.getSchemaDefinition().getElements();
- Iterator elementNames = elements.getNames();
- while(elementNames.hasNext())
- {
- QName elementName = (QName)elementNames.next();
- Iterator otherInlineSchemas = schemaList.iterator();
- while(otherInlineSchemas.hasNext())
- {
- if(((InlinedSchema)otherInlineSchemas.next()).getSchemaDefinition().getElementByName(elementName) != null)
- {
- // Duplicate element defined.
- errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1073", new Object[]{elementName, ns}, ErrorReporter.SEVERITY_ERROR);
- isValid = false;
- }
- }
-
- }
-
- XmlSchemaObjectTable types = iSchema.getSchemaDefinition().getSchemaTypes();
- Iterator typeNames = types.getNames();
- while(typeNames.hasNext())
- {
- QName typeName = (QName)typeNames.next();
- Iterator otherInlineSchemas = schemaList.iterator();
- while(otherInlineSchemas.hasNext())
- {
- if(((InlinedSchema)otherInlineSchemas.next()).getSchemaDefinition().getTypeByName(typeName) != null)
- {
- // Duplicate type defined.
- errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1073b", new Object[]{typeName, ns}, ErrorReporter.SEVERITY_ERROR);
- isValid = false;
- }
- }
-
- }
- //Check if another element has been defined.
- //check if another type has been defined.
- //add to the existing list of schemas
- schemaList.add(iSchema);
- }
- else
- {
- List schemaList = new ArrayList();
- schemaList.add(iSchema);
- schemas.put(ns, schemaList);
- }
-
- }
- return isValid;
- }
-
- /**
- * Test assertion Interface-1012. All style defaults specified on an interface
- * element must be absolute.
- *
- * @param interfaceElem The interface element to check the style default list.
- * @param errorReporter The error reporter.
- * @return True if the assertion passes, false otherwise.
- * @throws WSDLException
- */
- protected boolean testAssertionInterface1012(InterfaceElement interfaceElem, ErrorReporter errorReporter) throws WSDLException
- {
- boolean isValid = true;
-
- URI[] styleDefaults = interfaceElem.getStyleDefault();
- int numStyleDefaults = styleDefaults.length;
- for(int i = 0; i < numStyleDefaults; i++)
- {
- if(!styleDefaults[i].isAbsolute())
- {
- errorReporter.reportError(new ErrorLocatorImpl(), "Interface-1012", new Object[]{styleDefaults[i].toString()}, ErrorReporter.SEVERITY_ERROR);
- isValid = false;
- }
- }
- return isValid;
- }
-
- /**
- * Test assertion Schema-1066. References to XML schema components must only refer
- * to elements and types in namespaces that have been imported or inlined or that
- * are part of the XML schema namespace.
- *
- * @param descElement The description element of the document.
- * @param namespace Check this namespace to see if it has been defined.
- * @param errorReporter The error Reporter.
- * @return True if the assertion passes, false otherwise.
- * @throws WSDLException
- */
- protected boolean testAssertionSchema1066(DescriptionElement descElement, QName qualifiedName, ErrorReporter errorReporter) throws WSDLException
- {
- // If the qualifiedName is null it can't be checked.
- if(qualifiedName != null && !qualifiedName.getNamespaceURI().equals(Constants.TYPE_XSD_2001))
- {
- //Get the namespace and the local name from the qualified name.
- String namespace = qualifiedName.getNamespaceURI();
- String localname = qualifiedName.getLocalPart();
-
- TypesElement types = descElement.getTypesElement();
- if(types == null)
- {
- errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1066", new Object[]{localname, namespace}, ErrorReporter.SEVERITY_ERROR);
- return false;
- }
- Schema[] schemas = types.getSchemas();
- int numSchemas = schemas.length;
- boolean schemaNotFound = true;
- // TODO: This linear search should be improved for performance.
- for(int i = 0; i < numSchemas; i++)
- {
- URI schemaNs = schemas[i].getNamespace();
- // If the schema namespace is null continue to the next one. This is not the
- // schema we're looking for.
- if(schemaNs == null)
- continue;
- if(schemaNs.toString().equals(namespace))
- {
- schemaNotFound = false;
- break;
- }
- }
- if(schemaNotFound)
- {
- errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1066", new Object[]{localname, namespace}, ErrorReporter.SEVERITY_ERROR);
- return false;
- }
- }
- return true;
- }
-}
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.internal.wsdl20.validation;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.internal.wsdl20.Constants;
+import org.apache.woden.schema.ImportedSchema;
+import org.apache.woden.schema.InlinedSchema;
+import org.apache.woden.schema.Schema;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.ImportElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.InterfaceFaultElement;
+import org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
+import org.apache.woden.wsdl20.xml.TypesElement;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObjectTable;
+
+/**
+ * The WSDL document validator validates a WSDL XML model against the
+ * document assertions specified in the WSDL 2.0 specification.
+ */
+public class WSDLDocumentValidator
+{
+ /**
+ * Validate the document representation of the WSDL document against
+ * the WSDL 2.0 specification.
+ *
+ * @param descElement The WSDL 2.0 XML model description element.
+ * @param errorReporter The error reporter to use for any errors.
+ * @return True if the WSDL document representation is valid, false otherwise.
+ * @throws WSDLException
+ */
+ public boolean validate(DescriptionElement descElement, ErrorReporter errorReporter) throws WSDLException
+ {
+ boolean isValid = true;
+
+ // Test the description element.
+ isValid = testAssertionDescription1006(descElement, errorReporter);
+
+ // Test the import elements.
+ ImportElement[] imports = descElement.getImportElements();
+ int numImports = imports.length;
+ for(int i = 0; i < numImports; i++)
+ {
+ // TODO: Implement methods once import elements are supported.
+// if(!testAssertionImport0001(imports[i], errorReporter))
+// isValid = false;
+// if(!testAssertionImport0003(imports[i], errorReporter))
+// isValid = false;
+ }
+ if(!validateTypes(descElement.getTypesElement(), errorReporter))
+ isValid = false;
+
+ if(!validateInterfaces(descElement, descElement.getInterfaceElements(), errorReporter))
+ isValid = false;
+
+ // 1. Call the validators for specific namespaces
+ // - Does this need to be broken up into XML specific and compoent model?
+ // 2. Call post validators
+ // validateTypes(descElement.getTypesElement(), errorReporter);
+// Description descComponent = descElement.getDescriptionComponent();
+// validateInterfaces(descComponent.getInterfaces(), errorReporter);
+//
+ // TODO: validate bindings, services, and extension elements
+
+ return isValid;
+ }
+
+ /**
+ * Validate the contents of the types element. This method runs the assertion
+ * tests for inline and imported types.
+ *
+ * @param types The types element of which to validate the contents.
+ * @param errorReporter The error reporter.
+ * @return True if all the types related assertions pass, false otherwise.
+ * @throws WSDLException
+ */
+ protected boolean validateTypes(TypesElement types, ErrorReporter errorReporter) throws WSDLException
+ {
+ boolean isValid = true;
+
+ // If there is no types element all types assertions are true.
+ if(types == null)
+ return true;
+
+ // Test imported schema assertions.
+ ImportedSchema[] importedSchemas = types.getImportedSchemas();
+ int numImportedSchemas = importedSchemas.length;
+ for(int i = 0; i < numImportedSchemas; i++)
+ {
+ ImportedSchema schema = (ImportedSchema)importedSchemas[i];
+
+ if(!testAssertionSchema1069(schema, errorReporter))
+ isValid = false;
+
+ if(!testAssertionSchema1070(schema, errorReporter))
+ isValid = false;
+
+ }
+
+ // Test inlined schema assertions.
+ InlinedSchema[] inlinedSchemas = types.getInlinedSchemas();
+ if(!testAssertionSchema1073(inlinedSchemas, errorReporter))
+ isValid = false;
+ return isValid;
+ }
+
+ /**
+ * Validate the contents of the interface element. This method runs the assertion
+ * tests for interface element components.
+ *
+ * @param interfaces An array of interface elements for which to validate the contents.
+ * @param errorReporter The error reporter.
+ * @return True if all the interface related assertions pass, false otherwise.
+ * @throws WSDLException
+ */
+ protected boolean validateInterfaces(DescriptionElement descElement, InterfaceElement[] interfaces, ErrorReporter errorReporter) throws WSDLException
+ {
+ boolean isValid = true;
+
+ int numInterfaceElements = interfaces.length;
+ for(int i = 0; i < numInterfaceElements; i++)
+ {
+ InterfaceElement interfaceElem = interfaces[i];
+
+ if(!testAssertionInterface1012(interfaceElem, errorReporter))
+ isValid = false;
+
+ if(!validateInterfaceFaults(descElement, interfaceElem.getInterfaceFaultElements(), errorReporter))
+ isValid = false;
+
+ if(!validateInterfaceOperations(descElement, interfaceElem.getInterfaceOperationElements(), errorReporter))
+ isValid = false;
+ }
+
+ return isValid;
+ }
+
+ /**
+ * Validate the InterfaceFault elements.
+ *
+ * @param descElement The root description element.
+ * @param faultElements An array of fault elements.
+ * @param errorReporter An error reporter.
+ * @return True if the interface fault elements are all valid, false otherwise.
+ * @throws WSDLException
+ */
+ protected boolean validateInterfaceFaults(DescriptionElement descElement, InterfaceFaultElement[] faultElements, ErrorReporter errorReporter) throws WSDLException
+ {
+ boolean isValid = true;
+ int numFaultElements = faultElements.length;
+ for(int j = 0; j < numFaultElements; j++)
+ {
+ InterfaceFaultElement faultElement = faultElements[j];
+ if(!testAssertionSchema1066(descElement, faultElement.getElementName(), errorReporter))
+ isValid = false;
+ }
+ return isValid;
+ }
+
+ /**
+ * Validate the InterfaceOperation elements.
+ *
+ * @param descElement The root description element.
+ * @param interfaceOperations An array of interface operation elements.
+ * @param errorReporter An error reporter.
+ * @return True if the interface operation elements are all valid, false otherwise.
+ * @throws WSDLException
+ */
+ protected boolean validateInterfaceOperations(DescriptionElement descElement, InterfaceOperationElement[] interfaceOperations, ErrorReporter errorReporter) throws WSDLException
+ {
+ boolean isValid = true;
+ int numInterfaceOperations = interfaceOperations.length;
+ for(int j = 0; j < numInterfaceOperations; j++)
+ {
+ InterfaceOperationElement interfaceOperation = interfaceOperations[j];
+
+ if(!validateInterfaceMessageReferences(descElement, interfaceOperation.getInterfaceMessageReferenceElements(), errorReporter))
+ isValid = false;
+ }
+ return isValid;
+ }
+
+ /**
+ * Validate the InterfaceMessageReference elements.
+ *
+ * @param descElement The root description element.
+ * @param messageReferences An array of interface message reference elements.
+ * @param errorReporter An error reporter.
+ * @return True if the interface message reference elements are all valid, false otherwise.
+ * @throws WSDLException
+ */
+ protected boolean validateInterfaceMessageReferences(DescriptionElement descElement, InterfaceMessageReferenceElement[] messageReferences, ErrorReporter errorReporter) throws WSDLException
+ {
+ boolean isValid = true;
+ //WODEN-149 removed assertion Schema-0020 from this method. InterfaceMessageReference assertions to be implemented.
+ return isValid;
+ }
+
+ /**
+ * Test assertion Description-1006. Tests whether the target namespace
+ * specified is an absolute IRI.
+ *
+ * @param descElement The description element for which to check the target namespace.
+ * @param errorReporter The error reporter.
+ * @return True if the assertion passes, false otherwise.
+ * @throws WSDLException
+ */
+ protected boolean testAssertionDescription1006(DescriptionElement descElement, ErrorReporter errorReporter) throws WSDLException
+ {
+ URI targetNS = descElement.getTargetNamespace();
+ if(!targetNS.isAbsolute())
+ {
+ errorReporter.reportError(new ErrorLocatorImpl(), "Description-1006", new Object[]{targetNS}, ErrorReporter.SEVERITY_ERROR);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Test assertion Schema-1069. An imported schema must contain a
+ * target namespace.
+ *
+ * @param schema The imported schema to check.
+ * @param errorReporter The error reporter.
+ * @return True if the assertion passes, false otherwise.
+ * @throws WSDLException
+ */
+ protected boolean testAssertionSchema1069(ImportedSchema schema, ErrorReporter errorReporter) throws WSDLException
+ {
+ XmlSchema schemaDef = schema.getSchemaDefinition();
+ // The assertion is true if the schema definition is not available.
+ // Problems locating the schema will be reported elseware and are
+ // not part of this assertion.
+ if(schemaDef == null)
+ return true;
+
+ String targetNS = schemaDef.getTargetNamespace();
+ if(targetNS == null || targetNS.equals(""))
+ {
+ errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1069", new Object[]{schema.getSchemaLocation()}, ErrorReporter.SEVERITY_ERROR);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Test assertion Schema-1070. An imported schema must specify the
+ * same target namespace as the import element.
+ *
+ * @param schema The imported schema to check.
+ * @param errorReporter The error reporter.
+ * @return True if the assertion passes, false otherwise.
+ * @throws WSDLException
+ */
+ protected boolean testAssertionSchema1070(ImportedSchema schema, ErrorReporter errorReporter) throws WSDLException
+ {
+ XmlSchema schemaDef = schema.getSchemaDefinition();
+ // The assertion is true if the schema definition is not available.
+ // Problems locating the schema will be reported elseware and are
+ // not part of this assertion.
+ if(schemaDef == null)
+ return true;
+
+ String importedSchemaTargetNS = schemaDef.getTargetNamespace();
+ String specifiedTargetNS = schema.getNamespace().toString();
+ if(specifiedTargetNS != null && !specifiedTargetNS.equals(importedSchemaTargetNS))
+ {
+ errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1070", new Object[]{specifiedTargetNS}, ErrorReporter.SEVERITY_ERROR);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Test assertion Schema-1073. Inlined XML Schemas must not define
+ * an element that has already been defined by another inline schema
+ * with the same target namespace.
+ *
+ * @param schema An array containing all the inline schemas in the order in which they are defined.
+ * @param errorReporter The error reporter.
+ * @return True if the assertion passes, false otherwise.
+ * @throws WSDLException
+ */
+ protected boolean testAssertionSchema1073(InlinedSchema[] schema, ErrorReporter errorReporter) throws WSDLException
+ {
+ boolean isValid = true;
+ int numInlineSchemas = schema.length;
+ Hashtable schemas = new Hashtable();
+ for(int i = 0; i < numInlineSchemas; i++)
+ {
+ InlinedSchema iSchema = schema[i];
+ URI iSchemaNs = iSchema.getNamespace();
+ // If the namespace isn't defined this assertion doesn't apply.
+ if(iSchemaNs == null)
+ continue;
+ String ns = iSchemaNs.toString();
+
+ if(schemas.containsKey(ns))
+ {
+ List schemaList = (List)schemas.get(ns);
+ XmlSchemaObjectTable elements = iSchema.getSchemaDefinition().getElements();
+ Iterator elementNames = elements.getNames();
+ while(elementNames.hasNext())
+ {
+ QName elementName = (QName)elementNames.next();
+ Iterator otherInlineSchemas = schemaList.iterator();
+ while(otherInlineSchemas.hasNext())
+ {
+ if(((InlinedSchema)otherInlineSchemas.next()).getSchemaDefinition().getElementByName(elementName) != null)
+ {
+ // Duplicate element defined.
+ errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1073", new Object[]{elementName, ns}, ErrorReporter.SEVERITY_ERROR);
+ isValid = false;
+ }
+ }
+
+ }
+
+ XmlSchemaObjectTable types = iSchema.getSchemaDefinition().getSchemaTypes();
+ Iterator typeNames = types.getNames();
+ while(typeNames.hasNext())
+ {
+ QName typeName = (QName)typeNames.next();
+ Iterator otherInlineSchemas = schemaList.iterator();
+ while(otherInlineSchemas.hasNext())
+ {
+ if(((InlinedSchema)otherInlineSchemas.next()).getSchemaDefinition().getTypeByName(typeName) != null)
+ {
+ // Duplicate type defined.
+ errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1073b", new Object[]{typeName, ns}, ErrorReporter.SEVERITY_ERROR);
+ isValid = false;
+ }
+ }
+
+ }
+ //Check if another element has been defined.
+ //check if another type has been defined.
+ //add to the existing list of schemas
+ schemaList.add(iSchema);
+ }
+ else
+ {
+ List schemaList = new ArrayList();
+ schemaList.add(iSchema);
+ schemas.put(ns, schemaList);
+ }
+
+ }
+ return isValid;
+ }
+
+ /**
+ * Test assertion Interface-1012. All style defaults specified on an interface
+ * element must be absolute.
+ *
+ * @param interfaceElem The interface element to check the style default list.
+ * @param errorReporter The error reporter.
+ * @return True if the assertion passes, false otherwise.
+ * @throws WSDLException
+ */
+ protected boolean testAssertionInterface1012(InterfaceElement interfaceElem, ErrorReporter errorReporter) throws WSDLException
+ {
+ boolean isValid = true;
+
+ URI[] styleDefaults = interfaceElem.getStyleDefault();
+ int numStyleDefaults = styleDefaults.length;
+ for(int i = 0; i < numStyleDefaults; i++)
+ {
+ if(!styleDefaults[i].isAbsolute())
+ {
+ errorReporter.reportError(new ErrorLocatorImpl(), "Interface-1012", new Object[]{styleDefaults[i].toString()}, ErrorReporter.SEVERITY_ERROR);
+ isValid = false;
+ }
+ }
+ return isValid;
+ }
+
+ /**
+ * Test assertion Schema-1066. References to XML schema components must only refer
+ * to elements and types in namespaces that have been imported or inlined or that
+ * are part of the XML schema namespace.
+ *
+ * @param descElement The description element of the document.
+ * @param namespace Check this namespace to see if it has been defined.
+ * @param errorReporter The error Reporter.
+ * @return True if the assertion passes, false otherwise.
+ * @throws WSDLException
+ */
+ protected boolean testAssertionSchema1066(DescriptionElement descElement, QName qualifiedName, ErrorReporter errorReporter) throws WSDLException
+ {
+ // If the qualifiedName is null it can't be checked.
+ if(qualifiedName != null && !qualifiedName.getNamespaceURI().equals(Constants.TYPE_XSD_2001))
+ {
+ //Get the namespace and the local name from the qualified name.
+ String namespace = qualifiedName.getNamespaceURI();
+ String localname = qualifiedName.getLocalPart();
+
+ TypesElement types = descElement.getTypesElement();
+ if(types == null)
+ {
+ errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1066", new Object[]{localname, namespace}, ErrorReporter.SEVERITY_ERROR);
+ return false;
+ }
+ Schema[] schemas = types.getSchemas();
+ int numSchemas = schemas.length;
+ boolean schemaNotFound = true;
+ // TODO: This linear search should be improved for performance.
+ for(int i = 0; i < numSchemas; i++)
+ {
+ URI schemaNs = schemas[i].getNamespace();
+ // If the schema namespace is null continue to the next one. This is not the
+ // schema we're looking for.
+ if(schemaNs == null)
+ continue;
+ if(schemaNs.toString().equals(namespace))
+ {
+ schemaNotFound = false;
+ break;
+ }
+ }
+ if(schemaNotFound)
+ {
+ errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1066", new Object[]{localname, namespace}, ErrorReporter.SEVERITY_ERROR);
+ return false;
+ }
+ }
+ return true;
+ }
+}
Propchange: incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/xml/ArgumentArrayAttrImpl.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/xml/ArgumentArrayAttrImpl.java?rev=568932&r1=568931&r2=568932&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/xml/ArgumentArrayAttrImpl.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/xml/ArgumentArrayAttrImpl.java Thu Aug 23 04:01:23 2007
@@ -1,147 +1,147 @@
-/**
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.woden.internal.xml;
-
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.woden.ErrorReporter;
-import org.apache.woden.WSDLException;
-import org.apache.woden.XMLElement;
-import org.apache.woden.internal.ErrorLocatorImpl;
-import org.apache.woden.internal.util.StringUtils;
-import org.apache.woden.wsdl20.extensions.rpc.Argument;
-import org.apache.woden.wsdl20.extensions.rpc.Direction;
-import org.apache.woden.xml.ArgumentArrayAttr;
-
-/**
- * This class represents an XML attribute information items whose type is a list
- * of pairs (xs:QName, xs:token) that obey the contraints of wrpc:signature as
- * defined in Part 2 of the WSDL 2.0 spec.
- *
- * @author Arthur Ryman (ryman@ca.ibm.com)
- */
-
-public class ArgumentArrayAttrImpl extends XMLAttrImpl implements
- ArgumentArrayAttr {
-
- public ArgumentArrayAttrImpl(XMLElement ownerEl, QName attrType,
- String attrValue, ErrorReporter errRpt) throws WSDLException {
-
- super(ownerEl, attrType, attrValue, errRpt);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.woden.xml.ArgumentArrayAttr#getArgumentArray()
- */
- public Argument[] getArgumentArray() {
-
- return (Argument[]) getContent();
- }
-
- protected Object convert(XMLElement ownerEl, String attrValue)
- throws WSDLException {
-
- setValid(false);
-
- if (attrValue != null) {
-
- List tokens = StringUtils.parseNMTokens(attrValue);
- int length = tokens.size();
-
- // list consists of (qname, token) pairs
- if (length % 2 == 0) {
-
- int argc = length / 2;
- Argument[] args = new Argument[argc];
-
- Iterator i = tokens.iterator();
- for (int j = 0; j < argc; j++) {
-
- String qnameStr = (String) i.next();
- QName qname = convertQName(ownerEl, qnameStr);
- if (qname == null)
- return null;
-
- String directionStr = (String) i.next();
- Direction direction = convertDirection(directionStr);
- if (direction == null)
- return null;
-
- args[j] = new Argument(qname, direction);
- }
-
- setValid(true);
- return args;
- }
- }
-
- // TODO: line&col nos.
- // TODO: use correct error number
- getErrorReporter().reportError(new ErrorLocatorImpl(), "WSDL510",
- new Object[] { attrValue }, ErrorReporter.SEVERITY_ERROR,
- new IllegalArgumentException());
-
- return null;
- }
-
- private QName convertQName(XMLElement ownerEl, String qnameStr)
- throws WSDLException {
-
- QName qname = null;
-
- try {
- qname = ownerEl.getQName(qnameStr);
- } catch (WSDLException e) {
-
- // TODO: line&col nos.
- // TODO: use correct error number
- getErrorReporter().reportError(new ErrorLocatorImpl(), "WSDL510",
- new Object[] { qnameStr }, ErrorReporter.SEVERITY_ERROR, e);
- }
-
- return qname;
- }
-
- private Direction convertDirection(String directionStr)
- throws WSDLException {
-
- Direction[] directions = new Direction[] { Direction.IN,
- Direction.INOUT, Direction.OUT, Direction.RETURN };
-
- for (int i = 0; i < directions.length; i++) {
- if (directionStr.equals(directions[i].toString())) {
- return directions[i];
- }
- }
-
- // TODO: line&col nos.
- // TODO: use correct error number
- getErrorReporter().reportError(new ErrorLocatorImpl(), "WSDL510",
- new Object[] { directionStr }, ErrorReporter.SEVERITY_ERROR,
- new IllegalArgumentException());
-
- return null;
-
- }
-
-}
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.woden.internal.xml;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.XMLElement;
+import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.internal.util.StringUtils;
+import org.apache.woden.wsdl20.extensions.rpc.Argument;
+import org.apache.woden.wsdl20.extensions.rpc.Direction;
+import org.apache.woden.xml.ArgumentArrayAttr;
+
+/**
+ * This class represents an XML attribute information items whose type is a list
+ * of pairs (xs:QName, xs:token) that obey the contraints of wrpc:signature as
+ * defined in Part 2 of the WSDL 2.0 spec.
+ *
+ * @author Arthur Ryman (ryman@ca.ibm.com)
+ */
+
+public class ArgumentArrayAttrImpl extends XMLAttrImpl implements
+ ArgumentArrayAttr {
+
+ public ArgumentArrayAttrImpl(XMLElement ownerEl, QName attrType,
+ String attrValue, ErrorReporter errRpt) throws WSDLException {
+
+ super(ownerEl, attrType, attrValue, errRpt);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.woden.xml.ArgumentArrayAttr#getArgumentArray()
+ */
+ public Argument[] getArgumentArray() {
+
+ return (Argument[]) getContent();
+ }
+
+ protected Object convert(XMLElement ownerEl, String attrValue)
+ throws WSDLException {
+
+ setValid(false);
+
+ if (attrValue != null) {
+
+ List tokens = StringUtils.parseNMTokens(attrValue);
+ int length = tokens.size();
+
+ // list consists of (qname, token) pairs
+ if (length % 2 == 0) {
+
+ int argc = length / 2;
+ Argument[] args = new Argument[argc];
+
+ Iterator i = tokens.iterator();
+ for (int j = 0; j < argc; j++) {
+
+ String qnameStr = (String) i.next();
+ QName qname = convertQName(ownerEl, qnameStr);
+ if (qname == null)
+ return null;
+
+ String directionStr = (String) i.next();
+ Direction direction = convertDirection(directionStr);
+ if (direction == null)
+ return null;
+
+ args[j] = new Argument(qname, direction);
+ }
+
+ setValid(true);
+ return args;
+ }
+ }
+
+ // TODO: line&col nos.
+ // TODO: use correct error number
+ getErrorReporter().reportError(new ErrorLocatorImpl(), "WSDL510",
+ new Object[] { attrValue }, ErrorReporter.SEVERITY_ERROR,
+ new IllegalArgumentException());
+
+ return null;
+ }
+
+ private QName convertQName(XMLElement ownerEl, String qnameStr)
+ throws WSDLException {
+
+ QName qname = null;
+
+ try {
+ qname = ownerEl.getQName(qnameStr);
+ } catch (WSDLException e) {
+
+ // TODO: line&col nos.
+ // TODO: use correct error number
+ getErrorReporter().reportError(new ErrorLocatorImpl(), "WSDL510",
+ new Object[] { qnameStr }, ErrorReporter.SEVERITY_ERROR, e);
+ }
+
+ return qname;
+ }
+
+ private Direction convertDirection(String directionStr)
+ throws WSDLException {
+
+ Direction[] directions = new Direction[] { Direction.IN,
+ Direction.INOUT, Direction.OUT, Direction.RETURN };
+
+ for (int i = 0; i < directions.length; i++) {
+ if (directionStr.equals(directions[i].toString())) {
+ return directions[i];
+ }
+ }
+
+ // TODO: line&col nos.
+ // TODO: use correct error number
+ getErrorReporter().reportError(new ErrorLocatorImpl(), "WSDL510",
+ new Object[] { directionStr }, ErrorReporter.SEVERITY_ERROR,
+ new IllegalArgumentException());
+
+ return null;
+
+ }
+
+}
Propchange: incubator/woden/trunk/java/src/org/apache/woden/internal/xml/ArgumentArrayAttrImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/xml/BooleanAttrImpl.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/xml/BooleanAttrImpl.java?rev=568932&r1=568931&r2=568932&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/xml/BooleanAttrImpl.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/xml/BooleanAttrImpl.java Thu Aug 23 04:01:23 2007
@@ -1,78 +1,78 @@
-/**
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.woden.internal.xml;
-
-import javax.xml.namespace.QName;
-
-import org.apache.woden.ErrorReporter;
-import org.apache.woden.WSDLException;
-import org.apache.woden.XMLElement;
-import org.apache.woden.internal.ErrorLocatorImpl;
-import org.apache.woden.xml.BooleanAttr;
-
-/**
- * This class represents XML attribute information items of type xs:boolean.
- * If the attribute value is not "true" or "false" the Boolean content will
- * be initialized to "false" by default, but the isValid() method will
- * return "false".
- *
- * @author jkaputin@apache.org
- */
-public class BooleanAttrImpl extends XMLAttrImpl implements BooleanAttr
-{
- public BooleanAttrImpl(XMLElement ownerEl, QName attrType,
- String attrValue, ErrorReporter errRpt) throws WSDLException
- {
- super(ownerEl, attrType, attrValue, errRpt);
- }
-
- /* ************************************************************
- * BooleanAttr interface declared methods
- * ************************************************************/
-
- public Boolean getBoolean() {
- return (Boolean)getContent();
- }
-
- /* ************************************************************
- * Non-API implementation methods
- * ************************************************************/
-
- /*
- * Convert a string of type xs:boolean to a java.lang.Boolean.
- * An empty string or a null argument will initialize the Boolean to false.
- * Any conversion error will be reported and will initialize the Boolean to false.
- * If the attrValue does not match the Boolean value the Attr is marked invalid.
- */
- protected Object convert(XMLElement ownerEl, String attrValue) throws WSDLException
- {
- Boolean bool = Boolean.valueOf(attrValue);
-
- if(attrValue == null || !attrValue.equals(bool.toString()) )
- {
- setValid(false);
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL511",
- new Object[] {attrValue},
- ErrorReporter.SEVERITY_ERROR);
- }
-
- return bool;
- }
-
-}
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.internal.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.XMLElement;
+import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.xml.BooleanAttr;
+
+/**
+ * This class represents XML attribute information items of type xs:boolean.
+ * If the attribute value is not "true" or "false" the Boolean content will
+ * be initialized to "false" by default, but the isValid() method will
+ * return "false".
+ *
+ * @author jkaputin@apache.org
+ */
+public class BooleanAttrImpl extends XMLAttrImpl implements BooleanAttr
+{
+ public BooleanAttrImpl(XMLElement ownerEl, QName attrType,
+ String attrValue, ErrorReporter errRpt) throws WSDLException
+ {
+ super(ownerEl, attrType, attrValue, errRpt);
+ }
+
+ /* ************************************************************
+ * BooleanAttr interface declared methods
+ * ************************************************************/
+
+ public Boolean getBoolean() {
+ return (Boolean)getContent();
+ }
+
+ /* ************************************************************
+ * Non-API implementation methods
+ * ************************************************************/
+
+ /*
+ * Convert a string of type xs:boolean to a java.lang.Boolean.
+ * An empty string or a null argument will initialize the Boolean to false.
+ * Any conversion error will be reported and will initialize the Boolean to false.
+ * If the attrValue does not match the Boolean value the Attr is marked invalid.
+ */
+ protected Object convert(XMLElement ownerEl, String attrValue) throws WSDLException
+ {
+ Boolean bool = Boolean.valueOf(attrValue);
+
+ if(attrValue == null || !attrValue.equals(bool.toString()) )
+ {
+ setValid(false);
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), //TODO line&col nos.
+ "WSDL511",
+ new Object[] {attrValue},
+ ErrorReporter.SEVERITY_ERROR);
+ }
+
+ return bool;
+ }
+
+}
Propchange: incubator/woden/trunk/java/src/org/apache/woden/internal/xml/BooleanAttrImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/xml/HTTPAuthenticationSchemeAttrImpl.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/xml/HTTPAuthenticationSchemeAttrImpl.java?rev=568932&r1=568931&r2=568932&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/xml/HTTPAuthenticationSchemeAttrImpl.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/xml/HTTPAuthenticationSchemeAttrImpl.java Thu Aug 23 04:01:23 2007
@@ -1,94 +1,94 @@
-/**
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.woden.internal.xml;
-
-import javax.xml.namespace.QName;
-
-import org.apache.woden.ErrorReporter;
-import org.apache.woden.WSDLException;
-import org.apache.woden.XMLElement;
-import org.apache.woden.internal.ErrorLocatorImpl;
-import org.apache.woden.wsdl20.extensions.http.HTTPAuthenticationScheme;
-import org.apache.woden.xml.HTTPAuthenticationSchemeAttr;
-
-/**
- * This class implements the whttp:authenticationScheme attribute.
- *
- * @author Arthur Ryman (ryman@ca.ibm.com, arthur.ryman@gmail.com)
- *
- */
-public class HTTPAuthenticationSchemeAttrImpl extends XMLAttrImpl implements
- HTTPAuthenticationSchemeAttr {
-
- public HTTPAuthenticationSchemeAttrImpl(XMLElement ownerEl, QName attrType,
- String attrValue, ErrorReporter errRpt) throws WSDLException
- {
- super(ownerEl, attrType, attrValue, errRpt);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.woden.internal.xml.XMLAttrImpl#convert(org.w3c.dom.Element,
- * java.lang.String)
- */
- protected Object convert(XMLElement ownerEl, String attrValue)
- throws WSDLException {
-
- // TODO: define correct error numbers
-
- HTTPAuthenticationScheme scheme = null;
-
- if (attrValue == null) {
- setValid(false);
- getErrorReporter().reportError(new ErrorLocatorImpl(), // TODO
- // line&col
- // nos.
- "WSDL508", new Object[] { attrValue },
- ErrorReporter.SEVERITY_ERROR);
- } else if (attrValue.equals(HTTPAuthenticationScheme.BASIC.toString())) {
-
- setValid(true);
- scheme = HTTPAuthenticationScheme.BASIC;
- } else if (attrValue.equals(HTTPAuthenticationScheme.DIGEST.toString())) {
-
- setValid(true);
- scheme = HTTPAuthenticationScheme.DIGEST;
- } else {
-
- setValid(false);
- getErrorReporter().reportError(new ErrorLocatorImpl(), // TODO
- // line&col
- // nos.
- "WSDL508", new Object[] { attrValue },
- ErrorReporter.SEVERITY_ERROR);
- }
-
- return scheme;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.woden.xml.HTTPAuthenticationSchemeAttr#getScheme()
- */
- public HTTPAuthenticationScheme getScheme() {
-
- return (HTTPAuthenticationScheme) getContent();
- }
-
-}
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.internal.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.XMLElement;
+import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.wsdl20.extensions.http.HTTPAuthenticationScheme;
+import org.apache.woden.xml.HTTPAuthenticationSchemeAttr;
+
+/**
+ * This class implements the whttp:authenticationScheme attribute.
+ *
+ * @author Arthur Ryman (ryman@ca.ibm.com, arthur.ryman@gmail.com)
+ *
+ */
+public class HTTPAuthenticationSchemeAttrImpl extends XMLAttrImpl implements
+ HTTPAuthenticationSchemeAttr {
+
+ public HTTPAuthenticationSchemeAttrImpl(XMLElement ownerEl, QName attrType,
+ String attrValue, ErrorReporter errRpt) throws WSDLException
+ {
+ super(ownerEl, attrType, attrValue, errRpt);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.woden.internal.xml.XMLAttrImpl#convert(org.w3c.dom.Element,
+ * java.lang.String)
+ */
+ protected Object convert(XMLElement ownerEl, String attrValue)
+ throws WSDLException {
+
+ // TODO: define correct error numbers
+
+ HTTPAuthenticationScheme scheme = null;
+
+ if (attrValue == null) {
+ setValid(false);
+ getErrorReporter().reportError(new ErrorLocatorImpl(), // TODO
+ // line&col
+ // nos.
+ "WSDL508", new Object[] { attrValue },
+ ErrorReporter.SEVERITY_ERROR);
+ } else if (attrValue.equals(HTTPAuthenticationScheme.BASIC.toString())) {
+
+ setValid(true);
+ scheme = HTTPAuthenticationScheme.BASIC;
+ } else if (attrValue.equals(HTTPAuthenticationScheme.DIGEST.toString())) {
+
+ setValid(true);
+ scheme = HTTPAuthenticationScheme.DIGEST;
+ } else {
+
+ setValid(false);
+ getErrorReporter().reportError(new ErrorLocatorImpl(), // TODO
+ // line&col
+ // nos.
+ "WSDL508", new Object[] { attrValue },
+ ErrorReporter.SEVERITY_ERROR);
+ }
+
+ return scheme;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.woden.xml.HTTPAuthenticationSchemeAttr#getScheme()
+ */
+ public HTTPAuthenticationScheme getScheme() {
+
+ return (HTTPAuthenticationScheme) getContent();
+ }
+
+}
Propchange: incubator/woden/trunk/java/src/org/apache/woden/internal/xml/HTTPAuthenticationSchemeAttrImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/xml/IntOrTokenAnyAttrImpl.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/xml/IntOrTokenAnyAttrImpl.java?rev=568932&r1=568931&r2=568932&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/xml/IntOrTokenAnyAttrImpl.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/xml/IntOrTokenAnyAttrImpl.java Thu Aug 23 04:01:23 2007
@@ -1,123 +1,123 @@
-/**
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.woden.internal.xml;
-
-import javax.xml.namespace.QName;
-
-import org.apache.woden.ErrorReporter;
-import org.apache.woden.WSDLException;
-import org.apache.woden.XMLElement;
-import org.apache.woden.internal.ErrorLocatorImpl;
-import org.apache.woden.xml.IntOrTokenAttr;
-
-/**
- * This class represents XML attribute information items of type
- * 'Union of xs:int, xs:token #any', for example the
- * whttp:code extension attribute of binding <fault>.
- *
- * @author jkaputin@apache.org
- */
-public class IntOrTokenAnyAttrImpl extends XMLAttrImpl implements IntOrTokenAttr
-{
-
- public IntOrTokenAnyAttrImpl(XMLElement ownerEl, QName attrType,
- String attrValue, ErrorReporter errRpt) throws WSDLException
- {
- super(ownerEl, attrType, attrValue, errRpt);
- }
-
- /* ************************************************************
- * QNameOrTokenAttr interface declared methods
- * ************************************************************/
-
- /* (non-Javadoc)
- * @see org.apache.woden.xml.IntOrTokenAttr#isInt()
- */
- public boolean isInt()
- {
- return getContent() instanceof Integer;
- }
-
- /* (non-Javadoc)
- * @see org.apache.woden.xml.IntOrTokenAttr#isToken()
- */
- public boolean isToken()
- {
- return !isInt() && isValid();
- }
-
- /* (non-Javadoc)
- * @see org.apache.woden.xml.IntOrTokenAttr#getInt()
- */
- public Integer getInt()
- {
- if(isInt()) {
- return (Integer)getContent();
- } else {
- return null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.woden.xml.IntOrTokenAttr#getToken()
- */
- public String getToken()
- {
- if(!isInt() && isValid()) {
- return (String)getContent();
- } else {
- return null;
- }
- }
-
- /* ************************************************************
- * Implementation of abstract method inherited from XmlAttrImpl
- * ************************************************************/
-
- /* (non-Javadoc)
- * @see org.apache.woden.internal.xml.XMLAttrImpl#convert(org.w3c.dom.Element, java.lang.String)
- *
- * Convert a string of type "Union of xs:int, xs:token #any" to a
- * java.lang.Integer or a String.
- * A null argument will return a null value.
- * Any conversion error will be reported and a null value will be returned.
- */
- protected Object convert(XMLElement ownerEl, String attrValue) throws WSDLException
- {
- //First, check if the attribute contains the xs:token '#any'.
- if("#any".equals(attrValue)) return attrValue;
-
- //Second, assume the attribute contains a xs:int value.
- Integer intVal = null;
- try
- {
- intVal = new Integer(attrValue);
- }
- catch (NumberFormatException e)
- {
- setValid(false);
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL512",
- new Object[] {attrValue},
- ErrorReporter.SEVERITY_ERROR,
- e);
- }
- return intVal;
- }
-
-}
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.internal.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.XMLElement;
+import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.xml.IntOrTokenAttr;
+
+/**
+ * This class represents XML attribute information items of type
+ * 'Union of xs:int, xs:token #any', for example the
+ * whttp:code extension attribute of binding <fault>.
+ *
+ * @author jkaputin@apache.org
+ */
+public class IntOrTokenAnyAttrImpl extends XMLAttrImpl implements IntOrTokenAttr
+{
+
+ public IntOrTokenAnyAttrImpl(XMLElement ownerEl, QName attrType,
+ String attrValue, ErrorReporter errRpt) throws WSDLException
+ {
+ super(ownerEl, attrType, attrValue, errRpt);
+ }
+
+ /* ************************************************************
+ * QNameOrTokenAttr interface declared methods
+ * ************************************************************/
+
+ /* (non-Javadoc)
+ * @see org.apache.woden.xml.IntOrTokenAttr#isInt()
+ */
+ public boolean isInt()
+ {
+ return getContent() instanceof Integer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.woden.xml.IntOrTokenAttr#isToken()
+ */
+ public boolean isToken()
+ {
+ return !isInt() && isValid();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.woden.xml.IntOrTokenAttr#getInt()
+ */
+ public Integer getInt()
+ {
+ if(isInt()) {
+ return (Integer)getContent();
+ } else {
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.woden.xml.IntOrTokenAttr#getToken()
+ */
+ public String getToken()
+ {
+ if(!isInt() && isValid()) {
+ return (String)getContent();
+ } else {
+ return null;
+ }
+ }
+
+ /* ************************************************************
+ * Implementation of abstract method inherited from XmlAttrImpl
+ * ************************************************************/
+
+ /* (non-Javadoc)
+ * @see org.apache.woden.internal.xml.XMLAttrImpl#convert(org.w3c.dom.Element, java.lang.String)
+ *
+ * Convert a string of type "Union of xs:int, xs:token #any" to a
+ * java.lang.Integer or a String.
+ * A null argument will return a null value.
+ * Any conversion error will be reported and a null value will be returned.
+ */
+ protected Object convert(XMLElement ownerEl, String attrValue) throws WSDLException
+ {
+ //First, check if the attribute contains the xs:token '#any'.
+ if("#any".equals(attrValue)) return attrValue;
+
+ //Second, assume the attribute contains a xs:int value.
+ Integer intVal = null;
+ try
+ {
+ intVal = new Integer(attrValue);
+ }
+ catch (NumberFormatException e)
+ {
+ setValid(false);
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), //TODO line&col nos.
+ "WSDL512",
+ new Object[] {attrValue},
+ ErrorReporter.SEVERITY_ERROR,
+ e);
+ }
+ return intVal;
+ }
+
+}
Propchange: incubator/woden/trunk/java/src/org/apache/woden/internal/xml/IntOrTokenAnyAttrImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/xml/QNameAttrImpl.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/xml/QNameAttrImpl.java?rev=568932&r1=568931&r2=568932&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/xml/QNameAttrImpl.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/xml/QNameAttrImpl.java Thu Aug 23 04:01:23 2007
@@ -1,88 +1,88 @@
-/**
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.woden.internal.xml;
-
-import javax.xml.namespace.QName;
-
-import org.apache.woden.ErrorReporter;
-import org.apache.woden.WSDLException;
-import org.apache.woden.XMLElement;
-import org.apache.woden.internal.ErrorLocatorImpl;
-import org.apache.woden.xml.QNameAttr;
-
-/**
- * This class represents XML attribute information items of type xs:QName.
- *
- * @author jkaputin@apache.org
- */
-public class QNameAttrImpl extends XMLAttrImpl implements QNameAttr
-{
- public QNameAttrImpl(XMLElement ownerEl, QName attrType,
- String attrValue, ErrorReporter errRpt) throws WSDLException
- {
- super(ownerEl, attrType, attrValue, errRpt);
- }
-
- /* ************************************************************
- * QNameAttr interface declared methods
- * ************************************************************/
-
- public QName getQName() {
- return (QName)getContent();
- }
-
- /* ************************************************************
- * Non-API implementation methods
- * ************************************************************/
-
- /*
- * Convert a string of type xs:QName to a java.xml.namespace.QName.
- * A a null argument will return a null value.
- * Any conversion error will be reported and a null value will be returned.
- */
- protected Object convert(XMLElement ownerEl, String attrValue) throws WSDLException
- {
- Exception ex = null;
- QName qn = null;
-
- if(attrValue != null)
- {
- try
- {
- qn = ownerEl.getQName(attrValue);
- }
- catch (WSDLException e)
- {
- ex = e;
- }
- }
-
- if(qn == null)
- {
- setValid(false);
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL507", //TODO chg to WSDL505 and test
- new Object[] {attrValue},
- ErrorReporter.SEVERITY_ERROR,
- ex);
- }
-
- return qn;
- }
-
-}
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.internal.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.XMLElement;
+import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.xml.QNameAttr;
+
+/**
+ * This class represents XML attribute information items of type xs:QName.
+ *
+ * @author jkaputin@apache.org
+ */
+public class QNameAttrImpl extends XMLAttrImpl implements QNameAttr
+{
+ public QNameAttrImpl(XMLElement ownerEl, QName attrType,
+ String attrValue, ErrorReporter errRpt) throws WSDLException
+ {
+ super(ownerEl, attrType, attrValue, errRpt);
+ }
+
+ /* ************************************************************
+ * QNameAttr interface declared methods
+ * ************************************************************/
+
+ public QName getQName() {
+ return (QName)getContent();
+ }
+
+ /* ************************************************************
+ * Non-API implementation methods
+ * ************************************************************/
+
+ /*
+ * Convert a string of type xs:QName to a java.xml.namespace.QName.
+ * A a null argument will return a null value.
+ * Any conversion error will be reported and a null value will be returned.
+ */
+ protected Object convert(XMLElement ownerEl, String attrValue) throws WSDLException
+ {
+ Exception ex = null;
+ QName qn = null;
+
+ if(attrValue != null)
+ {
+ try
+ {
+ qn = ownerEl.getQName(attrValue);
+ }
+ catch (WSDLException e)
+ {
+ ex = e;
+ }
+ }
+
+ if(qn == null)
+ {
+ setValid(false);
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), //TODO line&col nos.
+ "WSDL507", //TODO chg to WSDL505 and test
+ new Object[] {attrValue},
+ ErrorReporter.SEVERITY_ERROR,
+ ex);
+ }
+
+ return qn;
+ }
+
+}
Propchange: incubator/woden/trunk/java/src/org/apache/woden/internal/xml/QNameAttrImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/xml/QNameListAttrImpl.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/xml/QNameListAttrImpl.java?rev=568932&r1=568931&r2=568932&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/xml/QNameListAttrImpl.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/xml/QNameListAttrImpl.java Thu Aug 23 04:01:23 2007
@@ -1,110 +1,110 @@
-/**
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.woden.internal.xml;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import javax.xml.namespace.QName;
-
-import org.apache.woden.ErrorReporter;
-import org.apache.woden.WSDLException;
-import org.apache.woden.XMLElement;
-import org.apache.woden.internal.ErrorLocatorImpl;
-import org.apache.woden.internal.util.StringUtils;
-import org.apache.woden.xml.QNameListAttr;
-
-
-/**
- * This class represents XML attribute information items of type xs:list of QNames.
- *
- * @author jkaputin@apache.org
- */
-public class QNameListAttrImpl extends XMLAttrImpl implements QNameListAttr
-{
- public QNameListAttrImpl(XMLElement ownerEl, QName attrType,
- String attrValue, ErrorReporter errRpt) throws WSDLException
- {
- super(ownerEl, attrType, attrValue, errRpt);
- }
-
- /* ************************************************************
- * QNameAttr interface declared methods
- * ************************************************************/
-
- public QName[] getQNames() {
- return (QName[])getContent();
- }
-
- /* ************************************************************
- * Non-API implementation methods
- * ************************************************************/
-
- /*
- * Convert a string of type 'xs:list of QNames' to a java.xml.namespace.QName[].
- * A a null argument will return a null value.
- * If a QName string in the list causes a conversion error, it will be reported
- * and that QName will not appear in the array. Valid QName strings will still
- * be converted, but the object will be marked invalid. If no QName strings can
- * be converted, a null value will be returned.
- */
- protected Object convert(XMLElement ownerEl, String attrValue) throws WSDLException
- {
- if(attrValue == null || "".equals(attrValue))
- {
- setValid(false);
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL509",
- new Object[] {attrValue},
- ErrorReporter.SEVERITY_ERROR);
- return null;
- }
-
- List qnStrings = StringUtils.parseNMTokens(attrValue);
- Iterator i = qnStrings.iterator();
- String qnString;
- QName qname;
- List qnames = new Vector();
-
- while(i.hasNext())
- {
- qnString = (String)i.next();
- try
- {
- qname = ownerEl.getQName(qnString);
- }
- catch (WSDLException e)
- {
- setValid(false);
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL510",
- new Object[] {qnString, attrValue},
- ErrorReporter.SEVERITY_ERROR,
- e);
- continue;
- }
- qnames.add(qname);
- }
- QName[] qnArray = new QName[qnames.size()];
- qnames.toArray(qnArray);
- return qnArray;
- }
-
-}
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.internal.xml;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.XMLElement;
+import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.internal.util.StringUtils;
+import org.apache.woden.xml.QNameListAttr;
+
+
+/**
+ * This class represents XML attribute information items of type xs:list of QNames.
+ *
+ * @author jkaputin@apache.org
+ */
+public class QNameListAttrImpl extends XMLAttrImpl implements QNameListAttr
+{
+ public QNameListAttrImpl(XMLElement ownerEl, QName attrType,
+ String attrValue, ErrorReporter errRpt) throws WSDLException
+ {
+ super(ownerEl, attrType, attrValue, errRpt);
+ }
+
+ /* ************************************************************
+ * QNameAttr interface declared methods
+ * ************************************************************/
+
+ public QName[] getQNames() {
+ return (QName[])getContent();
+ }
+
+ /* ************************************************************
+ * Non-API implementation methods
+ * ************************************************************/
+
+ /*
+ * Convert a string of type 'xs:list of QNames' to a java.xml.namespace.QName[].
+ * A a null argument will return a null value.
+ * If a QName string in the list causes a conversion error, it will be reported
+ * and that QName will not appear in the array. Valid QName strings will still
+ * be converted, but the object will be marked invalid. If no QName strings can
+ * be converted, a null value will be returned.
+ */
+ protected Object convert(XMLElement ownerEl, String attrValue) throws WSDLException
+ {
+ if(attrValue == null || "".equals(attrValue))
+ {
+ setValid(false);
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), //TODO line&col nos.
+ "WSDL509",
+ new Object[] {attrValue},
+ ErrorReporter.SEVERITY_ERROR);
+ return null;
+ }
+
+ List qnStrings = StringUtils.parseNMTokens(attrValue);
+ Iterator i = qnStrings.iterator();
+ String qnString;
+ QName qname;
+ List qnames = new Vector();
+
+ while(i.hasNext())
+ {
+ qnString = (String)i.next();
+ try
+ {
+ qname = ownerEl.getQName(qnString);
+ }
+ catch (WSDLException e)
+ {
+ setValid(false);
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), //TODO line&col nos.
+ "WSDL510",
+ new Object[] {qnString, attrValue},
+ ErrorReporter.SEVERITY_ERROR,
+ e);
+ continue;
+ }
+ qnames.add(qname);
+ }
+ QName[] qnArray = new QName[qnames.size()];
+ qnames.toArray(qnArray);
+ return qnArray;
+ }
+
+}
Propchange: incubator/woden/trunk/java/src/org/apache/woden/internal/xml/QNameListAttrImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org