You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by bi...@apache.org on 2011/04/22 23:03:33 UTC
svn commit: r1096036 - in
/webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema:
XmlSchemaCollection.java utils/NamespaceMap.java
Author: bimargulies
Date: Fri Apr 22 21:03:33 2011
New Revision: 1096036
URL: http://svn.apache.org/viewvc?rev=1096036&view=rev
Log:
XMLSCHEMA-13
Modified:
webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/utils/NamespaceMap.java
Modified: webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java?rev=1096036&r1=1096035&r2=1096036&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java (original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java Fri Apr 22 21:03:33 2011
@@ -345,6 +345,9 @@ public final class XmlSchemaCollection {
addSimpleType(xsd, Constants.XSD_LANGUAGE.getLocalPart());
addSimpleType(xsd, Constants.XSD_TOKEN.getLocalPart());
+ // 2.5.3 setup built-in datatype hierarchy
+ setupBuiltinDatatypeHierarchy(xsd);
+
// SchemaKey key = new SchemaKey(XmlSchema.SCHEMA_NS, null);
// addSchema(key, xsd);
@@ -368,6 +371,77 @@ public final class XmlSchemaCollection {
}
}
+ private void setupBuiltinDatatypeHierarchy(XmlSchema xsd) {
+
+ setDerivationByRestriction(xsd, Constants.XSD_ANYSIMPLETYPE, Constants.XSD_ANYTYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_DURATION, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_DATETIME, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_TIME, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_DATE, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_YEARMONTH, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_YEAR, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_MONTHDAY, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_DAY, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_MONTH, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_BOOLEAN, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_BASE64, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_HEXBIN, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_FLOAT, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_DOUBLE, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_ANYURI, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_QNAME, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_NOTATION, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_NOTATION, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_DECIMAL, Constants.XSD_ANYSIMPLETYPE);
+
+ setDerivationByRestriction(xsd, Constants.XSD_INTEGER, Constants.XSD_DECIMAL);
+ setDerivationByRestriction(xsd, Constants.XSD_NONPOSITIVEINTEGER, Constants.XSD_INTEGER);
+ setDerivationByRestriction(xsd, Constants.XSD_NEGATIVEINTEGER, Constants.XSD_NONPOSITIVEINTEGER);
+ setDerivationByRestriction(xsd, Constants.XSD_LONG, Constants.XSD_INTEGER);
+ setDerivationByRestriction(xsd, Constants.XSD_INT, Constants.XSD_LONG);
+ setDerivationByRestriction(xsd, Constants.XSD_SHORT, Constants.XSD_INT);
+ setDerivationByRestriction(xsd, Constants.XSD_BYTE, Constants.XSD_SHORT);
+ setDerivationByRestriction(xsd, Constants.XSD_NONNEGATIVEINTEGER, Constants.XSD_INTEGER);
+ setDerivationByRestriction(xsd, Constants.XSD_POSITIVEINTEGER, Constants.XSD_NONNEGATIVEINTEGER);
+ setDerivationByRestriction(xsd, Constants.XSD_UNSIGNEDLONG, Constants.XSD_NONNEGATIVEINTEGER);
+ setDerivationByRestriction(xsd, Constants.XSD_UNSIGNEDINT, Constants.XSD_UNSIGNEDLONG);
+ setDerivationByRestriction(xsd, Constants.XSD_UNSIGNEDSHORT, Constants.XSD_UNSIGNEDINT);
+ setDerivationByRestriction(xsd, Constants.XSD_UNSIGNEDBYTE, Constants.XSD_UNSIGNEDSHORT);
+
+ setDerivationByRestriction(xsd, Constants.XSD_STRING, Constants.XSD_ANYSIMPLETYPE);
+ setDerivationByRestriction(xsd, Constants.XSD_NORMALIZEDSTRING, Constants.XSD_STRING);
+ setDerivationByRestriction(xsd, Constants.XSD_TOKEN, Constants.XSD_NORMALIZEDSTRING);
+ setDerivationByRestriction(xsd, Constants.XSD_LANGUAGE, Constants.XSD_TOKEN);
+ setDerivationByRestriction(xsd, Constants.XSD_NMTOKEN, Constants.XSD_TOKEN);
+ setDerivationByRestriction(xsd, Constants.XSD_NAME, Constants.XSD_NMTOKEN);
+ setDerivationByRestriction(xsd, Constants.XSD_NCNAME, Constants.XSD_TOKEN);
+ setDerivationByRestriction(xsd, Constants.XSD_ID, Constants.XSD_NCNAME);
+ setDerivationByRestriction(xsd, Constants.XSD_IDREF, Constants.XSD_NCNAME);
+ setDerivationByRestriction(xsd, Constants.XSD_ENTITY, Constants.XSD_NCNAME);
+
+ setDerivationByList(xsd, Constants.XSD_NMTOKENS, Constants.XSD_NMTOKEN);
+ setDerivationByList(xsd, Constants.XSD_IDREFS, Constants.XSD_IDREF);
+ setDerivationByList(xsd, Constants.XSD_ENTITIES, Constants.XSD_ENTITY);
+ }
+
+ private void setDerivationByRestriction(XmlSchema xsd, QName child, QName parent) {
+
+ XmlSchemaSimpleType simple = (XmlSchemaSimpleType)xsd.getTypeByName(child);
+ XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
+ restriction.setBaseTypeName(parent);
+ restriction.setBaseType((XmlSchemaSimpleType)xsd.getTypeByName(parent));
+ simple.setContent(restriction);
+ }
+
+ private void setDerivationByList(XmlSchema xsd, QName child, QName parent) {
+
+ XmlSchemaSimpleType simple = (XmlSchemaSimpleType)xsd.getTypeByName(child);
+ XmlSchemaSimpleTypeList restriction = new XmlSchemaSimpleTypeList();
+ restriction.setItemTypeName(parent);
+ restriction.setItemType((XmlSchemaSimpleType)xsd.getTypeByName(parent));
+ simple.setContent(restriction);
+ }
+
/**
* Pop the stack of schemas. This function, while public, is probably not useful outside of the
* implementation.
Modified: webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/utils/NamespaceMap.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/utils/NamespaceMap.java?rev=1096036&r1=1096035&r2=1096036&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/utils/NamespaceMap.java (original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/utils/NamespaceMap.java Fri Apr 22 21:03:33 2011
@@ -51,7 +51,8 @@ public class NamespaceMap extends HashMa
}
public String getNamespaceURI(String prefix) {
- return get(prefix).toString();
+ Object namespaceURI = get(prefix);
+ return namespaceURI == null ? null : namespaceURI .toString();
}
public String getPrefix(String namespaceURI) {