Author: bimargulies
Date: Sun Sep 5 11:39:13 2010
New Revision: 992760
URL: http://svn.apache.org/viewvc?rev=992760&view=rev
Log:
WSCOMMONS-559
Modified:
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttribute.java
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroupRef.java
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexContentExtension.java
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexContentRestriction.java
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexType.java
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaContent.java
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleContentExtension.java
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleContentRestriction.java
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleType.java
Modified:
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java?rev=992760&r1=992759&r2=992760&view=diff
==============================================================================
---
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
(original)
+++
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
Sun Sep 5 11:39:13 2010
@@ -666,7 +666,7 @@ public class SchemaBuilder {
} else if (el.getLocalName().equals("attribute")) {
ct.attributes.add(handleAttribute(schema, el,
schemaEl));
} else if (el.getLocalName().equals("attributeGroup")) {
- ct.attributes.add(handleAttributeGroupRef(el));
+
ct.attributes.add(handleAttributeGroupRef(schema, el));
} else if (el.getLocalName().equals("group")) {
XmlSchemaGroupRef group =
handleGroupRef(schema, el, schemaEl);
ct.particle = (group.particle == null) ?
(XmlSchemaParticle) group
@@ -780,7 +780,7 @@ public class SchemaBuilder {
private XmlSchemaSimpleContentRestriction
handleSimpleContentRestriction(
XmlSchema schema, Element restrictionEl, Element
schemaEl) {
- XmlSchemaSimpleContentRestriction restriction = new
XmlSchemaSimpleContentRestriction();
+ XmlSchemaSimpleContentRestriction restriction = new
XmlSchemaSimpleContentRestriction(schema);
if (restrictionEl.hasAttribute("base")) {
String name = restrictionEl.getAttribute("base");
@@ -799,7 +799,7 @@ public class SchemaBuilder {
XmlSchemaAttribute attr =
handleAttribute(schema, el, schemaEl);
restriction.attributes.add(attr);
} else if (el.getLocalName().equals("attributeGroup")) {
- XmlSchemaAttributeGroupRef attrGroup =
handleAttributeGroupRef(el);
+ XmlSchemaAttributeGroupRef attrGroup =
handleAttributeGroupRef(schema, el);
restriction.attributes.add(attrGroup);
} else if (el.getLocalName().equals("simpleType")) {
restriction.baseType = handleSimpleType(schema,
el, schemaEl);
@@ -823,7 +823,7 @@ public class SchemaBuilder {
private XmlSchemaSimpleContentExtension handleSimpleContentExtension(
XmlSchema schema, Element extEl, Element schemaEl) {
- XmlSchemaSimpleContentExtension ext = new
XmlSchemaSimpleContentExtension();
+ XmlSchemaSimpleContentExtension ext = new
XmlSchemaSimpleContentExtension(schema);
if (extEl.hasAttribute("base")) {
String name = extEl.getAttribute("base");
@@ -838,7 +838,7 @@ public class SchemaBuilder {
XmlSchemaAttribute attr =
handleAttribute(schema, el, schemaEl);
ext.attributes.add(attr);
} else if (el.getLocalName().equals("attributeGroup")) {
- XmlSchemaAttributeGroupRef attrGroup =
handleAttributeGroupRef(el);
+ XmlSchemaAttributeGroupRef attrGroup =
handleAttributeGroupRef(schema, el);
ext.attributes.add(attrGroup);
} else if (el.getLocalName().equals("anyAttribute")) {
ext.anyAttribute = handleAnyAttribute(schema,
el, schemaEl);
@@ -853,7 +853,7 @@ public class SchemaBuilder {
private XmlSchemaComplexContentRestriction
handleComplexContentRestriction(
XmlSchema schema, Element restrictionEl, Element
schemaEl) {
- XmlSchemaComplexContentRestriction restriction = new
XmlSchemaComplexContentRestriction();
+ XmlSchemaComplexContentRestriction restriction = new
XmlSchemaComplexContentRestriction(schema);
if (restrictionEl.hasAttribute("base")) {
String name = restrictionEl.getAttribute("base");
@@ -873,7 +873,7 @@ public class SchemaBuilder {
restriction.attributes
.add(handleAttribute(schema,
el, schemaEl));
} else if (el.getLocalName().equals("attributeGroup")) {
-
restriction.attributes.add(handleAttributeGroupRef(el));
+
restriction.attributes.add(handleAttributeGroupRef(schema, el));
} else if (el.getLocalName().equals("group")) {
restriction.particle = handleGroupRef(schema,
el, schemaEl);
} else if (el.getLocalName().equals("anyAttribute")) {
@@ -889,7 +889,7 @@ public class SchemaBuilder {
private XmlSchemaComplexContentExtension handleComplexContentExtension(
XmlSchema schema, Element extEl, Element schemaEl) {
- XmlSchemaComplexContentExtension ext = new
XmlSchemaComplexContentExtension();
+ XmlSchemaComplexContentExtension ext = new
XmlSchemaComplexContentExtension(schema);
if (extEl.hasAttribute("base")) {
String name = extEl.getAttribute("base");
@@ -909,7 +909,7 @@ public class SchemaBuilder {
} else if (el.getLocalName().equals("attribute")) {
ext.attributes.add(handleAttribute(schema, el,
schemaEl));
} else if (el.getLocalName().equals("attributeGroup")) {
- ext.attributes.add(handleAttributeGroupRef(el));
+
ext.attributes.add(handleAttributeGroupRef(schema, el));
} else if (el.getLocalName().equals("group")) {
ext.particle = handleGroupRef(schema, el,
schemaEl);
} else if (el.getLocalName().equals("anyAttribute")) {
@@ -921,10 +921,10 @@ public class SchemaBuilder {
return ext;
}
- private XmlSchemaAttributeGroupRef handleAttributeGroupRef(
+ private XmlSchemaAttributeGroupRef handleAttributeGroupRef(XmlSchema
schema,
Element attrGroupEl) {
- XmlSchemaAttributeGroupRef attrGroup = new
XmlSchemaAttributeGroupRef();
+ XmlSchemaAttributeGroupRef attrGroup = new
XmlSchemaAttributeGroupRef(schema);
if (attrGroupEl.hasAttribute("ref")) {
String ref = attrGroupEl.getAttribute("ref");
@@ -1115,7 +1115,7 @@ public class SchemaBuilder {
XmlSchemaAttribute attr =
handleAttribute(schema, el, schemaEl);
attrGroup.attributes.add(attr);
} else if (el.getLocalName().equals("attributeGroup")) {
- XmlSchemaAttributeGroupRef attrGroupRef =
handleAttributeGroupRef(el);
+ XmlSchemaAttributeGroupRef attrGroupRef =
handleAttributeGroupRef(schema, el);
attrGroup.attributes.add(attrGroupRef);
} else if (el.getLocalName().equals("anyAttribute")) {
attrGroup.anyAttribute =
handleAnyAttribute(schema, el,
Modified:
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttribute.java
URL:
http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttribute.java?rev=992760&r1=992759&r2=992760&view=diff
==============================================================================
---
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttribute.java
(original)
+++
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttribute.java
Sun Sep 5 11:39:13 2010
@@ -136,4 +136,23 @@ public class XmlSchemaAttribute extends
return xml;
}
+
+ static final XmlSchemaAttribute getAttribute(final
XmlSchemaObjectCollection attributes, final QName name) {
+ if ((attributes == null) || (name == null)) return null;
+ for (int i = 0; i < attributes.getCount(); i++) {
+ final XmlSchemaObject attrItem = attributes.getItem(i);
+ if (attrItem instanceof XmlSchemaAttributeGroupRef) {
+ final XmlSchemaAttributeGroup attrGroup =
((XmlSchemaAttributeGroupRef)attrItem).resolve();
+ if (attrGroup == null) continue;
+ final XmlSchemaAttribute attr =
getAttribute(attrGroup.getAttributes(), name);
+ if (attr != null) return attr;
+ } else if (attrItem instanceof XmlSchemaAttribute) {
+ final XmlSchemaAttribute attr = (XmlSchemaAttribute)attrItem;
+ final QName attrQName = attr.getQName();
+ if ((attrQName != null) && (attrQName.equals(name))) return
attr;
+ }
+ }
+ return null;
+ }
+
}
Modified:
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroupRef.java
URL:
http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroupRef.java?rev=992760&r1=992759&r2=992760&view=diff
==============================================================================
---
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroupRef.java
(original)
+++
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaAttributeGroupRef.java
Sun Sep 5 11:39:13 2010
@@ -28,10 +28,13 @@ import javax.xml.namespace.QName;
*/
public class XmlSchemaAttributeGroupRef extends XmlSchemaAnnotated {
+ XmlSchema schema;
+
/**
* Creates new XmlSchemaAttributeGroupRef
*/
- public XmlSchemaAttributeGroupRef() {
+ public XmlSchemaAttributeGroupRef(XmlSchema schema) {
+ this.schema = schema;
}
QName refName;
@@ -44,4 +47,8 @@ public class XmlSchemaAttributeGroupRef
this.refName = refName;
}
+ public XmlSchemaAttributeGroup resolve() {
+ return
(XmlSchemaAttributeGroup)schema.getAttributeGroups().getItem(refName);
+ }
+
}
Modified:
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexContentExtension.java
URL:
http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexContentExtension.java?rev=992760&r1=992759&r2=992760&view=diff
==============================================================================
---
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexContentExtension.java
(original)
+++
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexContentExtension.java
Sun Sep 5 11:39:13 2010
@@ -33,7 +33,8 @@ public class XmlSchemaComplexContentExte
/**
* Creates new XmlSchemaComplexContentExtension
*/
- public XmlSchemaComplexContentExtension() {
+ public XmlSchemaComplexContentExtension(XmlSchema schema) {
+ super(schema);
attributes = new XmlSchemaObjectCollection();
}
@@ -96,4 +97,18 @@ public class XmlSchemaComplexContentExte
xml += "</" + prefix + "extension>\n";
return xml;
}
+
+ public XmlSchemaComplexType resolveBaseComplexType() {
+ return (XmlSchemaComplexType)resolveBaseType();
+ }
+
+ XmlSchemaAttribute getAttribute(QName name) {
+ XmlSchemaAttribute attr = super.getAttribute(name);
+ if (attr == null) {
+ XmlSchemaComplexType baseType = resolveBaseComplexType();
+ if (baseType != null) attr = baseType.getAttribute(name);
+ }
+ return attr;
+ }
+
}
Modified:
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexContentRestriction.java
URL:
http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexContentRestriction.java?rev=992760&r1=992759&r2=992760&view=diff
==============================================================================
---
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexContentRestriction.java
(original)
+++
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexContentRestriction.java
Sun Sep 5 11:39:13 2010
@@ -34,7 +34,8 @@ public class XmlSchemaComplexContentRest
/**
* Creates new XmlSchemaComplexContentRestriction
*/
- public XmlSchemaComplexContentRestriction() {
+ public XmlSchemaComplexContentRestriction(XmlSchema schema) {
+ super(schema);
attributes = new XmlSchemaObjectCollection();
}
@@ -100,5 +101,19 @@ public class XmlSchemaComplexContentRest
xml += "</" + prefix + "restriction>\n";
return xml;
}
+
+ public XmlSchemaComplexType resolveBaseComplexType() {
+ return (XmlSchemaComplexType)resolveBaseType();
+ }
+
+ XmlSchemaAttribute getAttribute(QName name) {
+ XmlSchemaAttribute attr = super.getAttribute(name);
+ if (attr == null) {
+ XmlSchemaComplexType baseType = resolveBaseComplexType();
+ if (baseType != null) attr = baseType.getAttribute(name);
+ }
+ return attr;
+ }
+
}
Modified:
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexType.java
URL:
http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexType.java?rev=992760&r1=992759&r2=992760&view=diff
==============================================================================
---
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexType.java
(original)
+++
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaComplexType.java
Sun Sep 5 11:39:13 2010
@@ -177,5 +177,11 @@ public class XmlSchemaComplexType extend
return ext.getBaseTypeName();
}
+ public XmlSchemaAttribute getAttribute(QName name) {
+ XmlSchemaAttribute attr = XmlSchemaAttribute.getAttribute(attributes,
name);
+ if (attr != null) return attr;
+ if (contentModel != null) return
contentModel.getContent().getAttribute(name);
+ return null;
+ }
}
Modified:
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaContent.java
URL:
http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaContent.java?rev=992760&r1=992759&r2=992760&view=diff
==============================================================================
---
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaContent.java
(original)
+++
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaContent.java
Sun Sep 5 11:39:13 2010
@@ -19,6 +19,8 @@
package org.apache.ws.commons.schema;
+import javax.xml.namespace.QName;
+
/**
* An abstract class for schema content.
*
@@ -26,10 +28,26 @@ package org.apache.ws.commons.schema;
public abstract class XmlSchemaContent extends XmlSchemaAnnotated {
+ XmlSchema schema;
+
/**
* Creates new XmlSchemaContent
*/
- protected XmlSchemaContent() {
+ protected XmlSchemaContent(XmlSchema schema) {
+ this.schema = schema;
+ }
+
+ public abstract XmlSchemaObjectCollection getAttributes();
+
+ public abstract QName getBaseTypeName();
+
+ public XmlSchemaType resolveBaseType() {
+ QName baseTypeName = getBaseTypeName();
+ return (baseTypeName != null) ? schema.getTypeByName(baseTypeName) :
null;
+ }
+
+ XmlSchemaAttribute getAttribute(QName name) {
+ return XmlSchemaAttribute.getAttribute(getAttributes(), name);
}
}
Modified:
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleContentExtension.java
URL:
http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleContentExtension.java?rev=992760&r1=992759&r2=992760&view=diff
==============================================================================
---
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleContentExtension.java
(original)
+++
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleContentExtension.java
Sun Sep 5 11:39:13 2010
@@ -33,7 +33,8 @@ public class XmlSchemaSimpleContentExten
/**
* Creates new XmlSchemaSimpleContentExtension
*/
- public XmlSchemaSimpleContentExtension() {
+ public XmlSchemaSimpleContentExtension(XmlSchema schema) {
+ super(schema);
attributes = new XmlSchemaObjectCollection();
}
@@ -67,5 +68,9 @@ public class XmlSchemaSimpleContentExten
return this.baseTypeName;
}
+ public XmlSchemaSimpleType resolveBaseSimpleType() {
+ return (XmlSchemaSimpleType)resolveBaseType();
+ }
+
}
Modified:
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleContentRestriction.java
URL:
http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleContentRestriction.java?rev=992760&r1=992759&r2=992760&view=diff
==============================================================================
---
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleContentRestriction.java
(original)
+++
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleContentRestriction.java
Sun Sep 5 11:39:13 2010
@@ -33,7 +33,8 @@ public class XmlSchemaSimpleContentRestr
/**
* Creates new XmlSchemaSimpleContentRestriction
*/
- public XmlSchemaSimpleContentRestriction() {
+ public XmlSchemaSimpleContentRestriction(XmlSchema schema) {
+ super(schema);
facets = new XmlSchemaObjectCollection();
attributes = new XmlSchemaObjectCollection();
}
@@ -85,5 +86,14 @@ public class XmlSchemaSimpleContentRestr
return this.facets;
}
+ public XmlSchemaType resolveBaseType() {
+ if (baseType != null) return baseType;
+ return resolveBaseType();
+ }
+
+ public XmlSchemaSimpleType resolveBaseSimpleType() {
+ return (XmlSchemaSimpleType)resolveBaseType();
+ }
+
}
Modified:
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleType.java
URL:
http://svn.apache.org/viewvc/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleType.java?rev=992760&r1=992759&r2=992760&view=diff
==============================================================================
---
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleType.java
(original)
+++
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/XmlSchemaSimpleType.java
Sun Sep 5 11:39:13 2010
@@ -19,6 +19,9 @@
package org.apache.ws.commons.schema;
+import javax.xml.namespace.QName;
+
+
/**
* Class defines a simple type that determines the information and
* constraints for the values of attributes or elements with text-only
@@ -66,5 +69,13 @@ public class XmlSchemaSimpleType extends
return xml;
}
+ public QName getRootTypeName() {
+ if (content == null) return getQName();
+ if (!(content instanceof XmlSchemaSimpleTypeRestriction)) return null;
+ XmlSchemaSimpleTypeRestriction typeRestriction =
(XmlSchemaSimpleTypeRestriction)content;
+ if (typeRestriction.getBaseType() != null) return
typeRestriction.getBaseType().getRootTypeName();
+ return typeRestriction.getBaseTypeName();
+ }
+
}