Author: ajith
Date: Fri Apr 21 00:45:47 2006
New Revision: 395806
URL: http://svn.apache.org/viewcvs?rev=395806&view=rev
Log:
1. Added a new constants class to keep the values like "any","lax" and so on
The original problem is wrongful content case (camelcase instead of
lowercase)
2. Fixed a serialization issue where anyAttribute was serialized before
attributes (which is invalid as per the schema spec)
3. Added two new test cases to test the new changes
Added:
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/constants/BlockConstants.java
webservices/commons/trunk/modules/XmlSchema/test-resources/block.xsd
webservices/commons/trunk/modules/XmlSchema/test-resources/mixedContent.xsd
webservices/commons/trunk/modules/XmlSchema/test/tests/BlockTest.java
webservices/commons/trunk/modules/XmlSchema/test/tests/MixedContentTest.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/test/tests/TestForwardRefs.java
Modified:
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java?rev=395806&r1=395805&r2=395806&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
Fri Apr 21 00:45:47 2006
@@ -25,6 +25,7 @@
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 org.xml.sax.InputSource;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -286,7 +287,7 @@
if (finalstr.equalsIgnoreCase("all") |
finalstr.equalsIgnoreCase("#all"))
- simpleType.setFinal(new XmlSchemaDerivationMethod("All"));
+ simpleType.setFinal(new
XmlSchemaDerivationMethod(BlockConstants.ALL));
else
simpleType.setFinal(new XmlSchemaDerivationMethod(finalstr));
}
@@ -613,7 +614,7 @@
if (blockStr.equalsIgnoreCase("all") |
blockStr.equalsIgnoreCase("#all")) {
- ct.setBlock(new XmlSchemaDerivationMethod("All"));
+ ct.setBlock(new XmlSchemaDerivationMethod(BlockConstants.ALL));
} else
ct.setBlock(new XmlSchemaDerivationMethod(blockStr));
//ct.setBlock(new XmlSchemaDerivationMethod(block));
@@ -623,7 +624,7 @@
if (finalstr.equalsIgnoreCase("all") |
finalstr.equalsIgnoreCase("#all")) {
- ct.setFinal(new XmlSchemaDerivationMethod("All"));
+ ct.setFinal(new XmlSchemaDerivationMethod(BlockConstants.ALL));
} else
ct.setFinal(new XmlSchemaDerivationMethod(finalstr));
}
@@ -1866,23 +1867,20 @@
if (el.hasAttribute(attrName) &&
!el.getAttribute(attrName).equals("")) {
//#all | List of (extension | restriction | substitution
String derivationMethod = el.getAttribute(attrName).trim();
- char c = Character.toUpperCase(derivationMethod.charAt(0));
if (derivationMethod.equals("#all"))
- return new XmlSchemaDerivationMethod("All");
+ return new XmlSchemaDerivationMethod(BlockConstants.ALL);
else
- return new XmlSchemaDerivationMethod(c +
derivationMethod.substring(1));
+ return new XmlSchemaDerivationMethod(derivationMethod);
}
- return new XmlSchemaDerivationMethod("None");
+ return new XmlSchemaDerivationMethod(BlockConstants.NONE);
}
//Check value entered by user and change according to .net spec, user
String getEnumString(Element el, String attrName) {
if (el.hasAttribute(attrName)) {
- String contentProcessing = el.getAttribute(attrName).trim();
- char c = Character.toUpperCase(contentProcessing.charAt(0));
- return c + contentProcessing.substring(1);
+ return el.getAttribute(attrName).trim();
}
- return "None";
+ return BlockConstants.NONE;
}
XmlSchema getXmlSchemaFromLocation(String schemaLocation) {
Modified:
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchema.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchema.java?rev=395806&r1=395805&r2=395806&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
Fri Apr 21 00:45:47 2006
@@ -17,6 +17,7 @@
package org.apache.ws.commons.schema;
import org.w3c.dom.Document;
+import org.apache.ws.commons.schema.constants.BlockConstants;
import javax.xml.namespace.QName;
import javax.xml.transform.OutputKeys;
@@ -74,8 +75,8 @@
this.parent = parent;
attributeFormDefault = new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
elementFormDefault = new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
- blockDefault = new XmlSchemaDerivationMethod("None");
- finalDefault = new XmlSchemaDerivationMethod("None");
+ blockDefault = new XmlSchemaDerivationMethod(BlockConstants.NONE);
+ finalDefault = new XmlSchemaDerivationMethod(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/viewcvs/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAny.java?rev=395806&r1=395805&r2=395806&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
Fri Apr 21 00:45:47 2006
@@ -16,6 +16,8 @@
package org.apache.ws.commons.schema;
+import org.apache.ws.commons.schema.constants.BlockConstants;
+
/**
* Enables any element from the specified namespace or namespaces
* to appear in the containing complexType element. Represents the
@@ -32,7 +34,7 @@
* Creates new XmlSchemaAny
*/
public XmlSchemaAny() {
- processContent = new XmlSchemaContentProcessing("None");
+ processContent = new XmlSchemaContentProcessing(BlockConstants.NONE);
}
/**
Modified:
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAnyAttribute.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAnyAttribute.java?rev=395806&r1=395805&r2=395806&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
Fri Apr 21 00:45:47 2006
@@ -16,6 +16,8 @@
package org.apache.ws.commons.schema;
+import org.apache.ws.commons.schema.constants.BlockConstants;
+
/**
* Enables any attribute from the specified namespace or namespaces
* to appear in the containing complexType element. Represents the
@@ -29,7 +31,8 @@
* Creates new XmlSchemaAnyAttribute
*/
public XmlSchemaAnyAttribute() {
- processContent = new XmlSchemaContentProcessing("None");
+ processContent = new XmlSchemaContentProcessing(
+ BlockConstants.NONE);
}
String namespace;
Modified:
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAttribute.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaAttribute.java?rev=395806&r1=395805&r2=395806&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
Fri Apr 21 00:45:47 2006
@@ -16,6 +16,8 @@
package org.apache.ws.commons.schema;
+import org.apache.ws.commons.schema.constants.BlockConstants;
+
import javax.xml.namespace.QName;
/**
@@ -41,7 +43,7 @@
*/
public XmlSchemaAttribute() {
form = new XmlSchemaForm(XmlSchemaForm.NONE);
- use = new XmlSchemaUse("None");
+ use = new XmlSchemaUse(BlockConstants.NONE);
}
public Object getAttributeType() {
Modified:
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaComplexType.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaComplexType.java?rev=395806&r1=395805&r2=395806&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
Fri Apr 21 00:45:47 2006
@@ -16,6 +16,8 @@
package org.apache.ws.commons.schema;
+import org.apache.ws.commons.schema.constants.BlockConstants;
+
/**
* Class for complex types. Defines a complex type that determines the
* set of attributes and content of an element. Represents the World Wide
@@ -40,7 +42,7 @@
public XmlSchemaComplexType(XmlSchema schema) {
super(schema);
attributes = new XmlSchemaObjectCollection();
- block = new XmlSchemaDerivationMethod("None");
+ block = new XmlSchemaDerivationMethod(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/viewcvs/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaContentProcessing.java?rev=395806&r1=395805&r2=395806&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
Fri Apr 21 00:45:47 2006
@@ -16,6 +16,8 @@
package org.apache.ws.commons.schema;
+import org.apache.ws.commons.schema.constants.BlockConstants;
+
/**
* Provides information about the validation mode of any
* and anyAttribute element replacements.
@@ -25,8 +27,12 @@
public class XmlSchemaContentProcessing extends
org.apache.ws.commons.schema.constants.Enum {
- static String[] members = new String[]{"Lax", "None",
- "Skip", "Strict"};
+ static String[] members = new String[]{
+ BlockConstants.LAX,
+ BlockConstants.NONE,
+ BlockConstants.SKIP,
+ BlockConstants.STRICT
+ };
/**
* Creates new XmlSeverityType
Modified:
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaContentType.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaContentType.java?rev=395806&r1=395805&r2=395806&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
Fri Apr 21 00:45:47 2006
@@ -17,6 +17,7 @@
package org.apache.ws.commons.schema;
import org.apache.ws.commons.schema.constants.Enum;
+import org.apache.ws.commons.schema.constants.BlockConstants;
/**
* Enumerations for the content model of the complex type. This
@@ -27,8 +28,11 @@
public class XmlSchemaContentType extends Enum {
- static String[] members = new String[]{"ElementOnly", "Empty",
- "Mixed", "TextOnly"};
+ static String[] members = new String[]{
+ BlockConstants.ELEMENT_ONLY,
+ BlockConstants.EMPTY,
+ BlockConstants.MIXED,
+ 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/viewcvs/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaDerivationMethod.java?rev=395806&r1=395805&r2=395806&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
Fri Apr 21 00:45:47 2006
@@ -16,6 +16,8 @@
package org.apache.ws.commons.schema;
+import org.apache.ws.commons.schema.constants.BlockConstants;
+
/**
* Provides different methods for preventing derivation.
*
@@ -23,9 +25,15 @@
*/
public class XmlSchemaDerivationMethod extends
org.apache.ws.commons.schema.constants.Enum {
- static String[] members = new String[]{"All", "Empty", "Extension",
- "List", "None", "Restriction",
- "Substitution", "Union"};
+ static String[] members = new String[]{
+ BlockConstants.ALL,
+ BlockConstants.EMPTY,
+ BlockConstants.EXTENSION,
+ BlockConstants.LIST,
+ BlockConstants.NONE,
+ BlockConstants.RESTRICTION,
+ BlockConstants.SUBSITUTION,
+ BlockConstants.UNION};
/**
* Creates new XmlSeverityType
Modified:
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaElement.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaElement.java?rev=395806&r1=395805&r2=395806&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
Fri Apr 21 00:45:47 2006
@@ -16,6 +16,8 @@
package org.apache.ws.commons.schema;
+import org.apache.ws.commons.schema.constants.BlockConstants;
+
import javax.xml.namespace.QName;
@@ -93,8 +95,8 @@
isAbstract = false;
isNillable = false;
form = new XmlSchemaForm(XmlSchemaForm.NONE);
- finalDerivation = new XmlSchemaDerivationMethod("None");
- block = new XmlSchemaDerivationMethod("None");
+ finalDerivation = new XmlSchemaDerivationMethod(BlockConstants.NONE);
+ block = new XmlSchemaDerivationMethod(BlockConstants.NONE);
}
/**
Modified:
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaSerializer.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaSerializer.java?rev=395806&r1=395805&r2=395806&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
Fri Apr 21 00:45:47 2006
@@ -23,6 +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 javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -135,14 +136,14 @@
}
if (schemaObj.blockDefault != null) {
String blockDefault = schemaObj.blockDefault.getValue();
- if (!blockDefault.equals("None")) {
+ if (!blockDefault.equals(BlockConstants.NONE)) {
blockDefault = convertString(blockDefault);
serializedSchema.setAttribute("blockDefault", blockDefault);
}
}
if (schemaObj.finalDefault != null) {
String finalDefault = schemaObj.finalDefault.getValue();
- if (!finalDefault.equals("None")) {
+ if (!finalDefault.equals(BlockConstants.NONE)) {
finalDefault = convertString(finalDefault);
serializedSchema.setAttribute("finalDefault", finalDefault);
}
@@ -507,7 +508,7 @@
serializedEl.setAttribute("abstract", "true");
String block = elementObj.block.getValue();
- if (!block.equals("None")) {
+ if (!block.equals(BlockConstants.NONE)) {
block = convertString(block);
serializedEl.setAttribute("block", block);
}
@@ -516,7 +517,7 @@
elementObj.defaultValue);
String finalDerivation = elementObj.finalDerivation.getValue();
- if (!finalDerivation.equals("None")) {
+ if (!finalDerivation.equals(BlockConstants.NONE)) {
finalDerivation = convertString(finalDerivation);
serializedEl.setAttribute("final",
finalDerivation);
@@ -632,7 +633,7 @@
String tmp;
tmp = simpleTypeObj.finalDerivation.getValue();
- if (!tmp.equals("None")) {
+ if (!tmp.equals(BlockConstants.NONE)) {
tmp = convertString(tmp);
serializedSimpleType.setAttribute("final", tmp);
@@ -904,13 +905,13 @@
}
String block = complexTypeObj.block.getValue();
- if (!block.equals("None")) {
+ if (!block.equals(BlockConstants.NONE)) {
block = convertString(block);
serializedComplexType.setAttribute(
"block", block);
}
String finalDerivation = complexTypeObj.finalDerivation.getValue();
- if (!finalDerivation.equals("None")) {
+ if (!finalDerivation.equals(BlockConstants.NONE)) {
finalDerivation = convertString(finalDerivation);
serializedComplexType.setAttribute("final",
finalDerivation);
@@ -1046,7 +1047,7 @@
attribute.setAttribute("id", attributeObj.id);
String useType = attributeObj.use.getValue();
- if (!useType.equals("None")) {
+ if (!useType.equals(BlockConstants.NONE)) {
useType = convertString(useType);
attribute.setAttribute("use", useType);
}
@@ -1409,7 +1410,7 @@
if (anyObj.processContent != null) {
String value = anyObj.processContent.getValue();
- if (!value.equals("None")) {
+ if (!value.equals(BlockConstants.NONE)) {
String processContent = convertString(value);
anyEl.setAttribute("processContents",
processContent);
@@ -2075,11 +2076,6 @@
extensionObj.annotation,
schema);
extension.appendChild(annotation);
}
- if (extensionObj.anyAttribute != null) {
- Element anyAttribute = serializeAnyAttribute(doc,
-
extensionObj.anyAttribute, schema);
- extension.appendChild(anyAttribute);
- }
XmlSchemaObjectCollection attributes = extensionObj.attributes;
int attributeLength = attributes.getCount();
@@ -2096,6 +2092,16 @@
extension.appendChild(attributeGroupRef);
}
}
+
+ /*
+ * anyAttribute must come *after* any other attributes
+ */
+ if (extensionObj.anyAttribute != null) {
+ Element anyAttribute = serializeAnyAttribute(doc,
+
extensionObj.anyAttribute, schema);
+ extension.appendChild(anyAttribute);
+ }
+
return extension;
}
@@ -2479,7 +2485,7 @@
//Convert given string to lower case or w3c standard
private String convertString(String convert) {
String input = convert.trim();
- if (input.equals("All")) {
+ if (input.equals(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/viewcvs/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaType.java?rev=395806&r1=395805&r2=395806&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
Fri Apr 21 00:45:47 2006
@@ -16,6 +16,8 @@
package org.apache.ws.commons.schema;
+import org.apache.ws.commons.schema.constants.BlockConstants;
+
import javax.xml.namespace.QName;
@@ -44,7 +46,7 @@
*/
public XmlSchemaType(XmlSchema schema) {
this.schema = schema;
- finalDerivation = new XmlSchemaDerivationMethod("None");
+ finalDerivation = new XmlSchemaDerivationMethod(BlockConstants.NONE);
}
public Object getBaseSchemaType() {
Modified:
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaUse.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaUse.java?rev=395806&r1=395805&r2=395806&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
Fri Apr 21 00:45:47 2006
@@ -16,6 +16,8 @@
package org.apache.ws.commons.schema;
+import org.apache.ws.commons.schema.constants.BlockConstants;
+
/**
* Indicator of how the attribute is used.
*
@@ -23,9 +25,12 @@
*/
public class XmlSchemaUse extends org.apache.ws.commons.schema.constants.Enum {
- static String[] members = new String[]{"None", "Optional",
- "Prohibited", "Required"};
-
+ static String[] members = new String[]{
+ BlockConstants.NONE,
+ BlockConstants.OPTIONAL,
+ BlockConstants.PROHIBITED,
+ BlockConstants.REQUIRED
+ };
/**
* Creates new XmlSchemaUse
*/
Modified:
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSeverityType.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSeverityType.java?rev=395806&r1=395805&r2=395806&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
Fri Apr 21 00:45:47 2006
@@ -17,6 +17,7 @@
package org.apache.ws.commons.schema;
import org.apache.ws.commons.schema.constants.Enum;
+import org.apache.ws.commons.schema.constants.BlockConstants;
/**
* Represents the severity of the validation event.
@@ -26,7 +27,10 @@
public class XmlSeverityType extends Enum {
- static String[] members = new String[]{"Error", "Warning"};
+ static String[] members = new String[]{
+ BlockConstants.ERROR,
+ BlockConstants.WARNING
+ };
/**
* Creates new XmlSeverityType
Added:
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/constants/BlockConstants.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/constants/BlockConstants.java?rev=395806&view=auto
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/constants/BlockConstants.java
(added)
+++
webservices/commons/trunk/modules/XmlSchema/src/org/apache/ws/commons/schema/constants/BlockConstants.java
Fri Apr 21 00:45:47 2006
@@ -0,0 +1,44 @@
+package org.apache.ws.commons.schema.constants;
+/*
+ * 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 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";
+
+
+}
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/block.xsd
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/test-resources/block.xsd?rev=395806&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/block.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/block.xsd Fri
Apr 21 00:45:47 2006
@@ -0,0 +1,16 @@
+<schema targetNamespace="http://soapinterop.org/xsd"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd1="http://soapinterop.org/xsd"
+ xmlns:xsd2="http://soapinterop.org/xsd2"
+ elementFormDefault="qualified">
+ <element name="complexElt" block="restriction">
+ <complexType>
+ <sequence>
+ <element name="name" type="string"/>
+ <element name="age" type="int"/>
+ </sequence>
+ </complexType>
+ </element>
+</schema>
\ No newline at end of file
Added:
webservices/commons/trunk/modules/XmlSchema/test-resources/mixedContent.xsd
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/test-resources/mixedContent.xsd?rev=395806&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/mixedContent.xsd
(added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/mixedContent.xsd
Fri Apr 21 00:45:47 2006
@@ -0,0 +1,16 @@
+<schema targetNamespace="http://soapinterop.org/xsd"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd1="http://soapinterop.org/xsd"
+ xmlns:xsd2="http://soapinterop.org/xsd2"
+ elementFormDefault="qualified">
+ <element name="complexElt">
+ <complexType mixed="true">
+ <sequence>
+ <element name="name" type="string"/>
+ <element name="age" type="int"/>
+ </sequence>
+ </complexType>
+ </element>
+</schema>
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test/tests/BlockTest.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/test/tests/BlockTest.java?rev=395806&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test/tests/BlockTest.java
(added)
+++ webservices/commons/trunk/modules/XmlSchema/test/tests/BlockTest.java Fri
Apr 21 00:45:47 2006
@@ -0,0 +1,47 @@
+package tests;
+
+import junit.framework.TestCase;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+import java.io.InputStream;
+import java.io.FileInputStream;
+
+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;
+/*
+ * 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 BlockTest extends TestCase {
+ public void testMixedContent() throws Exception {
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/xsd",
+ "complexElt");
+
+
+ InputStream is = new FileInputStream("test-resources/block.xsd");
+ XmlSchemaCollection schema = new XmlSchemaCollection();
+ XmlSchema s = schema.read(new StreamSource(is), null);
+
+ XmlSchemaElement elementByName = s.getElementByName(ELEMENT_QNAME);
+ assertNotNull(elementByName);
+
+ String value = elementByName.getBlock().getValue();
+ assertEquals("restriction",value);
+
+ }
+}
Added:
webservices/commons/trunk/modules/XmlSchema/test/tests/MixedContentTest.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/test/tests/MixedContentTest.java?rev=395806&view=auto
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/test/tests/MixedContentTest.java
(added)
+++
webservices/commons/trunk/modules/XmlSchema/test/tests/MixedContentTest.java
Fri Apr 21 00:45:47 2006
@@ -0,0 +1,48 @@
+package tests;
+
+import junit.framework.TestCase;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+import java.io.InputStream;
+import java.io.FileInputStream;
+
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+/*
+ * 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 MixedContentTest extends TestCase {
+ public void testMixedContent() throws Exception {
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/xsd",
+ "complexElt");
+
+
+ InputStream is = new
FileInputStream("test-resources/mixedContent.xsd");
+ XmlSchemaCollection schema = new XmlSchemaCollection();
+ XmlSchema s = schema.read(new StreamSource(is), null);
+
+ XmlSchemaElement elementByName = s.getElementByName(ELEMENT_QNAME);
+ assertNotNull(elementByName);
+
+ XmlSchemaType schemaType = elementByName.getSchemaType();
+ assertNotNull(schemaType);
+
+ assertTrue(schemaType.isMixed());
+ }
+}
Modified:
webservices/commons/trunk/modules/XmlSchema/test/tests/TestForwardRefs.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/XmlSchema/test/tests/TestForwardRefs.java?rev=395806&r1=395805&r2=395806&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test/tests/TestForwardRefs.java
(original)
+++ webservices/commons/trunk/modules/XmlSchema/test/tests/TestForwardRefs.java
Fri Apr 21 00:45:47 2006
@@ -33,6 +33,7 @@
/**
*/
public class TestForwardRefs extends TestCase {
+
public void testForwardRefs() throws Exception {
QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
"attrTest");