You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by aj...@apache.org on 2006/07/11 09:43:18 UTC
svn commit: r420752 - in /webservices/commons/trunk/modules/XmlSchema:
src/org/apache/ws/commons/schema/
src/org/apache/ws/commons/schema/constants/ test-resources/ test/tests/
Author: ajith
Date: Tue Jul 11 00:43:17 2006
New Revision: 420752
URL: http://svn.apache.org/viewvc?rev=420752&view=rev
Log:
1. Moved the block constants to an inner class inside the Constants class for clarity. Presence of multiple constant files is confusing!
2. Added functionality to populate a metadata map when external attributes are present. When external attributes are present they are populated as QName/value pairs into a map and stored in the metadata map under the key EXTERNAL_ATTRIBUTES (constant is Constants.MetaDataConstants.EXTERNAL_ATTRIBUTES)
3. Added a new test case and the relevant test case xsd file to test this functionality
Added:
webservices/commons/trunk/modules/XmlSchema/test-resources/externalAttributes.xsd
webservices/commons/trunk/modules/XmlSchema/test/tests/ExternalAttTest.java
Removed:
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/constants/BlockConstants.java
Modified:
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchema.java
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAny.java
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAnyAttribute.java
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAttribute.java
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaComplexType.java
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaContentProcessing.java
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaContentType.java
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaDerivationMethod.java
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaElement.java
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaSerializer.java
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaType.java
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaUse.java
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSeverityType.java
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/constants/Constants.java
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java?rev=420752&r1=420751&r2=420752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java Tue Jul 11 00:43:17 2006
@@ -27,7 +27,6 @@
import org.apache.ws.commons.schema.utils.XDOMUtil;
import org.apache.ws.commons.schema.utils.Tokenizer;
import org.apache.ws.commons.schema.constants.Constants;
-import org.apache.ws.commons.schema.constants.BlockConstants;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.namespace.QName;
@@ -42,17 +41,35 @@
XmlSchemaCollection collection;
DocumentBuilderFactory docFac;
+ public static final String XMLNS_PREFIX = "xmlns";
+ /**
+ * Schema builder constructor
+ * @param collection
+ */
SchemaBuilder(XmlSchemaCollection collection) {
this.collection = collection;
schema = new XmlSchema(collection);
}
+ /**
+ * build method taking in a document and a validation handler
+ * @param doc
+ * @param uri
+ * @param veh
+ * @return
+ */
XmlSchema build(Document doc, String uri, ValidationEventHandler veh) {
Element schemaEl = doc.getDocumentElement();
return handleXmlSchemaElement(schemaEl, uri);
}
+ /**
+ * handles the schema element
+ * @param schemaEl
+ * @param uri
+ * @return
+ */
XmlSchema handleXmlSchemaElement(Element schemaEl, String uri) {
// get all the attributes along with the namespace declns
@@ -76,6 +93,9 @@
schema.setFinalDefault(this.getDerivation(schemaEl, "finalDefault"));
schema.setSourceURI(uri);
+ //add the extesibility components
+ processExtensibilityComponents(schema,schemaEl);
+
/***********
* for ( each childElement)
* if( simpleTypeElement)
@@ -127,6 +147,7 @@
el, schemaEl);
schema.includes.add(include);
schema.items.add(include);
+
} else if (el.getLocalName().equals("import")) {
XmlSchemaImport schemaImport = handleImport(schema,
el, schemaEl);
@@ -204,8 +225,8 @@
}
Element annotationEl =
- XDOMUtil.getFirstChildElementNS(notationEl,
- XmlSchema.SCHEMA_NS, "annotation");
+ XDOMUtil.getFirstChildElementNS(notationEl,
+ XmlSchema.SCHEMA_NS, "annotation");
if (annotationEl != null) {
XmlSchemaAnnotation annotation = handleAnnotation(annotationEl);
@@ -279,7 +300,7 @@
if (map.item(i).getNodeValue().equals(XmlSchema.SCHEMA_NS))
schema.schema_ns_prefix = map.item(i).getLocalName();
- } else if (map.item(i).getNodeName().startsWith("xmlns")) {
+ } else if (map.item(i).getNodeName().startsWith(XMLNS_PREFIX)) {
schema.namespaces.put("", map.item(i).getNodeValue());
}
}
@@ -294,19 +315,26 @@
if (!contain.equals(""))
schema.targetNamespace = contain;
} else {
- //do nothing here
+ //do nothing here
}
}
private void putNamespace(String prefix, String namespace) {
while(schema.namespaces.containsKey(prefix)){
- prefix = "gen" +
+ prefix = "gen" +
new java.util.Random().nextInt(999);
}
schema.namespaces.put(prefix, namespace);
}
+ /**
+ * Handles simple types
+ * @param schema
+ * @param simpleEl
+ * @param schemaEl
+ * @return
+ */
XmlSchemaSimpleType handleSimpleType(XmlSchema schema,
Element simpleEl, Element schemaEl) {
@@ -321,7 +349,7 @@
if (finalstr.equalsIgnoreCase("all") |
finalstr.equalsIgnoreCase("#all"))
- simpleType.setFinal(new XmlSchemaDerivationMethod(BlockConstants.ALL));
+ simpleType.setFinal(new XmlSchemaDerivationMethod(Constants.BlockConstants.ALL));
else
simpleType.setFinal(new XmlSchemaDerivationMethod(finalstr));
}
@@ -543,9 +571,20 @@
}
simpleType.content = union;
}
+
+ //process extra attributes and elements
+ processExtensibilityComponents(simpleType,schemaEl);
+
return simpleType;
}
+ /**
+ * Handle complex types
+ * @param schema
+ * @param complexEl
+ * @param schemaEl
+ * @return
+ */
XmlSchemaComplexType handleComplexType(XmlSchema schema,
Element complexEl, Element schemaEl) {
@@ -649,7 +688,7 @@
if (blockStr.equalsIgnoreCase("all") |
blockStr.equalsIgnoreCase("#all")) {
- ct.setBlock(new XmlSchemaDerivationMethod(BlockConstants.ALL));
+ ct.setBlock(new XmlSchemaDerivationMethod(Constants.BlockConstants.ALL));
} else
ct.setBlock(new XmlSchemaDerivationMethod(blockStr));
//ct.setBlock(new XmlSchemaDerivationMethod(block));
@@ -659,7 +698,7 @@
if (finalstr.equalsIgnoreCase("all") |
finalstr.equalsIgnoreCase("#all")) {
- ct.setFinal(new XmlSchemaDerivationMethod(BlockConstants.ALL));
+ ct.setFinal(new XmlSchemaDerivationMethod(Constants.BlockConstants.ALL));
} else
ct.setFinal(new XmlSchemaDerivationMethod(finalstr));
}
@@ -677,6 +716,10 @@
else
ct.setMixed(false);
}
+
+ //process extra attributes and elements
+ processExtensibilityComponents(ct,schemaEl);
+
return ct;
}
@@ -1418,7 +1461,7 @@
return attr;
}
- /********
+ /*
* handle_simple_content_restriction
*
* if( restriction has base attribute )
@@ -1428,7 +1471,7 @@
* add facets if any to the restriction
*/
- /*********
+ /*
* handle_simple_content_extension
*
* extension should have a base name and cannot have any inline defn
@@ -1441,10 +1484,18 @@
* handleAnyAttribute
*/
- /**
+ /*
* ********
* handle_complex_content_restriction
*/
+ /**
+ * handle elements
+ * @param schema
+ * @param el
+ * @param schemaEl
+ * @param isGlobal
+ * @return
+ */
XmlSchemaElement handleElement(XmlSchema schema,
Element el,
Element schemaEl,
@@ -1638,7 +1689,7 @@
Object result = findNamespaceForPrefix(args[0],schema);
if (result == null) {
throw new XmlSchemaException("No namespace found in"
- + "given substitionGroup");
+ + "given substitionGroup");
}
namespace = result.toString();
} else {
@@ -1650,6 +1701,10 @@
element.minOccurs = getMinOccurs(el);
element.maxOccurs = getMaxOccurs(el);
+
+ //process extra attributes and elements
+ processExtensibilityComponents(element,schemaEl);
+
return element;
}
@@ -1684,7 +1739,7 @@
if (namespaceFromEl.length > 1) {
Object result =
findNamespaceForPrefix(namespaceFromEl[0],
- schema);
+ schema);
if (result == null)
throw new XmlSchemaException("No namespace found in "
+ "given base simple content type");
@@ -1787,6 +1842,13 @@
return schemaImport;
}
+ /**
+ * Handles the include
+ * @param schema
+ * @param includeEl
+ * @param schemaEl
+ * @return
+ */
XmlSchemaInclude handleInclude(XmlSchema schema,
Element includeEl, Element schemaEl) {
@@ -1822,13 +1884,16 @@
include.schemaLocation);
}
XmlSchemaObjectCollection coll = include.schema.getItems();
-
+ //process extra attributes and elements
+ processExtensibilityComponents(include,schemaEl);
return include;
}
/**
+ * Handles the annotation
* Traversing if encounter appinfo or documentation
* add it to annotation collection
+ *
*/
XmlSchemaAnnotation handleAnnotation(Element annotEl) {
XmlSchemaObjectCollection content = new XmlSchemaObjectCollection();
@@ -1855,17 +1920,26 @@
docsObj = handleDocumentation(documentation);
if (docsObj != null) {
- content.add(docsObj);
+ content.add(docsObj);
}
}
XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();
annotation.items = content;
+
+ //process extra attributes and elements
+ processExtensibilityComponents(annotation,annotEl);
return annotation;
}
- //create new XmlSchemaAppinfo and add value goten from element
- //to this obj
+
+
+ /**
+ * create new XmlSchemaAppinfo and add value goten from element
+ * to this obj
+ * @param content
+ * @return
+ */
XmlSchemaAppInfo handleAppInfo(Element content) {
XmlSchemaAppInfo appInfo = new XmlSchemaAppInfo();
NodeList markup = getChild(content);
@@ -1916,7 +1990,7 @@
if (value.equals("unbounded"))
return Long.MAX_VALUE;
else
- return new Long(value).longValue();
+ return Long.parseLong(value);
}
return 1;
} catch (java.lang.NumberFormatException e) {
@@ -1931,7 +2005,7 @@
if (value.equals("unbounded"))
return Long.MAX_VALUE;
else
- return new Long(value).longValue();
+ return Long.parseLong(value);
}
return 1;
} catch (java.lang.NumberFormatException e) {
@@ -1955,11 +2029,11 @@
//#all | List of (extension | restriction | substitution
String derivationMethod = el.getAttribute(attrName).trim();
if (derivationMethod.equals("#all"))
- return new XmlSchemaDerivationMethod(BlockConstants.ALL);
+ return new XmlSchemaDerivationMethod(Constants.BlockConstants.ALL);
else
return new XmlSchemaDerivationMethod(derivationMethod);
}
- return new XmlSchemaDerivationMethod(BlockConstants.NONE);
+ return new XmlSchemaDerivationMethod(Constants.BlockConstants.NONE);
}
//Check value entered by user and change according to .net spec, user
@@ -1967,7 +2041,7 @@
if (el.hasAttribute(attrName)) {
return el.getAttribute(attrName).trim();
}
- return BlockConstants.NONE;
+ return Constants.BlockConstants.NONE;
}
/**
@@ -1982,12 +2056,12 @@
//use the entity resolver provided
XmlSchema schema = null;
InputSource source = collection.schemaResolver.
- resolveEntity(targetNamespace,schemaLocation,baseUri);
-
+ resolveEntity(targetNamespace,schemaLocation,baseUri);
+
if (source.getSystemId() != null) {
schema = collection.getXmlSchema(source.getSystemId());
}
-
+
if (schema == null) {
try {
return collection.read(source, null);
@@ -1995,7 +2069,7 @@
throw new RuntimeException(e);
}
}
-
+
return schema;
}
@@ -2028,5 +2102,41 @@
}
+ /**
+ * A generic method to process the extra attributes and the the extra
+ * elements present within the schema.
+ * What it does right now is to attach extra attributes to a map
+ * having QName/value pairs and store the map in the metadata section
+ * of the schema object
+ * @param schemaObject
+ * @param elt
+ */
+ private void processExtensibilityComponents(XmlSchemaObject schemaObject,Element elt){
+ Map attribMap = new HashMap();
+ NamedNodeMap attributes = elt.getAttributes();
+ for (int i=0 ;i < attributes.getLength();i++){
+ Attr attribute = (Attr)attributes.item(i);
+
+ String namespaceURI = attribute.getNamespaceURI();
+ String name = attribute.getName();
+
+ if (namespaceURI!= null &&
+ !"".equals(namespaceURI) && //ignore unqualified attributes
+ !name.startsWith(XMLNS_PREFIX) && //ignore namespaces
+ !Constants.URI_2001_SCHEMA_XSD.equals(namespaceURI)){
+ attribMap.put(new QName(namespaceURI,name),
+ attribute.getValue());
+ }
+ }
+
+ if (!attribMap.isEmpty()){
+ schemaObject.addMetaInfo(
+ Constants.MetaDataConstants.EXTERNAL_ATTRIBUTES,
+ attribMap
+ );
+
+ }
+
+ }
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchema.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchema.java?rev=420752&r1=420751&r2=420752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchema.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchema.java Tue Jul 11 00:43:17 2006
@@ -17,7 +17,7 @@
package org.apache.ws.commons.schema;
import org.w3c.dom.Document;
-import org.apache.ws.commons.schema.constants.BlockConstants;
+import org.apache.ws.commons.schema.constants.Constants;
import javax.xml.namespace.QName;
import javax.xml.transform.OutputKeys;
@@ -73,8 +73,8 @@
this.parent = parent;
attributeFormDefault = new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
elementFormDefault = new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
- blockDefault = new XmlSchemaDerivationMethod(BlockConstants.NONE);
- finalDefault = new XmlSchemaDerivationMethod(BlockConstants.NONE);
+ blockDefault = new XmlSchemaDerivationMethod(Constants.BlockConstants.NONE);
+ finalDefault = new XmlSchemaDerivationMethod(Constants.BlockConstants.NONE);
items = new XmlSchemaObjectCollection();
includes = new XmlSchemaObjectCollection();
namespaces = new Hashtable();
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAny.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAny.java?rev=420752&r1=420751&r2=420752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAny.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAny.java Tue Jul 11 00:43:17 2006
@@ -16,7 +16,7 @@
package org.apache.ws.commons.schema;
-import org.apache.ws.commons.schema.constants.BlockConstants;
+import org.apache.ws.commons.schema.constants.Constants;
/**
* Enables any element from the specified namespace or namespaces
@@ -30,7 +30,7 @@
* Creates new XmlSchemaAny
*/
public XmlSchemaAny() {
- processContent = new XmlSchemaContentProcessing(BlockConstants.NONE);
+ processContent = new XmlSchemaContentProcessing(Constants.BlockConstants.NONE);
}
/**
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAnyAttribute.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAnyAttribute.java?rev=420752&r1=420751&r2=420752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAnyAttribute.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAnyAttribute.java Tue Jul 11 00:43:17 2006
@@ -16,7 +16,7 @@
package org.apache.ws.commons.schema;
-import org.apache.ws.commons.schema.constants.BlockConstants;
+import org.apache.ws.commons.schema.constants.Constants;
/**
* Enables any attribute from the specified namespace or namespaces
@@ -30,7 +30,7 @@
*/
public XmlSchemaAnyAttribute() {
processContent = new XmlSchemaContentProcessing(
- BlockConstants.NONE);
+ Constants.BlockConstants.NONE);
}
String namespace;
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAttribute.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAttribute.java?rev=420752&r1=420751&r2=420752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAttribute.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAttribute.java Tue Jul 11 00:43:17 2006
@@ -16,7 +16,7 @@
package org.apache.ws.commons.schema;
-import org.apache.ws.commons.schema.constants.BlockConstants;
+import org.apache.ws.commons.schema.constants.Constants;
import javax.xml.namespace.QName;
@@ -41,7 +41,7 @@
*/
public XmlSchemaAttribute() {
form = new XmlSchemaForm(XmlSchemaForm.NONE);
- use = new XmlSchemaUse(BlockConstants.NONE);
+ use = new XmlSchemaUse(Constants.BlockConstants.NONE);
}
public Object getAttributeType() {
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaComplexType.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaComplexType.java?rev=420752&r1=420751&r2=420752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaComplexType.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaComplexType.java Tue Jul 11 00:43:17 2006
@@ -16,7 +16,7 @@
package org.apache.ws.commons.schema;
-import org.apache.ws.commons.schema.constants.BlockConstants;
+import org.apache.ws.commons.schema.constants.Constants;
/**
* Class for complex types. Defines a complex type that determines the
@@ -40,7 +40,7 @@
public XmlSchemaComplexType(XmlSchema schema) {
super(schema);
attributes = new XmlSchemaObjectCollection();
- block = new XmlSchemaDerivationMethod(BlockConstants.NONE);
+ block = new XmlSchemaDerivationMethod(Constants.BlockConstants.NONE);
isAbstract = false;
isMixed = false;
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaContentProcessing.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaContentProcessing.java?rev=420752&r1=420751&r2=420752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaContentProcessing.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaContentProcessing.java Tue Jul 11 00:43:17 2006
@@ -16,7 +16,7 @@
package org.apache.ws.commons.schema;
-import org.apache.ws.commons.schema.constants.BlockConstants;
+import org.apache.ws.commons.schema.constants.Constants;
/**
* Provides information about the validation mode of any
@@ -26,10 +26,10 @@
public class XmlSchemaContentProcessing extends org.apache.ws.commons.schema.constants.Enum {
static String[] members = new String[]{
- BlockConstants.LAX,
- BlockConstants.NONE,
- BlockConstants.SKIP,
- BlockConstants.STRICT
+ Constants.BlockConstants.LAX,
+ Constants.BlockConstants.NONE,
+ Constants.BlockConstants.SKIP,
+ Constants.BlockConstants.STRICT
};
/**
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaContentType.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaContentType.java?rev=420752&r1=420751&r2=420752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaContentType.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaContentType.java Tue Jul 11 00:43:17 2006
@@ -17,7 +17,7 @@
package org.apache.ws.commons.schema;
import org.apache.ws.commons.schema.constants.Enum;
-import org.apache.ws.commons.schema.constants.BlockConstants;
+import org.apache.ws.commons.schema.constants.Constants;
/**
* Enumerations for the content model of the complex type. This
@@ -27,10 +27,10 @@
public class XmlSchemaContentType extends Enum {
static String[] members = new String[]{
- BlockConstants.ELEMENT_ONLY,
- BlockConstants.EMPTY,
- BlockConstants.MIXED,
- BlockConstants.TEXT_ONLY};
+ Constants.BlockConstants.ELEMENT_ONLY,
+ Constants.BlockConstants.EMPTY,
+ Constants.BlockConstants.MIXED,
+ Constants.BlockConstants.TEXT_ONLY};
/**
* Creates new XmlSchemaContentType
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaDerivationMethod.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaDerivationMethod.java?rev=420752&r1=420751&r2=420752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaDerivationMethod.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaDerivationMethod.java Tue Jul 11 00:43:17 2006
@@ -16,21 +16,21 @@
package org.apache.ws.commons.schema;
-import org.apache.ws.commons.schema.constants.BlockConstants;
+import org.apache.ws.commons.schema.constants.Constants;
/**
* Provides different methods for preventing derivation.
*/
public class XmlSchemaDerivationMethod extends org.apache.ws.commons.schema.constants.Enum {
static String[] members = new String[]{
- BlockConstants.ALL,
- BlockConstants.EMPTY,
- BlockConstants.EXTENSION,
- BlockConstants.LIST,
- BlockConstants.NONE,
- BlockConstants.RESTRICTION,
- BlockConstants.SUBSITUTION,
- BlockConstants.UNION};
+ Constants.BlockConstants.ALL,
+ Constants.BlockConstants.EMPTY,
+ Constants.BlockConstants.EXTENSION,
+ Constants.BlockConstants.LIST,
+ Constants.BlockConstants.NONE,
+ Constants.BlockConstants.RESTRICTION,
+ Constants.BlockConstants.SUBSITUTION,
+ Constants.BlockConstants.UNION};
/**
* Creates new XmlSeverityType
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaElement.java?rev=420752&r1=420751&r2=420752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaElement.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaElement.java Tue Jul 11 00:43:17 2006
@@ -16,7 +16,7 @@
package org.apache.ws.commons.schema;
-import org.apache.ws.commons.schema.constants.BlockConstants;
+import org.apache.ws.commons.schema.constants.Constants;
import javax.xml.namespace.QName;
@@ -91,8 +91,8 @@
isAbstract = false;
isNillable = false;
form = new XmlSchemaForm(XmlSchemaForm.NONE);
- finalDerivation = new XmlSchemaDerivationMethod(BlockConstants.NONE);
- block = new XmlSchemaDerivationMethod(BlockConstants.NONE);
+ finalDerivation = new XmlSchemaDerivationMethod(Constants.BlockConstants.NONE);
+ block = new XmlSchemaDerivationMethod(Constants.BlockConstants.NONE);
}
/**
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaSerializer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaSerializer.java?rev=420752&r1=420751&r2=420752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaSerializer.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaSerializer.java Tue Jul 11 00:43:17 2006
@@ -23,7 +23,7 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
-import org.apache.ws.commons.schema.constants.BlockConstants;
+import org.apache.ws.commons.schema.constants.Constants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -136,14 +136,14 @@
}
if (schemaObj.blockDefault != null) {
String blockDefault = schemaObj.blockDefault.getValue();
- if (!blockDefault.equals(BlockConstants.NONE)) {
+ if (!blockDefault.equals(Constants.BlockConstants.NONE)) {
blockDefault = convertString(blockDefault);
serializedSchema.setAttribute("blockDefault", blockDefault);
}
}
if (schemaObj.finalDefault != null) {
String finalDefault = schemaObj.finalDefault.getValue();
- if (!finalDefault.equals(BlockConstants.NONE)) {
+ if (!finalDefault.equals(Constants.BlockConstants.NONE)) {
finalDefault = convertString(finalDefault);
serializedSchema.setAttribute("finalDefault", finalDefault);
}
@@ -519,7 +519,7 @@
serializedEl.setAttribute("abstract", "true");
String block = elementObj.block.getValue();
- if (!block.equals(BlockConstants.NONE)) {
+ if (!block.equals(Constants.BlockConstants.NONE)) {
block = convertString(block);
serializedEl.setAttribute("block", block);
}
@@ -528,7 +528,7 @@
elementObj.defaultValue);
String finalDerivation = elementObj.finalDerivation.getValue();
- if (!finalDerivation.equals(BlockConstants.NONE)) {
+ if (!finalDerivation.equals(Constants.BlockConstants.NONE)) {
finalDerivation = convertString(finalDerivation);
serializedEl.setAttribute("final",
finalDerivation);
@@ -647,7 +647,7 @@
String tmp;
tmp = simpleTypeObj.finalDerivation.getValue();
- if (!tmp.equals(BlockConstants.NONE)) {
+ if (!tmp.equals(Constants.BlockConstants.NONE)) {
tmp = convertString(tmp);
serializedSimpleType.setAttribute("final", tmp);
@@ -919,13 +919,13 @@
}
String block = complexTypeObj.block.getValue();
- if (!block.equals(BlockConstants.NONE)) {
+ if (!block.equals(Constants.BlockConstants.NONE)) {
block = convertString(block);
serializedComplexType.setAttribute(
"block", block);
}
String finalDerivation = complexTypeObj.finalDerivation.getValue();
- if (!finalDerivation.equals(BlockConstants.NONE)) {
+ if (!finalDerivation.equals(Constants.BlockConstants.NONE)) {
finalDerivation = convertString(finalDerivation);
serializedComplexType.setAttribute("final",
finalDerivation);
@@ -1061,7 +1061,7 @@
attribute.setAttribute("id", attributeObj.id);
String useType = attributeObj.use.getValue();
- if (!useType.equals(BlockConstants.NONE)) {
+ if (!useType.equals(Constants.BlockConstants.NONE)) {
useType = convertString(useType);
attribute.setAttribute("use", useType);
}
@@ -1424,7 +1424,7 @@
if (anyObj.processContent != null) {
String value = anyObj.processContent.getValue();
- if (!value.equals(BlockConstants.NONE)) {
+ if (!value.equals(Constants.BlockConstants.NONE)) {
String processContent = convertString(value);
anyEl.setAttribute("processContents",
processContent);
@@ -2501,7 +2501,7 @@
//Convert given string to lower case or w3c standard
private String convertString(String convert) {
String input = convert.trim();
- if (input.equals(BlockConstants.ALL)) {
+ if (input.equals(Constants.BlockConstants.ALL)) {
return "#all";
} else
return input.toLowerCase();
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaType.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaType.java?rev=420752&r1=420751&r2=420752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaType.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaType.java Tue Jul 11 00:43:17 2006
@@ -16,7 +16,7 @@
package org.apache.ws.commons.schema;
-import org.apache.ws.commons.schema.constants.BlockConstants;
+import org.apache.ws.commons.schema.constants.Constants;
import javax.xml.namespace.QName;
@@ -42,7 +42,7 @@
*/
public XmlSchemaType(XmlSchema schema) {
this.schema = schema;
- finalDerivation = new XmlSchemaDerivationMethod(BlockConstants.NONE);
+ finalDerivation = new XmlSchemaDerivationMethod(Constants.BlockConstants.NONE);
}
public Object getBaseSchemaType() {
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaUse.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaUse.java?rev=420752&r1=420751&r2=420752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaUse.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaUse.java Tue Jul 11 00:43:17 2006
@@ -16,7 +16,7 @@
package org.apache.ws.commons.schema;
-import org.apache.ws.commons.schema.constants.BlockConstants;
+import org.apache.ws.commons.schema.constants.Constants;
/**
* Indicator of how the attribute is used.
@@ -24,10 +24,10 @@
public class XmlSchemaUse extends org.apache.ws.commons.schema.constants.Enum {
static String[] members = new String[]{
- BlockConstants.NONE,
- BlockConstants.OPTIONAL,
- BlockConstants.PROHIBITED,
- BlockConstants.REQUIRED
+ Constants.BlockConstants.NONE,
+ Constants.BlockConstants.OPTIONAL,
+ Constants.BlockConstants.PROHIBITED,
+ Constants.BlockConstants.REQUIRED
};
/**
* Creates new XmlSchemaUse
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSeverityType.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSeverityType.java?rev=420752&r1=420751&r2=420752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSeverityType.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSeverityType.java Tue Jul 11 00:43:17 2006
@@ -17,7 +17,7 @@
package org.apache.ws.commons.schema;
import org.apache.ws.commons.schema.constants.Enum;
-import org.apache.ws.commons.schema.constants.BlockConstants;
+import org.apache.ws.commons.schema.constants.Constants;
/**
* Represents the severity of the validation event.
@@ -26,8 +26,8 @@
public class XmlSeverityType extends Enum {
static String[] members = new String[]{
- BlockConstants.ERROR,
- BlockConstants.WARNING
+ Constants.BlockConstants.ERROR,
+ Constants.BlockConstants.WARNING
};
/**
Modified: webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/constants/Constants.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/constants/Constants.java?rev=420752&r1=420751&r2=420752&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/constants/Constants.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/constants/Constants.java Tue Jul 11 00:43:17 2006
@@ -89,4 +89,38 @@
public static final QName XSD_LANGUAGE = new QName(URI_2001_SCHEMA_XSD, "language");
public static final QName XSD_ID = new QName(URI_2001_SCHEMA_XSD, "ID");
public static final QName XSD_SCHEMA = new QName(URI_2001_SCHEMA_XSD, "schema");
+
+ /**
+ * All constants that are relevant to the names of the
+ * schema elements
+ */
+ public static class BlockConstants {
+
+ public static final String ALL = "all";
+ public static final String NONE = "none";
+ public static final String EXTENSION = "extension";
+ public static final String LIST = "list";
+ public static final String RESTRICTION = "restriction";
+ public static final String SUBSITUTION = "substitution";
+ public static final String UNION = "union";
+ public static final String EMPTY = "empty";
+ public static final String ELEMENT_ONLY = "elementOnly";
+ public static final String MIXED = "mixed";
+ public static final String TEXT_ONLY = "textOnly";
+ public static final String LAX = "lax";
+ public static final String SKIP = "skip";
+ public static final String STRICT = "strict";
+ public static final String OPTIONAL = "optional";
+ public static final String PROHIBITED = "prohibited";
+ public static final String REQUIRED = "required";
+ public static final String ERROR = "error";
+ public static final String WARNING = "warning";
+ }
+
+ /**
+ * class holding the the constants for meta data storage
+ */
+ public static class MetaDataConstants{
+ public static final String EXTERNAL_ATTRIBUTES = "EXTERNAL_ATTRIBUTES";
+ }
}
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/externalAttributes.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test-resources/externalAttributes.xsd?rev=420752&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/externalAttributes.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/externalAttributes.xsd Tue Jul 11 00:43:17 2006
@@ -0,0 +1,20 @@
+<schema
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://unqualified-elements.example.com"
+ xmlns:test="http://test-namespace"
+ targetNamespace="http://unqualified-elements.example.com"
+ test:level="1">
+
+ <element name="AnyAttContainer" test:level="2">
+ <complexType>
+ <sequence>
+ <element name="chileValue" type="xsd:string"/>
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax"></anyAttribute>
+ </complexType>
+ </element>
+
+ <element name="global" type="xsd:int"/>
+
+</schema>
Added: webservices/commons/trunk/modules/XmlSchema/test/tests/ExternalAttTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test/tests/ExternalAttTest.java?rev=420752&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test/tests/ExternalAttTest.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/test/tests/ExternalAttTest.java Tue Jul 11 00:43:17 2006
@@ -0,0 +1,60 @@
+package tests;
+
+import junit.framework.TestCase;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaParticle;
+import org.apache.ws.commons.schema.XmlSchemaAnyAttribute;
+import org.apache.ws.commons.schema.constants.Constants;
+
+import java.util.Map;
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+public class ExternalAttTest extends TestCase {
+
+
+ public void testExternalAtt() throws Exception{
+ //create a DOM document
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ Document doc = documentBuilderFactory.newDocumentBuilder().
+ parse("test-resources/externalAttributes.xsd");
+
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema s = schemaCol.read(doc.getDocumentElement());
+
+ //check the meta data
+ Map metaInfoMap = s.getMetaInfoMap();
+ assertNotNull(metaInfoMap);
+
+ Map extenalAttributeMap = (Map)metaInfoMap.get(Constants.MetaDataConstants.EXTERNAL_ATTRIBUTES);
+ assertNotNull(extenalAttributeMap);
+
+ assertEquals(1,extenalAttributeMap.size());
+
+
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org