This is an automated email from the ASF dual-hosted git repository.
andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git
The following commit(s) were added to refs/heads/main by this push:
new dc89c675ee GH-2828: Remove validation for XML-only datatypes
dc89c675ee is described below
commit dc89c675ee67b257d94509755585e5b8409db24a
Author: Ostrzyciel <[email protected]>
AuthorDate: Sun Nov 17 14:41:44 2024 +0100
GH-2828: Remove validation for XML-only datatypes
Issue: #2828
Remove the code for validating datatypes that according to the RDF 1.1 spec
SHOULD NOT be used: QName, ENTITY, ID, IDREF, NOTATION, ENTITIES, NMTOKENS,
IDREFS. Also remove code for validating XSD lists and unions.
---
.../org/apache/jena/datatypes/xsd/XSDDatatype.java | 137 +---
.../jena/ext/xerces/impl/dv/SchemaDVFactory.java | 31 -
.../jena/ext/xerces/impl/dv/XSSimpleType.java | 28 +-
.../jena/ext/xerces/impl/dv/xs/BaseDVFactory.java | 38 --
.../ext/xerces/impl/dv/xs/BaseSchemaDVFactory.java | 99 +--
.../jena/ext/xerces/impl/dv/xs/EntityDV.java | 57 --
.../jena/ext/xerces/impl/dv/xs/FullDVFactory.java | 36 -
.../apache/jena/ext/xerces/impl/dv/xs/IDDV.java | 56 --
.../apache/jena/ext/xerces/impl/dv/xs/IDREFDV.java | 55 --
.../apache/jena/ext/xerces/impl/dv/xs/ListDV.java | 146 ----
.../apache/jena/ext/xerces/impl/dv/xs/QNameDV.java | 116 ----
.../apache/jena/ext/xerces/impl/dv/xs/UnionDV.java | 47 --
.../ext/xerces/impl/dv/xs/XSSimpleTypeDecl.java | 732 ++-------------------
.../xerces/impl/dv/xs/XSSimpleTypeDelegate.java | 20 -
.../jena/ext/xerces/xs/XSSimpleTypeDefinition.java | 22 -
15 files changed, 120 insertions(+), 1500 deletions(-)
diff --git
a/jena-core/src/main/java/org/apache/jena/datatypes/xsd/XSDDatatype.java
b/jena-core/src/main/java/org/apache/jena/datatypes/xsd/XSDDatatype.java
index b9ddf31366..17bea0ff94 100644
--- a/jena-core/src/main/java/org/apache/jena/datatypes/xsd/XSDDatatype.java
+++ b/jena-core/src/main/java/org/apache/jena/datatypes/xsd/XSDDatatype.java
@@ -112,9 +112,6 @@ public class XSDDatatype extends BaseDatatype {
public static final XSDDatatype XSDnormalizedString = new
XSDBaseStringType("normalizedString", String.class);
/** Datatype representing xsd:anyURI */
- // If you see this, remove commented lines.
- // Merely temporary during switch over and testing.
- //public static final XSDDatatype XSDanyURI = new XSDDatatype("anyURI",
URI.class);
public static final XSDDatatype XSDanyURI = new XSDPlainType("anyURI",
URI.class);
/** Datatype representing xsd:token */
@@ -123,10 +120,11 @@ public class XSDDatatype extends BaseDatatype {
/** Datatype representing xsd:Name */
public static final XSDDatatype XSDName = new XSDBaseStringType("Name");
- /** Datatype representing xsd:QName */
- // If you see this, remove commented lines.
- // Merely temporary during switch over and testing.
- // public static final XSDDatatype XSDQName = new XSDDatatype("QName");
+ /**
+ * Datatype representing xsd:QName
+ * @deprecated will be removed in Jena 6
+ */
+ @Deprecated(forRemoval = true)
public static final XSDDatatype XSDQName = new XSDPlainType("QName");
/** Datatype representing xsd:language */
@@ -135,25 +133,35 @@ public class XSDDatatype extends BaseDatatype {
/** Datatype representing xsd:NMTOKEN */
public static final XSDDatatype XSDNMTOKEN = new
XSDBaseStringType("NMTOKEN");
- /** Datatype representing xsd:ENTITY */
+ /**
+ * Datatype representing xsd:ENTITY
+ * @deprecated will be removed in Jena 6
+ */
+ @Deprecated(forRemoval = true)
public static final XSDDatatype XSDENTITY = new
XSDBaseStringType("ENTITY");
- /** Datatype representing xsd:ID */
+ /**
+ * Datatype representing xsd:ID
+ * @deprecated will be removed in Jena 6
+ */
+ @Deprecated(forRemoval = true)
public static final XSDDatatype XSDID = new XSDBaseStringType("ID");
/** Datatype representing xsd:NCName */
public static final XSDDatatype XSDNCName = new
XSDBaseStringType("NCName");
- /** Datatype representing xsd:IDREF */
- // If you see this, remove commented lines.
- // Merely temporary during switch over and testing.
- //public static final XSDDatatype XSDIDREF = new XSDDatatype("IDREF");
+ /**
+ * Datatype representing xsd:IDREF
+ * @deprecated will be removed in Jena 6
+ */
+ @Deprecated(forRemoval = true)
public static final XSDDatatype XSDIDREF = new XSDPlainType("IDREF");
- /** Datatype representing xsd:NOTATION */
- // If you see this, remove commented lines.
- // Merely temporary during switch over and testing.
- //public static final XSDDatatype XSDNOTATION = new
XSDDatatype("NOTATION");
+ /**
+ * Datatype representing xsd:NOTATION
+ * @deprecated will be removed in Jena 6
+ */
+ @Deprecated(forRemoval = true)
public static final XSDDatatype XSDNOTATION = new XSDPlainType("NOTATION");
/** Datatype representing xsd:hexBinary */
@@ -198,17 +206,6 @@ public class XSDDatatype extends BaseDatatype {
/** Datatype representing xsd:gMonthDay */
public static final XSDDatatype XSDgMonthDay = new
XSDMonthDayType("gMonthDay");
- // The following are list rather than simple types and are omitted for now
-
-// /** Datatype representing xsd:ENTITIES */
-// public static final XSDDatatype XSDENTITIES = new
XSDBaseStringType("ENTITIES");
-//
-// /** Datatype representing xsd:NMTOKENS */
-// public static final XSDDatatype XSDNMTOKENS = new
XSDBaseStringType("NMTOKENS");
-//
-// /** Datatype representing xsd:IDREFS */
-// public static final XSDDatatype XSDIDREFS = new
XSDBaseStringType("IDREFS");
-
//=======================================================================
// local variables
@@ -311,83 +308,6 @@ public class XSDDatatype extends BaseDatatype {
return typeDeclaration;
}
- // The following code parses an external XSD file for XSD datatype
definitions.
- // See an example "testing/xsd/daml+oil-ex-dt.xsd" and
TestTypeLiterals.testUserDefined.
- // It calls into Xerces internal XM parsing, which is problematic if
switching to the
- // JDK built-in XML parser in Java9 and later.
-
-// /**
-// * Create and register a set of types specified in a user schema file.
-// * We use the (illegal) DAML+OIL approach that the uriref of the type
-// * is the url of the schema file with fragment ID corresponding the
-// * the name of the type.
-// *
-// * @param uri the absolute uri of the schema file to be loaded
-// * @param reader the Reader stream onto the file (useful if you wish to
load a cached copy of the schema file)
-// * @param encoding the encoding of the source file (can be null)
-// * @param tm the type mapper into which to load the definitions
-// * @return a List of strings giving the uri's of the newly defined
datatypes
-// * @throws DatatypeFormatException if there is a problem during load
(not that we use Xerces
-// * in default mode for load which may provide diagnostic output direct
to stderr)
-// */
-// public static List<String> loadUserDefined(String uri, Reader reader,
String encoding, TypeMapper tm) throws DatatypeFormatException {
-// return loadUserDefined(new XMLInputSource(null, uri, uri, reader,
encoding), tm);
-// }
-//
-// /**
-// * Create and register a set of types specified in a user schema file.
-// * We use the (illegal) DAML+OIL approach that the uriref of the type
-// * is the url of the schema file with fragment ID corresponding the
-// * the name of the type.
-// *
-// * @param uri the absolute uri of the schema file to be loaded, this
should be a resolvable URL
-// * @param encoding the encoding of the source file (can be null)
-// * @param tm the type mapper into which to load the definitions
-// * @return a List of strings giving the uri's of the newly defined
datatypes
-// * @throws DatatypeFormatException if there is a problem during load
(not that we use Xerces
-// * in default mode for load which may provide diagnostic output direct
to stderr)
-// */
-// public static List<String> loadUserDefined(String uri, String encoding,
TypeMapper tm) throws DatatypeFormatException {
-// return loadUserDefined(new XMLInputSource(null, uri, uri), tm);
-// }
-//
-// /**
-// * Internal implementation of loadUserDefined
-// *
-// * @param uri the absolute uri of the schema file to be loaded
-// * @param reader the Reader stream onto the file (useful if you wish to
load a cached copy of the schema file)
-// * @param encoding the encoding of the source file (can be null)
-// * @param tm the type mapper into which to load the definitions
-// * @return a List of strings giving the uri's of the newly defined
datatypes
-// * @throws DatatypeFormatException if there is a problem during load
(not that we use Xerces
-// * in default mode for load which may provide diagnostic output direct
to stderr)
-// */
-// private static List<String> loadUserDefined(XMLInputSource source,
TypeMapper tm) throws DatatypeFormatException {
-// XMLGrammarPreparser parser = new XMLGrammarPreparser();
-// parser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
-// try {
-// XSGrammar xsg = (XSGrammar)
parser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA, source);
-// org.apache.xerces.xs.XSModel xsm = xsg.toXSModel();
-// XSNamedMap map = xsm.getComponents(XSTypeDefinition.SIMPLE_TYPE);
-// int numDefs = map.getLength();
-// ArrayList<String> names = new ArrayList<>(numDefs);
-// for (int i = 0; i < numDefs; i++) {
-// XSSimpleType xstype = (XSSimpleType) map.item(i);
-// // Filter built in types - only needed for 2.6.0
-// if ( ! XSD.equals(xstype.getNamespace()) ) {
-// //xstype.derivedFrom()
-// XSDDatatype definedType = new XSDGenericType(xstype,
source.getSystemId());
-// tm.registerDatatype(definedType);
-// names.add(definedType.getURI());
-// }
-// }
-// return names;
-// } catch (Exception e) {
-// e.printStackTrace(); // Temp
-// throw new DatatypeFormatException(e.toString());
-// }
-// }
-
/**
* Convert a validated xerces data value into the corresponding java data
value.
* This function is currently the most blatently xerces-version dependent
part
@@ -596,6 +516,9 @@ public class XSDDatatype extends BaseDatatype {
tm.registerDatatype(XSDtoken);
tm.registerDatatype(XSDName);
tm.registerDatatype(XSDlanguage);
+
+ // According to the RDF 1.1 spec, these datatypes SHOULD NOT be used
in RDF.
+ // Jena will not do any special handling or validation of these
datatypes.
tm.registerDatatype(XSDQName);
tm.registerDatatype(XSDNMTOKEN);
tm.registerDatatype(XSDID);
@@ -603,10 +526,6 @@ public class XSDDatatype extends BaseDatatype {
tm.registerDatatype(XSDNCName);
tm.registerDatatype(XSDNOTATION);
tm.registerDatatype(XSDIDREF);
-
-// tm.registerDatatype(XSDIDREFS);
-// tm.registerDatatype(XSDENTITIES);
-// tm.registerDatatype(XSDNMTOKENS);
}
/**
diff --git
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/SchemaDVFactory.java
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/SchemaDVFactory.java
index e041b41f18..3f917ca18c 100644
---
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/SchemaDVFactory.java
+++
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/SchemaDVFactory.java
@@ -91,35 +91,4 @@ public abstract class SchemaDVFactory {
public abstract XSSimpleType createTypeRestriction(String name, String
targetNamespace,
short finalSet,
XSSimpleType base,
XSObjectList
annotations);
-
- /**
- * Create a new simple type which is derived by list from another simple
- * type.
- *
- * @param name name of the new type, could be null
- * @param targetNamespace target namespace of the new type, could be null
- * @param finalSet value of "final"
- * @param itemType item type of the list type
- * @param annotations set of annotations
- * @return the newly created simple type
- */
- public abstract XSSimpleType createTypeList(String name, String
targetNamespace,
- short finalSet, XSSimpleType
itemType,
- XSObjectList annotations);
-
- /**
- * Create a new simple type which is derived by union from a list of other
- * simple types.
- *
- * @param name name of the new type, could be null
- * @param targetNamespace target namespace of the new type, could be null
- * @param finalSet value of "final"
- * @param memberTypes member types of the union type
- * @param annotations set of annotations
- * @return the newly created simple type
- */
- public abstract XSSimpleType createTypeUnion(String name, String
targetNamespace,
- short finalSet,
XSSimpleType[] memberTypes,
- XSObjectList annotations);
-
}
diff --git
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/XSSimpleType.java
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/XSSimpleType.java
index 154ec0e394..17855cd467 100644
---
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/XSSimpleType.java
+++
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/XSSimpleType.java
@@ -51,6 +51,8 @@ public interface XSSimpleType extends XSSimpleTypeDefinition {
* see <a
href='http://www.w3.org/TR/xmlschema-2/#built-in-primitive-datatypes'>
* XML Schema Part 2: Datatypes </a>
*/
+ /** "anySimpleType" type */
+ public static final short PRIMITIVE_ANYSIMPLETYPE = 0;
/** "string" type */
public static final short PRIMITIVE_STRING = 1;
/** "boolean" type */
@@ -85,22 +87,10 @@ public interface XSSimpleType extends
XSSimpleTypeDefinition {
public static final short PRIMITIVE_BASE64BINARY = 16;
/** "anyURI" type */
public static final short PRIMITIVE_ANYURI = 17;
- /** "QName" type */
- public static final short PRIMITIVE_QNAME = 18;
/** "precisionDecimal" type */
- public static final short PRIMITIVE_PRECISIONDECIMAL = 19;
+ public static final short PRIMITIVE_PRECISIONDECIMAL = 18;
/** "NOTATION" type */
- public static final short PRIMITIVE_NOTATION = 20;
-
- /**
- * return an ID representing the built-in primitive base type.
- * REVISIT: This method is (currently) for internal use only.
- * the constants returned from this method are not finalized yet.
- * the names and values might change in the further.
- *
- * @return an ID representing the built-in primitive base type
- */
- public short getPrimitiveKind();
+ public static final short PRIMITIVE_NOTATION = 19;
/**
* validate a given string against this simple type.
@@ -180,16 +170,6 @@ public interface XSSimpleType extends
XSSimpleTypeDefinition {
*/
//public short compare(Object value1, Object value2);
- /**
- * Check whether this type is or is derived from ID.
- * REVISIT: this method makes ID special, which is not a good design.
- * but since ID is not a primitive, there doesn't seem to be a
- * clean way of doing it except to define special method like
this.
- *
- * @return whether this simple type is or is derived from ID.
- */
- public boolean isIDType();
-
/**
* Return the whitespace corresponding to this datatype.
*
diff --git
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/BaseDVFactory.java
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/BaseDVFactory.java
index 87c73709b0..fc44a6251e 100644
---
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/BaseDVFactory.java
+++
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/BaseDVFactory.java
@@ -86,44 +86,6 @@ public class BaseDVFactory extends SchemaDVFactory {
return new XSSimpleTypeDecl((XSSimpleTypeDecl)base, name,
targetNamespace, finalSet, false, annotations);
}
- /**
- * Create a new simple type which is derived by list from another simple
- * type.
- *
- * @param name name of the new type, could be null
- * @param targetNamespace target namespace of the new type, could be null
- * @param finalSet value of "final"
- * @param itemType item type of the list type
- * @param annotations set of annotations
- * @return the newly created simple type
- */
- public XSSimpleType createTypeList(String name, String targetNamespace,
- short finalSet, XSSimpleType itemType,
- XSObjectList annotations) {
- return new XSSimpleTypeDecl(name, targetNamespace, finalSet,
(XSSimpleTypeDecl)itemType, false, annotations);
- }
-
- /**
- * Create a new simple type which is derived by union from a list of other
- * simple types.
- *
- * @param name name of the new type, could be null
- * @param targetNamespace target namespace of the new type, could be null
- * @param finalSet value of "final"
- * @param memberTypes member types of the union type
- * @param annotations set of annotations
- * @return the newly created simple type
- */
- public XSSimpleType createTypeUnion(String name, String targetNamespace,
- short finalSet, XSSimpleType[]
memberTypes,
- XSObjectList annotations) {
- int typeNum = memberTypes.length;
- XSSimpleTypeDecl[] mtypes = new XSSimpleTypeDecl[typeNum];
- System.arraycopy(memberTypes, 0, mtypes, 0, typeNum);
-
- return new XSSimpleTypeDecl(name, targetNamespace, finalSet, mtypes,
annotations);
- }
-
// create all built-in types
static void createBuiltInTypes(SymbolHash types) {
// base schema simple type names
diff --git
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/BaseSchemaDVFactory.java
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/BaseSchemaDVFactory.java
index d08a40113b..92a051f6e3 100644
---
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/BaseSchemaDVFactory.java
+++
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/BaseSchemaDVFactory.java
@@ -57,13 +57,8 @@ public abstract class BaseSchemaDVFactory extends
SchemaDVFactory {
final String DAY = "gDay";
final String DECIMAL = "decimal";
final String DOUBLE = "double";
- final String ENTITY = "ENTITY";
- final String ENTITIES = "ENTITIES";
final String FLOAT = "float";
final String HEXBINARY = "hexBinary";
- final String ID = "ID";
- final String IDREF = "IDREF";
- final String IDREFS = "IDREFS";
final String INT = "int";
final String INTEGER = "integer";
final String LONG = "long";
@@ -73,14 +68,11 @@ public abstract class BaseSchemaDVFactory extends
SchemaDVFactory {
final String MONTHDAY = "gMonthDay";
final String NCNAME = "NCName";
final String NMTOKEN = "NMTOKEN";
- final String NMTOKENS = "NMTOKENS";
final String LANGUAGE = "language";
final String NONNEGATIVEINTEGER= "nonNegativeInteger";
final String NONPOSITIVEINTEGER= "nonPositiveInteger";
final String NORMALIZEDSTRING = "normalizedString";
- final String NOTATION = "NOTATION";
final String POSITIVEINTEGER = "positiveInteger";
- final String QNAME = "QName";
final String SHORT = "short";
final String STRING = "string";
final String TIME = "time";
@@ -92,6 +84,15 @@ public abstract class BaseSchemaDVFactory extends
SchemaDVFactory {
final String YEAR = "gYear";
final String YEARMONTH = "gYearMonth";
+ // These SHOULD NOT be used in RDF 1.1
+ // Only kept here because this is used by the respective datatype
registrations in XSDDatatype.
+ // TODO: remove this in Jena 6 together with the datatype
registrations.
+ final String ENTITY = "ENTITY";
+ final String ID = "ID";
+ final String IDREF = "IDREF";
+ final String NOTATION = "NOTATION";
+ final String QNAME = "QName";
+
final XSFacets facets = new XSFacets();
builtInTypes.put(ANYSIMPLETYPE, XSSimpleTypeDecl.fAnySimpleType);
@@ -187,7 +188,6 @@ public abstract class BaseSchemaDVFactory extends
SchemaDVFactory {
builtInTypes.put(FLOAT, new XSSimpleTypeDecl(baseAtomicType, FLOAT,
XSSimpleTypeDecl.DV_FLOAT, XSSimpleType.ORDERED_PARTIAL, true, true, true,
true, XSConstants.FLOAT_DT));
builtInTypes.put(DOUBLE, new XSSimpleTypeDecl(baseAtomicType, DOUBLE,
XSSimpleTypeDecl.DV_DOUBLE, XSSimpleType.ORDERED_PARTIAL, true, true, true,
true, XSConstants.DOUBLE_DT));
builtInTypes.put(HEXBINARY, new XSSimpleTypeDecl(baseAtomicType,
HEXBINARY, XSSimpleTypeDecl.DV_HEXBINARY, XSSimpleType.ORDERED_FALSE, false,
false, false, true, XSConstants.HEXBINARY_DT));
- builtInTypes.put(NOTATION, new XSSimpleTypeDecl(baseAtomicType,
NOTATION, XSSimpleTypeDecl.DV_NOTATION, XSSimpleType.ORDERED_FALSE, false,
false, false, true, XSConstants.NOTATION_DT));
facets.whiteSpace = XSSimpleType.WS_REPLACE;
XSSimpleTypeDecl normalizedDV = new XSSimpleTypeDecl(stringDV,
NORMALIZEDSTRING , URI_SCHEMAFORSCHEMA, (short)0, false, null,
XSConstants.NORMALIZEDSTRING_DT);
@@ -215,37 +215,20 @@ public abstract class BaseSchemaDVFactory extends
SchemaDVFactory {
ncnameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0,
XSSimpleTypeDecl.SPECIAL_PATTERN_NCNAME);
builtInTypes.put(NCNAME, ncnameDV);
- builtInTypes.put(QNAME, new XSSimpleTypeDecl(baseAtomicType, QNAME,
XSSimpleTypeDecl.DV_QNAME, XSSimpleType.ORDERED_FALSE, false, false, false,
true, XSConstants.QNAME_DT));
-
- builtInTypes.put(ID, new XSSimpleTypeDecl(ncnameDV, ID,
XSSimpleTypeDecl.DV_ID, XSSimpleType.ORDERED_FALSE, false, false, false , true,
XSConstants.ID_DT));
- XSSimpleTypeDecl idrefDV = new XSSimpleTypeDecl(ncnameDV, IDREF ,
XSSimpleTypeDecl.DV_IDREF, XSSimpleType.ORDERED_FALSE, false, false, false,
true, XSConstants.IDREF_DT);
- builtInTypes.put(IDREF, idrefDV);
-
- facets.minLength = 1;
- XSSimpleTypeDecl tempDV = new XSSimpleTypeDecl(null,
URI_SCHEMAFORSCHEMA, (short)0, idrefDV, true, null);
- XSSimpleTypeDecl idrefsDV = new XSSimpleTypeDecl(tempDV, IDREFS,
URI_SCHEMAFORSCHEMA, (short)0, false, null);
- idrefsDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
- builtInTypes.put(IDREFS, idrefsDV);
-
- XSSimpleTypeDecl entityDV = new XSSimpleTypeDecl(ncnameDV, ENTITY ,
XSSimpleTypeDecl.DV_ENTITY, XSSimpleType.ORDERED_FALSE, false, false, false,
true, XSConstants.ENTITY_DT);
- builtInTypes.put(ENTITY, entityDV);
-
- facets.minLength = 1;
- tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0,
entityDV, true, null);
- XSSimpleTypeDecl entitiesDV = new XSSimpleTypeDecl(tempDV, ENTITIES,
URI_SCHEMAFORSCHEMA, (short)0, false, null);
- entitiesDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH,
(short)0);
- builtInTypes.put(ENTITIES, entitiesDV);
-
facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
XSSimpleTypeDecl nmtokenDV = new XSSimpleTypeDecl(tokenDV, NMTOKEN,
URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NMTOKEN_DT);
nmtokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE,
(short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NMTOKEN);
builtInTypes.put(NMTOKEN, nmtokenDV);
- facets.minLength = 1;
- tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0,
nmtokenDV, true, null);
- XSSimpleTypeDecl nmtokensDV = new XSSimpleTypeDecl(tempDV, NMTOKENS,
URI_SCHEMAFORSCHEMA, (short)0, false, null);
- nmtokensDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH,
(short)0);
- builtInTypes.put(NMTOKENS, nmtokensDV);
+ // Dummy registrations for XML datatypes that SHOULD NOT be used in
RDF 1.1.
+ // We don't do any validation on them.
+ // Only kept here because this is used by the respective datatype
registrations in XSDDatatype.
+ // TODO: remove this in Jena 6 together with the datatype
registrations.
+ builtInTypes.put(ENTITY, XSSimpleTypeDecl.fAnySimpleType);
+ builtInTypes.put(ID, XSSimpleTypeDecl.fAnySimpleType);
+ builtInTypes.put(IDREF, XSSimpleTypeDecl.fAnySimpleType);
+ builtInTypes.put(NOTATION, XSSimpleTypeDecl.fAnySimpleType);
+ builtInTypes.put(QNAME, XSSimpleTypeDecl.fAnySimpleType);
} //createBuiltInTypes()
/**
@@ -269,52 +252,6 @@ public abstract class BaseSchemaDVFactory extends
SchemaDVFactory {
return new XSSimpleTypeDecl((XSSimpleTypeDecl)base, name,
targetNamespace, finalSet, false, annotations);
}
- /**
- * Create a new simple type which is derived by list from another simple
- * type.
- *
- * @param name name of the new type, could be null
- * @param targetNamespace target namespace of the new type, could be null
- * @param finalSet value of "final"
- * @param itemType item type of the list type
- * @param annotations set of annotations
- * @return the newly created simple type
- */
- public XSSimpleType createTypeList(String name, String targetNamespace,
- short finalSet, XSSimpleType itemType,
- XSObjectList annotations) {
- if (fDeclPool != null) {
- XSSimpleTypeDecl st= fDeclPool.getSimpleTypeDecl();
- return st.setListValues(name, targetNamespace, finalSet,
(XSSimpleTypeDecl)itemType, annotations);
- }
- return new XSSimpleTypeDecl(name, targetNamespace, finalSet,
(XSSimpleTypeDecl)itemType, false, annotations);
- }
-
- /**
- * Create a new simple type which is derived by union from a list of other
- * simple types.
- *
- * @param name name of the new type, could be null
- * @param targetNamespace target namespace of the new type, could be null
- * @param finalSet value of "final"
- * @param memberTypes member types of the union type
- * @param annotations set of annotations
- * @return the newly created simple type
- */
- public XSSimpleType createTypeUnion(String name, String targetNamespace,
- short finalSet, XSSimpleType[]
memberTypes,
- XSObjectList annotations) {
- int typeNum = memberTypes.length;
- XSSimpleTypeDecl[] mtypes = new XSSimpleTypeDecl[typeNum];
- System.arraycopy(memberTypes, 0, mtypes, 0, typeNum);
-
- if (fDeclPool != null) {
- XSSimpleTypeDecl st= fDeclPool.getSimpleTypeDecl();
- return st.setUnionValues(name, targetNamespace, finalSet, mtypes,
annotations);
- }
- return new XSSimpleTypeDecl(name, targetNamespace, finalSet, mtypes,
annotations);
- }
-
public void setDeclPool (XSDeclarationPool declPool){
fDeclPool = declPool;
}
diff --git
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/EntityDV.java
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/EntityDV.java
deleted file mode 100644
index b5acac1804..0000000000
---
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/EntityDV.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.ext.xerces.impl.dv.xs;
-
-import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
-import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
-import org.apache.jena.ext.xerces.util.XercesXMLChar;
-
-/**
- * Represent the schema type "entity"
- *
- * {@literal @xerces.internal}
- *
- * @author Neeraj Bajaj, Sun Microsystems, inc.
- * @author Sandy Gao, IBM
- *
- * @version $Id: EntityDV.java 446745 2006-09-15 21:43:58Z mrglavas $
- */
-public class EntityDV extends TypeValidator {
-
- @Override
- public short getAllowedFacets(){
- return (XSSimpleTypeDecl.FACET_LENGTH |
XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH |
XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION |
XSSimpleTypeDecl.FACET_WHITESPACE );
- }
-
- @Override
- public Object getActualValue(String content, ValidationContext context)
throws InvalidDatatypeValueException {
- if (!XercesXMLChar.isValidNCName(content)) {
- throw new
InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content,
"NCName"});
- }
-
- return content;
- }
-
- @Override
- public void checkExtraRules(Object value, ValidationContext context)
throws InvalidDatatypeValueException {
- if (!context.isEntityUnparsed((String)value)) {
- throw new InvalidDatatypeValueException("UndeclaredEntity", new
Object[]{value});
- }
- }
-
-} // class EntityDV
diff --git
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/FullDVFactory.java
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/FullDVFactory.java
index 5d7c1994e6..071af6c532 100644
---
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/FullDVFactory.java
+++
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/FullDVFactory.java
@@ -78,21 +78,13 @@ public class FullDVFactory extends BaseDVFactory {
// full schema simple type names
final String DOUBLE = "double";
final String DURATION = "duration";
- final String ENTITY = "ENTITY";
- final String ENTITIES = "ENTITIES";
final String FLOAT = "float";
final String HEXBINARY = "hexBinary";
- final String ID = "ID";
- final String IDREF = "IDREF";
- final String IDREFS = "IDREFS";
final String NAME = "Name";
final String NCNAME = "NCName";
final String NMTOKEN = "NMTOKEN";
- final String NMTOKENS = "NMTOKENS";
final String LANGUAGE = "language";
final String NORMALIZEDSTRING = "normalizedString";
- final String NOTATION = "NOTATION";
- final String QNAME = "QName";
final String STRING = "string";
final String TOKEN = "token";
@@ -105,8 +97,6 @@ public class FullDVFactory extends BaseDVFactory {
types.put(DOUBLE, new XSSimpleTypeDecl(anySimpleType, DOUBLE,
XSSimpleTypeDecl.DV_DOUBLE, XSSimpleType.ORDERED_PARTIAL, true, true, true,
true, XSConstants.DOUBLE_DT));
types.put(DURATION, new XSSimpleTypeDecl(anySimpleType, DURATION,
XSSimpleTypeDecl.DV_DURATION, XSSimpleType.ORDERED_PARTIAL, false, false,
false, true, XSConstants.DURATION_DT));
types.put(HEXBINARY, new XSSimpleTypeDecl(anySimpleType, HEXBINARY,
XSSimpleTypeDecl.DV_HEXBINARY, XSSimpleType.ORDERED_FALSE, false, false, false,
true, XSConstants.HEXBINARY_DT));
- types.put(QNAME, new XSSimpleTypeDecl(anySimpleType, QNAME,
XSSimpleTypeDecl.DV_QNAME, XSSimpleType.ORDERED_FALSE, false, false, false,
true, XSConstants.QNAME_DT));
- types.put(NOTATION, new XSSimpleTypeDecl(anySimpleType, NOTATION,
XSSimpleTypeDecl.DV_NOTATION, XSSimpleType.ORDERED_FALSE, false, false, false,
true, XSConstants.NOTATION_DT));
facets.whiteSpace = XSSimpleType.WS_REPLACE;
XSSimpleTypeDecl normalizedDV = new XSSimpleTypeDecl(stringDV,
NORMALIZEDSTRING , URI_SCHEMAFORSCHEMA, (short)0, false, null,
XSConstants.NORMALIZEDSTRING_DT);
@@ -134,36 +124,10 @@ public class FullDVFactory extends BaseDVFactory {
ncnameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0,
XSSimpleTypeDecl.SPECIAL_PATTERN_NCNAME);
types.put(NCNAME, ncnameDV);
- types.put(ID, new XSSimpleTypeDecl(ncnameDV, ID,
XSSimpleTypeDecl.DV_ID, XSSimpleType.ORDERED_FALSE, false, false, false , true,
XSConstants.ID_DT));
- XSSimpleTypeDecl idrefDV = new XSSimpleTypeDecl(ncnameDV, IDREF ,
XSSimpleTypeDecl.DV_IDREF, XSSimpleType.ORDERED_FALSE, false, false, false,
true, XSConstants.IDREF_DT);
- types.put(IDREF, idrefDV);
-
- facets.minLength = 1;
- XSSimpleTypeDecl tempDV = new XSSimpleTypeDecl(null,
URI_SCHEMAFORSCHEMA, (short)0, idrefDV, true, null);
- XSSimpleTypeDecl idrefsDV = new XSSimpleTypeDecl(tempDV, IDREFS,
URI_SCHEMAFORSCHEMA, (short)0, false, null);
- idrefsDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
- types.put(IDREFS, idrefsDV);
-
- XSSimpleTypeDecl entityDV = new XSSimpleTypeDecl(ncnameDV, ENTITY ,
XSSimpleTypeDecl.DV_ENTITY, XSSimpleType.ORDERED_FALSE, false, false, false,
true, XSConstants.ENTITY_DT);
- types.put(ENTITY, entityDV);
-
- facets.minLength = 1;
- tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0,
entityDV, true, null);
- XSSimpleTypeDecl entitiesDV = new XSSimpleTypeDecl(tempDV, ENTITIES,
URI_SCHEMAFORSCHEMA, (short)0, false, null);
- entitiesDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH,
(short)0);
- types.put(ENTITIES, entitiesDV);
-
-
facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
XSSimpleTypeDecl nmtokenDV = new XSSimpleTypeDecl(tokenDV, NMTOKEN,
URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NMTOKEN_DT);
nmtokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE,
(short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NMTOKEN);
types.put(NMTOKEN, nmtokenDV);
-
- facets.minLength = 1;
- tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0,
nmtokenDV, true, null);
- XSSimpleTypeDecl nmtokensDV = new XSSimpleTypeDecl(tempDV, NMTOKENS,
URI_SCHEMAFORSCHEMA, (short)0, false, null);
- nmtokensDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH,
(short)0);
- types.put(NMTOKENS, nmtokensDV);
}//createBuiltInTypes(SymbolHash)
}//XFormsDVFactory
diff --git
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IDDV.java
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IDDV.java
deleted file mode 100644
index 7c9a813c47..0000000000
--- a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IDDV.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.ext.xerces.impl.dv.xs;
-
-import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
-import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
-import org.apache.jena.ext.xerces.util.XercesXMLChar;
-
-/**
- * Represent the schema type "ID"
- *
- * {@literal @xerces.internal}
- *
- * @author Neeraj Bajaj, Sun Microsystems, inc.
- * @author Sandy Gao, IBM
- *
- * @version $Id: IDDV.java 699892 2008-09-28 21:08:27Z mrglavas $
- */
-public class IDDV extends TypeValidator{
-
- @Override
- public short getAllowedFacets(){
- return (XSSimpleTypeDecl.FACET_LENGTH |
XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH |
XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION |
XSSimpleTypeDecl.FACET_WHITESPACE );
- }
-
- @Override
- public Object getActualValue(String content, ValidationContext context)
throws InvalidDatatypeValueException {
- if (!XercesXMLChar.isValidNCName(content)) {
- throw new
InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content,
"NCName"});
- }
- return content;
- }
-
- @Override
- public void checkExtraRules(Object value, ValidationContext context)
throws InvalidDatatypeValueException {
- String content = (String)value;
- if (context.isIdDeclared(content))
- throw new InvalidDatatypeValueException("cvc-id.2", new
Object[]{content});
- context.addId(content);
- }
-} // class IDDV
diff --git
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IDREFDV.java
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IDREFDV.java
deleted file mode 100644
index 3fbe01a724..0000000000
--- a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/IDREFDV.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.ext.xerces.impl.dv.xs;
-
-import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
-import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
-import org.apache.jena.ext.xerces.util.XercesXMLChar;
-
-/**
- * Represent the schema type "IDREF"
- *
- * {@literal @xerces.internal}
- *
- * @author Neeraj Bajaj, Sun Microsystems, inc.
- * @author Sandy Gao, IBM
- *
- * @version $Id: IDREFDV.java 446745 2006-09-15 21:43:58Z mrglavas $
- */
-public class IDREFDV extends TypeValidator{
-
- @Override
- public short getAllowedFacets(){
- return (XSSimpleTypeDecl.FACET_LENGTH |
XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH |
XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION |
XSSimpleTypeDecl.FACET_WHITESPACE );
- }
-
- @Override
- public Object getActualValue(String content, ValidationContext context)
throws InvalidDatatypeValueException {
- if (!XercesXMLChar.isValidNCName(content)) {
- throw new
InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content,
"NCName"});
- }
- return content;
- }
-
- @Override
- public void checkExtraRules(Object value, ValidationContext context)
throws InvalidDatatypeValueException {
- context.addIdRef((String)value);
- }
-
-}//IDREF class
-
diff --git
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/ListDV.java
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/ListDV.java
deleted file mode 100644
index 6b87112cda..0000000000
--- a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/ListDV.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.ext.xerces.impl.dv.xs;
-
-import java.util.AbstractList;
-
-import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
-import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
-import org.apache.jena.ext.xerces.xs.datatypes.ObjectList;
-
-/**
- * Represent the schema list types
- *
- * {@literal @xerces.internal}
- *
- * @author Neeraj Bajaj, Sun Microsystems, inc.
- * @author Sandy Gao, IBM
- *
- * @version $Id: ListDV.java 725840 2008-12-11 22:19:06Z mrglavas $
- */
-public class ListDV extends TypeValidator{
-
- @Override
- public short getAllowedFacets(){
- return (XSSimpleTypeDecl.FACET_LENGTH |
XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH |
XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION |
XSSimpleTypeDecl.FACET_WHITESPACE );
- }
-
- // this method should never be called: XSSimpleTypeDecl is responsible for
- // calling the item type for the convertion
- @Override
- public Object getActualValue(String content, ValidationContext context)
throws InvalidDatatypeValueException{
- return content;
- }
-
- // length of a list type is the number of items in the list
- @Override
- public int getDataLength(Object value) {
- return ((ListData)value).getLength();
- }
-
- final static class ListData extends AbstractList<Object> implements
ObjectList {
- final Object[] data;
- private String canonical;
- public ListData(Object[] data) {
- this.data = data;
- }
- @Override
- public synchronized String toString() {
- if (canonical == null) {
- int len = data.length;
- StringBuffer buf = new StringBuffer();
- if (len > 0) {
- buf.append(data[0].toString());
- }
- for (int i = 1; i < len; i++) {
- buf.append(' ');
- buf.append(data[i].toString());
- }
- canonical = buf.toString();
- }
- return canonical;
- }
- @Override
- public int getLength() {
- return data.length;
- }
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof ListData))
- return false;
- Object[] odata = ((ListData)obj).data;
-
- int count = data.length;
- if (count != odata.length)
- return false;
-
- for (int i = 0 ; i < count ; i++) {
- if (!data[i].equals(odata[i]))
- return false;
- }//end of loop
-
- //everything went fine.
- return true;
- }
-
- @Override
- public int hashCode() {
- int hash = 0;
- for (int i = 0; i < data.length; ++i) {
- hash ^= data[i].hashCode();
- }
- return hash;
- }
-
- @Override
- public boolean contains(Object item) {
- for (int i = 0;i < data.length; i++) {
- if (item == data[i]) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public Object item(int index) {
- if (index < 0 || index >= data.length) {
- return null;
- }
- return data[index];
- }
-
- /*
- * List methods
- */
-
- @Override
- public Object get(int index) {
- if (index >= 0 && index < data.length) {
- return data[index];
- }
- throw new IndexOutOfBoundsException("Index: " + index);
- }
-
- @Override
- public int size() {
- return getLength();
- }
- }
-} // class ListDV
-
diff --git
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/QNameDV.java
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/QNameDV.java
deleted file mode 100644
index 38e6e8c414..0000000000
--- a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/QNameDV.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.ext.xerces.impl.dv.xs;
-
-import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
-import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
-import org.apache.jena.ext.xerces.xni.QName;
-import org.apache.jena.ext.xerces.xs.datatypes.XSQName;
-import org.apache.jena.ext.xerces.util.XercesXMLChar;
-
-/**
- * Represent the schema type "QName" and "NOTATION"
- *
- * {@literal @xerces.internal}
- *
- * @author Neeraj Bajaj, Sun Microsystems, inc.
- * @author Sandy Gao, IBM
- *
- * @version $Id: QNameDV.java 701915 2008-10-06 02:39:42Z mrglavas $
- */
-public class QNameDV extends TypeValidator {
-
- private static final String EMPTY_STRING = "".intern();
-
- @Override
- public short getAllowedFacets() {
- return (XSSimpleTypeDecl.FACET_LENGTH |
XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH |
XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION |
XSSimpleTypeDecl.FACET_WHITESPACE);
- }
-
- @Override
- public Object getActualValue(String content, ValidationContext context)
- throws InvalidDatatypeValueException {
-
- // "prefix:localpart" or "localpart"
- // get prefix and local part out of content
- String prefix, localpart;
- int colonptr = content.indexOf(":");
- if (colonptr > 0) {
- prefix = context.getSymbol(content.substring(0,colonptr));
- localpart = content.substring(colonptr+1);
- } else {
- prefix = EMPTY_STRING;
- localpart = content;
- }
-
- // both prefix (if any) a nd localpart must be valid NCName
- if (prefix.length() > 0 && !XercesXMLChar.isValidNCName(prefix))
- throw new
InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content,
"QName"});
-
- if(!XercesXMLChar.isValidNCName(localpart))
- throw new
InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content,
"QName"});
-
- // resove prefix to a uri, report an error if failed
- String uri = context.getURI(prefix);
- if (prefix.length() > 0 && uri == null)
- throw new InvalidDatatypeValueException("UndeclaredPrefix", new
Object[]{content, prefix});
-
- return new XQName(prefix, context.getSymbol(localpart),
context.getSymbol(content), uri);
-
- }
-
- // REVISIT: qname and notation shouldn't support length facets.
- // now we just return the length of the rawname
- @Override
- public int getDataLength(Object value) {
- return ((XQName)value).rawname.length();
- }
-
- /**
- * represent QName data
- */
- private static final class XQName extends QName implements XSQName {
- /** Constructs a QName with the specified values. */
- public XQName(String prefix, String localpart, String rawname, String
uri) {
- setValues(prefix, localpart, rawname, uri);
- } // <init>(String,String,String,String)
-
- /** Returns true if the two objects are equal. */
- @Override
- public boolean equals(Object object) {
- if (object instanceof QName) {
- QName qname = (QName)object;
- return uri == qname.uri && localpart == qname.localpart;
- }
- return false;
- } // equals(Object):boolean
-
- @Override
- public String toString() {
- return rawname;
- }
- @Override
- public javax.xml.namespace.QName getJAXPQName() {
- return new javax.xml.namespace.QName(uri, localpart, prefix);
- }
- @Override
- public QName getXNIQName() {
- return this;
- }
- }
-} // class QNameDVDV
diff --git
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/UnionDV.java
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/UnionDV.java
deleted file mode 100644
index 7f3c1330e0..0000000000
--- a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/UnionDV.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.ext.xerces.impl.dv.xs;
-
-import org.apache.jena.ext.xerces.impl.dv.InvalidDatatypeValueException;
-import org.apache.jena.ext.xerces.impl.dv.ValidationContext;
-
-/**
- * Represent the schema union types
- *
- * {@literal @xerces.internal}
- *
- * @author Neeraj Bajaj, Sun Microsystems, inc.
- * @author Sandy Gao, IBM
- *
- * @version $Id: UnionDV.java 446745 2006-09-15 21:43:58Z mrglavas $
- */
-public class UnionDV extends TypeValidator{
-
- @Override
- public short getAllowedFacets(){
- return (XSSimpleTypeDecl.FACET_PATTERN |
XSSimpleTypeDecl.FACET_ENUMERATION );
- }
-
- // this method should never be called: XSSimpleTypeDecl is responsible for
- // calling the member types for the convertion
- @Override
- public Object getActualValue(String content, ValidationContext context)
throws InvalidDatatypeValueException{
- return content;
- }
-
-} // class UnionDV
diff --git
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/XSSimpleTypeDecl.java
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/XSSimpleTypeDecl.java
index 0d23e1368b..49b655e774 100644
---
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/XSSimpleTypeDecl.java
+++
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/XSSimpleTypeDecl.java
@@ -20,7 +20,6 @@ package org.apache.jena.ext.xerces.impl.dv.xs;
import java.math.BigInteger;
import java.util.AbstractList;
import java.util.Locale;
-import java.util.StringTokenizer;
import java.util.Vector;
import org.apache.jena.ext.xerces.impl.Constants;
@@ -48,6 +47,7 @@ import org.w3c.dom.TypeInfo;
@SuppressWarnings({"unchecked", "rawtypes"})
public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo {
+ protected static final short DV_ANYSIMPLETYPE = PRIMITIVE_ANYSIMPLETYPE;
protected static final short DV_STRING = PRIMITIVE_STRING;
protected static final short DV_BOOLEAN = PRIMITIVE_BOOLEAN;
protected static final short DV_DECIMAL = PRIMITIVE_DECIMAL;
@@ -65,21 +65,13 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
protected static final short DV_HEXBINARY = PRIMITIVE_HEXBINARY;
protected static final short DV_BASE64BINARY = PRIMITIVE_BASE64BINARY;
protected static final short DV_ANYURI = PRIMITIVE_ANYURI;
- protected static final short DV_QNAME = PRIMITIVE_QNAME;
protected static final short DV_PRECISIONDECIMAL =
PRIMITIVE_PRECISIONDECIMAL;
- protected static final short DV_NOTATION = PRIMITIVE_NOTATION;
-
- protected static final short DV_ANYSIMPLETYPE = 0;
- protected static final short DV_ID = DV_NOTATION + 1;
- protected static final short DV_IDREF = DV_NOTATION + 2;
- protected static final short DV_ENTITY = DV_NOTATION + 3;
- protected static final short DV_INTEGER = DV_NOTATION + 4;
- protected static final short DV_LIST = DV_NOTATION + 5;
- protected static final short DV_UNION = DV_NOTATION + 6;
- protected static final short DV_YEARMONTHDURATION = DV_NOTATION + 7;
- protected static final short DV_DAYTIMEDURATION = DV_NOTATION + 8;
- protected static final short DV_ANYATOMICTYPE = DV_NOTATION + 9;
- protected static final short DV_DATETIMESTAMP = DV_NOTATION + 10;
+
+ protected static final short DV_INTEGER = DV_PRECISIONDECIMAL + 1;
+ protected static final short DV_YEARMONTHDURATION = DV_PRECISIONDECIMAL +
2;
+ protected static final short DV_DAYTIMEDURATION = DV_PRECISIONDECIMAL +
3;
+ protected static final short DV_ANYATOMICTYPE = DV_PRECISIONDECIMAL + 4;
+ protected static final short DV_DATETIMESTAMP = DV_PRECISIONDECIMAL + 5;
private static final TypeValidator[] gDVs = {
new AnySimpleDV(),
@@ -100,15 +92,8 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
new HexBinaryDV(),
new Base64BinaryDV(),
new AnyURIDV(),
- new QNameDV(),
new PrecisionDecimalDV(), // XML Schema 1.1 type
- new QNameDV(), // NOTATION -- use the same one as qname
- new IDDV(),
- new IDREFDV(),
- new EntityDV(),
new IntegerDV(),
- new ListDV(),
- new UnionDV(),
new YearMonthDurationDV(), // XML Schema 1.1 type
new DayTimeDurationDV(), // XML Schema 1.1 type
new AnyAtomicDV(), // XML Schema 1.1 type
@@ -137,15 +122,8 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
NORMALIZE_TRIM, //HexBinaryDV(),
NORMALIZE_NONE, //Base64BinaryDV(), // Base64 know how to deal with
spaces
NORMALIZE_TRIM, //AnyURIDV(),
- NORMALIZE_TRIM, //QNameDV(),
NORMALIZE_TRIM, //PrecisionDecimalDV() (Schema 1.1)
- NORMALIZE_TRIM, //QNameDV(), // notation
- NORMALIZE_TRIM, //IDDV(),
- NORMALIZE_TRIM, //IDREFDV(),
- NORMALIZE_TRIM, //EntityDV(),
NORMALIZE_TRIM, //IntegerDV(),
- NORMALIZE_FULL, //ListDV(),
- NORMALIZE_NONE, //UnionDV(),
NORMALIZE_TRIM, //YearMonthDurationDV() (Schema 1.1)
NORMALIZE_TRIM, //DayTimeDurationDV() (Schema 1.1)
NORMALIZE_NONE, //AnyAtomicDV() (Schema 1.1)
@@ -178,8 +156,6 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
static final int DERIVATION_ANY = 0;
static final int DERIVATION_RESTRICTION = 1;
static final int DERIVATION_EXTENSION = 2;
- static final int DERIVATION_UNION = 4;
- static final int DERIVATION_LIST = 8;
static final ValidationContext fEmptyContext = new ValidationContext() {
@Override
@@ -367,16 +343,6 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
fVariety = fBase.fVariety;
fValidationDV = fBase.fValidationDV;
- switch (fVariety) {
- case VARIETY_ATOMIC:
- break;
- case VARIETY_LIST:
- fItemType = fBase.fItemType;
- break;
- case VARIETY_UNION:
- fMemberTypes = fBase.fMemberTypes;
- break;
- }
// always inherit facets from the base.
// in case a type is created, but applyFacets is not called
@@ -420,59 +386,6 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
fBuiltInKind = base.fBuiltInKind;
}
- //Create a new simple type for list.
- protected XSSimpleTypeDecl(String name, String uri, short finalSet,
XSSimpleTypeDecl itemType, boolean isImmutable,
- XSObjectList annotations) {
- fBase = fAnySimpleType;
- fTypeName = name;
- fTargetNamespace = uri;
- fFinalSet = finalSet;
- fAnnotations = annotations;
-
- fVariety = VARIETY_LIST;
- fItemType = itemType;
- fValidationDV = DV_LIST;
- fFacetsDefined = FACET_WHITESPACE;
- fFixedFacet = FACET_WHITESPACE;
- fWhiteSpace = WS_COLLAPSE;
-
- //setting fundamental facets
- calcFundamentalFacets();
- fIsImmutable = isImmutable;
-
- // Values of this type are lists
- fBuiltInKind = XSConstants.LIST_DT;
- }
-
- //Create a new simple type for union.
- protected XSSimpleTypeDecl(String name, String uri, short finalSet,
XSSimpleTypeDecl[] memberTypes,
- XSObjectList annotations) {
- fBase = fAnySimpleType;
- fTypeName = name;
- fTargetNamespace = uri;
- fFinalSet = finalSet;
- fAnnotations = annotations;
-
- fVariety = VARIETY_UNION;
- fMemberTypes = memberTypes;
- fValidationDV = DV_UNION;
- // even for union, we set whitespace to something
- // this will never be used, but we can use fFacetsDefined to check
- // whether applyFacets() is allwwed: it's not allowed
- // if fFacetsDefined != 0
- fFacetsDefined = FACET_WHITESPACE;
- fWhiteSpace = WS_COLLAPSE;
-
- //setting fundamental facets
- calcFundamentalFacets();
- // none of the schema-defined types are unions, so just set
- // fIsImmutable to false.
- fIsImmutable = false;
-
- // No value can be of this type, so it's unavailable.
- fBuiltInKind = XSConstants.UNAVAILABLE_DT;
- }
-
//set values for restriction.
protected XSSimpleTypeDecl setRestrictionValues(XSSimpleTypeDecl base,
String name, String uri, short finalSet,
XSObjectList annotations) {
@@ -487,16 +400,6 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
fVariety = fBase.fVariety;
fValidationDV = fBase.fValidationDV;
- switch (fVariety) {
- case VARIETY_ATOMIC:
- break;
- case VARIETY_LIST:
- fItemType = fBase.fItemType;
- break;
- case VARIETY_UNION:
- fMemberTypes = fBase.fMemberTypes;
- break;
- }
// always inherit facets from the base.
// in case a type is created, but applyFacets is not called
@@ -527,65 +430,6 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
return this;
}
- //set values for list.
- protected XSSimpleTypeDecl setListValues(String name, String uri, short
finalSet, XSSimpleTypeDecl itemType,
- XSObjectList annotations) {
- //decline to do anything if the object is immutable.
- if(fIsImmutable) return null;
- fBase = fAnySimpleType;
- fAnonymous = false;
- fTypeName = name;
- fTargetNamespace = uri;
- fFinalSet = finalSet;
- fAnnotations = annotations;
-
- fVariety = VARIETY_LIST;
- fItemType = itemType;
- fValidationDV = DV_LIST;
- fFacetsDefined = FACET_WHITESPACE;
- fFixedFacet = FACET_WHITESPACE;
- fWhiteSpace = WS_COLLAPSE;
-
- //setting fundamental facets
- calcFundamentalFacets();
-
- // Values of this type are lists
- fBuiltInKind = XSConstants.LIST_DT;
-
- return this;
- }
-
- //set values for union.
- protected XSSimpleTypeDecl setUnionValues(String name, String uri, short
finalSet, XSSimpleTypeDecl[] memberTypes,
- XSObjectList annotations) {
- //decline to do anything if the object is immutable.
- if(fIsImmutable) return null;
- fBase = fAnySimpleType;
- fAnonymous = false;
- fTypeName = name;
- fTargetNamespace = uri;
- fFinalSet = finalSet;
- fAnnotations = annotations;
-
- fVariety = VARIETY_UNION;
- fMemberTypes = memberTypes;
- fValidationDV = DV_UNION;
- // even for union, we set whitespace to something
- // this will never be used, but we can use fFacetsDefined to check
- // whether applyFacets() is allwwed: it's not allowed
- // if fFacetsDefined != 0
- fFacetsDefined = FACET_WHITESPACE;
- fWhiteSpace = WS_COLLAPSE;
-
- //setting fundamental facets
- calcFundamentalFacets();
-
- // No value can be of this type, so it's unavailable.
- fBuiltInKind = XSConstants.UNAVAILABLE_DT;
-
- return this;
- }
-
@Override
public short getType () {
return XSConstants.TYPE_DEFINITION;
@@ -638,51 +482,10 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
}
@Override
- public boolean isIDType(){
- switch (fVariety) {
- case VARIETY_ATOMIC:
- return fValidationDV == DV_ID;
- case VARIETY_LIST:
- return fItemType.isIDType();
- case VARIETY_UNION:
- for (int i = 0; i < fMemberTypes.length; i++) {
- if (fMemberTypes[i].isIDType())
- return true;
- }
- }
- return false;
- }
-
- @Override
- public short getWhitespace() throws DatatypeException{
- if (fVariety == VARIETY_UNION) {
- throw new DatatypeException("dt-whitespace", new
Object[]{fTypeName});
- }
+ public short getWhitespace() {
return fWhiteSpace;
}
- @Override
- public short getPrimitiveKind() {
- if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
- if (fValidationDV == DV_ID || fValidationDV == DV_IDREF ||
fValidationDV == DV_ENTITY) {
- return DV_STRING;
- }
- else if (fValidationDV == DV_INTEGER) {
- return DV_DECIMAL;
- }
- else if (Constants.SCHEMA_1_1_SUPPORT && (fValidationDV ==
DV_YEARMONTHDURATION || fValidationDV == DV_DAYTIMEDURATION)) {
- return DV_DURATION;
- }
- else {
- return fValidationDV;
- }
- }
- else {
- // REVISIT: error situation. runtime exception?
- return (short)0;
- }
- }
-
/**
* Returns the closest built-in type category this type represents or
* derived from. For example, if this simple type is a built-in derived
@@ -713,37 +516,6 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
}
}
- /**
- * If variety is <code>list</code> the item type definition (an atomic or
- * union simple type definition) is available, otherwise
- * <code>null</code>.
- */
- @Override
- public XSSimpleTypeDefinition getItemType() {
- if (fVariety == VARIETY_LIST) {
- return fItemType;
- }
- else {
- // REVISIT: error situation. runtime exception?
- return null;
- }
- }
-
- /**
- * If variety is <code>union</code> the list of member type definitions (a
- * non-empty sequence of simple type definitions) is available,
- * otherwise an empty <code>XSObjectList</code>.
- */
- @Override
- public XSObjectList getMemberTypes() {
- if (fVariety == VARIETY_UNION) {
- return new XSObjectListImpl(fMemberTypes, fMemberTypes.length);
- }
- else {
- return XSObjectListImpl.EMPTY_LIST;
- }
- }
-
/**
* If <restriction> is chosen
*/
@@ -1658,35 +1430,6 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
short type = validatedInfo.actualValueType;
ShortList itemType = validatedInfo.itemValueTypes;
- // For QName and NOTATION types, we don't check length facets
- if (fValidationDV != DV_QNAME && fValidationDV != DV_NOTATION) {
- int length = fDVs[fValidationDV].getDataLength(ob);
-
- // maxLength
- if ( (fFacetsDefined & FACET_MAXLENGTH) != 0 ) {
- if ( length > fMaxLength ) {
- throw new
InvalidDatatypeValueException("cvc-maxLength-valid",
- new Object[]{content, Integer.toString(length),
Integer.toString(fMaxLength), fTypeName});
- }
- }
-
- //minLength
- if ( (fFacetsDefined & FACET_MINLENGTH) != 0 ) {
- if ( length < fMinLength ) {
- throw new
InvalidDatatypeValueException("cvc-minLength-valid",
- new Object[]{content, Integer.toString(length),
Integer.toString(fMinLength), fTypeName});
- }
- }
-
- //length
- if ( (fFacetsDefined & FACET_LENGTH) != 0 ) {
- if ( length != fLength ) {
- throw new InvalidDatatypeValueException("cvc-length-valid",
- new Object[]{content, Integer.toString(length),
Integer.toString(fLength), fTypeName});
- }
- }
- }
-
//enumeration
if ( ((fFacetsDefined & FACET_ENUMERATION) != 0 ) ) {
boolean present = false;
@@ -1794,44 +1537,8 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
}
private void checkExtraRules(ValidationContext context, ValidatedInfo
validatedInfo) throws InvalidDatatypeValueException {
-
Object ob = validatedInfo.actualValue;
-
- if (fVariety == VARIETY_ATOMIC) {
-
- fDVs[fValidationDV].checkExtraRules(ob, context);
-
- } else if (fVariety == VARIETY_LIST) {
-
- ListDV.ListData values = (ListDV.ListData)ob;
- XSSimpleType memberType = validatedInfo.memberType;
- int len = values.getLength();
- try {
- if (fItemType.fVariety == VARIETY_UNION) {
- XSSimpleTypeDecl[] memberTypes =
(XSSimpleTypeDecl[])validatedInfo.memberTypes;
- for (int i = len-1; i >= 0; i--) {
- validatedInfo.actualValue = values.item(i);
- validatedInfo.memberType = memberTypes[i];
- fItemType.checkExtraRules(context, validatedInfo);
- }
- } else { // (fVariety == VARIETY_ATOMIC)
- for (int i = len-1; i >= 0; i--) {
- validatedInfo.actualValue = values.item(i);
- fItemType.checkExtraRules(context, validatedInfo);
- }
- }
- }
- finally {
- validatedInfo.actualValue = values;
- validatedInfo.memberType = memberType;
- }
-
- } else { // (fVariety == VARIETY_UNION)
-
-
((XSSimpleTypeDecl)validatedInfo.memberType).checkExtraRules(context,
validatedInfo);
-
- }
-
+ fDVs[fValidationDV].checkExtraRules(ob, context);
}// checkExtraRules()
//we can still return object for internal use.
@@ -1839,140 +1546,55 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
ValidatedInfo validatedInfo, boolean needNormalize)
throws InvalidDatatypeValueException{
- String nvalue;
- if (needNormalize) {
- nvalue = normalize(content, fWhiteSpace);
- } else {
- nvalue = content.toString();
- }
- if ( (fFacetsDefined & FACET_PATTERN ) != 0 ) {
- RegularExpression regex;
- for (int idx = fPattern.size()-1; idx >= 0; idx--) {
- regex = (RegularExpression)fPattern.elementAt(idx);
- if (!regex.matches(nvalue)){
- throw new
InvalidDatatypeValueException("cvc-pattern-valid",
- new Object[]{content,
- fPatternStr.elementAt(idx),
-
- fTypeName});
- }
+ String nvalue;
+ if (needNormalize) {
+ nvalue = normalize(content, fWhiteSpace);
+ } else {
+ nvalue = content.toString();
+ }
+ if ( (fFacetsDefined & FACET_PATTERN ) != 0 ) {
+ RegularExpression regex;
+ for (int idx = fPattern.size()-1; idx >= 0; idx--) {
+ regex = (RegularExpression)fPattern.elementAt(idx);
+ if (!regex.matches(nvalue)){
+ throw new InvalidDatatypeValueException("cvc-pattern-valid",
+ new Object[]{content,
+ fPatternStr.elementAt(idx),
+
+ fTypeName});
}
}
+ }
- if (fVariety == VARIETY_ATOMIC) {
-
- // validate special kinds of token, in place of old pattern
matching
- if (fPatternType != SPECIAL_PATTERN_NONE) {
+ // validate special kinds of token, in place of old pattern matching
+ if (fPatternType != SPECIAL_PATTERN_NONE) {
- boolean seenErr = false;
- if (fPatternType == SPECIAL_PATTERN_NMTOKEN) {
- // PATTERN "\\c+"
- seenErr = !XercesXMLChar.isValidNmtoken(nvalue);
- }
- else if (fPatternType == SPECIAL_PATTERN_NAME) {
- // PATTERN "\\i\\c*"
- seenErr = !XercesXMLChar.isValidName(nvalue);
- }
- else if (fPatternType == SPECIAL_PATTERN_NCNAME) {
- // PATTERN "[\\i-[:]][\\c-[:]]*"
- seenErr = !XercesXMLChar.isValidNCName(nvalue);
- }
- if (seenErr) {
- throw new
InvalidDatatypeValueException("cvc-datatype-valid.1.2.1",
- new Object[]{nvalue,
SPECIAL_PATTERN_STRING[fPatternType]});
- }
+ boolean seenErr = false;
+ if (fPatternType == SPECIAL_PATTERN_NMTOKEN) {
+ // PATTERN "\\c+"
+ seenErr = !XercesXMLChar.isValidNmtoken(nvalue);
}
-
- validatedInfo.normalizedValue = nvalue;
- Object avalue = fDVs[fValidationDV].getActualValue(nvalue,
context);
- validatedInfo.actualValue = avalue;
- validatedInfo.actualValueType = fBuiltInKind;
- validatedInfo.actualType = this;
-
- return avalue;
-
- } else if (fVariety == VARIETY_LIST) {
-
- StringTokenizer parsedList = new StringTokenizer(nvalue, " ");
- int countOfTokens = parsedList.countTokens() ;
- Object[] avalue = new Object[countOfTokens];
- boolean isUnion = fItemType.getVariety() == VARIETY_UNION;
- short[] itemTypes = new short[isUnion ? countOfTokens : 1];
- if (!isUnion)
- itemTypes[0] = fItemType.fBuiltInKind;
- XSSimpleTypeDecl[] memberTypes = new
XSSimpleTypeDecl[countOfTokens];
- for(int i = 0 ; i < countOfTokens ; i ++){
- // we can't call fItemType.validate(), otherwise
checkExtraRules()
- // will be called twice: once in fItemType.validate, once in
- // validate method of this type.
- // so we take two steps to get the actual value:
- // 1. fItemType.getActualValue()
- // 2. fItemType.chekcFacets()
- avalue[i] = fItemType.getActualValue(parsedList.nextToken(),
context, validatedInfo, false);
- if (context.needFacetChecking() &&
- (fItemType.fFacetsDefined != 0 &&
fItemType.fFacetsDefined != FACET_WHITESPACE)) {
- fItemType.checkFacets(validatedInfo);
- }
- memberTypes[i] = (XSSimpleTypeDecl)validatedInfo.memberType;
- if (isUnion)
- itemTypes[i] = memberTypes[i].fBuiltInKind;
+ else if (fPatternType == SPECIAL_PATTERN_NAME) {
+ // PATTERN "\\i\\c*"
+ seenErr = !XercesXMLChar.isValidName(nvalue);
}
-
- ListDV.ListData v = new ListDV.ListData(avalue);
- validatedInfo.actualValue = v;
- validatedInfo.actualValueType = isUnion ?
XSConstants.LISTOFUNION_DT : XSConstants.LIST_DT;
- validatedInfo.memberType = null;
- validatedInfo.memberTypes = memberTypes;
- validatedInfo.itemValueTypes = new ShortListImpl(itemTypes,
itemTypes.length);
- validatedInfo.normalizedValue = nvalue;
- // Need to set it here or it will become the item type
- validatedInfo.actualType = this;
-
- return v;
-
- } else { // (fVariety == VARIETY_UNION)
- final Object _content = (fMemberTypes.length > 1 && content !=
null) ? content.toString() : content;
- for (int i = 0; i < fMemberTypes.length; i++) {
- try {
- // we can't call fMemberType[i].validate(), otherwise
checkExtraRules()
- // will be called twice: once in fMemberType[i].validate,
once in
- // validate method of this type.
- // so we take two steps to get the actual value:
- // 1. fMemberType[i].getActualValue()
- // 2. fMemberType[i].chekcFacets()
- Object aValue = fMemberTypes[i].getActualValue(_content,
context, validatedInfo, true);
- if (context.needFacetChecking() &&
- (fMemberTypes[i].fFacetsDefined != 0 &&
fMemberTypes[i].fFacetsDefined != FACET_WHITESPACE)) {
- fMemberTypes[i].checkFacets(validatedInfo);
- }
- validatedInfo.memberType = fMemberTypes[i];
- // Need to set it here or it will become the member type
- validatedInfo.actualType = this;
- return aValue;
- } catch(InvalidDatatypeValueException invalidValue) {
- }
+ else if (fPatternType == SPECIAL_PATTERN_NCNAME) {
+ // PATTERN "[\\i-[:]][\\c-[:]]*"
+ seenErr = !XercesXMLChar.isValidNCName(nvalue);
}
- StringBuffer typesBuffer = new StringBuffer();
- XSSimpleTypeDecl decl;
- for(int i = 0;i < fMemberTypes.length; i++) {
- if(i != 0)
- typesBuffer.append(" | ");
- decl = fMemberTypes[i];
- if(decl.fTargetNamespace != null) {
- typesBuffer.append('{');
- typesBuffer.append(decl.fTargetNamespace);
- typesBuffer.append('}');
- }
- typesBuffer.append(decl.fTypeName);
- if(decl.fEnumeration != null) {
- typesBuffer.append(" : ");
- decl.appendEnumString(typesBuffer);
- }
+ if (seenErr) {
+ throw new
InvalidDatatypeValueException("cvc-datatype-valid.1.2.1",
+ new Object[]{nvalue,
SPECIAL_PATTERN_STRING[fPatternType]});
}
- throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3",
- new Object[]{content, fTypeName, typesBuffer.toString()});
}
+ validatedInfo.normalizedValue = nvalue;
+ Object avalue = fDVs[fValidationDV].getActualValue(nvalue, context);
+ validatedInfo.actualValue = avalue;
+ validatedInfo.actualValueType = fBuiltInKind;
+ validatedInfo.actualType = this;
+
+ return avalue;
}//getActualValue()
@Override
@@ -2417,110 +2039,22 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
}
private void setOrdered(){
-
// When {variety} is atomic, {value} is inherited from {value} of
{base type definition}. For all "primitive" types {value} is as specified in
the table in Fundamental Facets (C.1).
- if(fVariety == VARIETY_ATOMIC){
- this.fOrdered = fBase.fOrdered;
- }
-
- // When {variety} is list, {value} is false.
- else if(fVariety == VARIETY_LIST){
- this.fOrdered = ORDERED_FALSE;
- }
-
- // When {variety} is union, the {value} is partial unless one of the
following:
- // 1. If every member of {member type definitions} is derived from a
common ancestor other than the simple ur-type, then {value} is the same as that
ancestor's ordered facet.
- // 2. If every member of {member type definitions} has a {value} of
false for the ordered facet, then {value} is false.
- else if(fVariety == VARIETY_UNION){
- int length = fMemberTypes.length;
- // REVISIT: is the length possible to be 0?
- if (length == 0) {
- this.fOrdered = ORDERED_PARTIAL;
- return;
- }
- // we need to process the first member type before entering the
loop
- short ancestorId = getPrimitiveDV(fMemberTypes[0].fValidationDV);
- boolean commonAnc = ancestorId != DV_ANYSIMPLETYPE;
- boolean allFalse = fMemberTypes[0].fOrdered == ORDERED_FALSE;
- // for the other member types, check whether the value is false
- // and whether they have the same ancestor as the first one
- for (int i = 1; i < fMemberTypes.length && (commonAnc ||
allFalse); i++) {
- if (commonAnc)
- commonAnc = ancestorId ==
getPrimitiveDV(fMemberTypes[i].fValidationDV);
- if (allFalse)
- allFalse = fMemberTypes[i].fOrdered == ORDERED_FALSE;
- }
- if (commonAnc) {
- // REVISIT: all member types should have the same ordered value
- // just use the first one. Can we assume this?
- this.fOrdered = fMemberTypes[0].fOrdered;
- } else if (allFalse) {
- this.fOrdered = ORDERED_FALSE;
- } else {
- this.fOrdered = ORDERED_PARTIAL;
- }
- }
-
+ this.fOrdered = fBase.fOrdered;
}//setOrdered
private void setNumeric(){
- if(fVariety == VARIETY_ATOMIC){
- this.fNumeric = fBase.fNumeric;
- }
- else if(fVariety == VARIETY_LIST){
- this.fNumeric = false;
- }
- else if(fVariety == VARIETY_UNION){
- XSSimpleType[] memberTypes = fMemberTypes;
- for(int i = 0 ; i < memberTypes.length ; i++){
- if(!memberTypes[i].getNumeric() ){
- this.fNumeric = false;
- return;
- }
- }
- this.fNumeric = true;
- }
-
+ this.fNumeric = fBase.fNumeric;
}//setNumeric
private void setBounded(){
- if(fVariety == VARIETY_ATOMIC){
- if( (((this.fFacetsDefined & FACET_MININCLUSIVE) != 0) ||
((this.fFacetsDefined & FACET_MINEXCLUSIVE) != 0))
- && (((this.fFacetsDefined & FACET_MAXINCLUSIVE) != 0) ||
((this.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0)) ){
- this.fBounded = true;
- }
- else{
- this.fBounded = false;
- }
- }
- else if(fVariety == VARIETY_LIST){
- if( ((this.fFacetsDefined & FACET_LENGTH) != 0 ) || (
((this.fFacetsDefined & FACET_MINLENGTH) != 0 )
- && ((this.fFacetsDefined & FACET_MAXLENGTH) != 0 )) ){
- this.fBounded = true;
- }
- else{
- this.fBounded = false;
- }
-
- }
- else if(fVariety == VARIETY_UNION){
-
- XSSimpleTypeDecl [] memberTypes = this.fMemberTypes;
- short ancestorId = 0 ;
-
- if(memberTypes.length > 0){
- ancestorId = getPrimitiveDV(memberTypes[0].fValidationDV);
- }
-
- for(int i = 0 ; i < memberTypes.length ; i++){
- if(!memberTypes[i].getBounded() || (ancestorId !=
getPrimitiveDV(memberTypes[i].fValidationDV)) ){
- this.fBounded = false;
- return;
- }
- }
+ if( (((this.fFacetsDefined & FACET_MININCLUSIVE) != 0) ||
((this.fFacetsDefined & FACET_MINEXCLUSIVE) != 0))
+ && (((this.fFacetsDefined & FACET_MAXINCLUSIVE) != 0) ||
((this.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0)) ){
this.fBounded = true;
}
-
+ else{
+ this.fBounded = false;
+ }
}//setBounded
private boolean specialCardinalityCheck(){
@@ -2534,58 +2068,32 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
} //specialCardinalityCheck()
private void setCardinality(){
- if(fVariety == VARIETY_ATOMIC){
- if(fBase.fFinite){
+ if(fBase.fFinite){
+ this.fFinite = true;
+ }
+ else {// (!fBase.fFinite)
+ if ( ((this.fFacetsDefined & FACET_LENGTH) != 0 ) ||
((this.fFacetsDefined & FACET_MAXLENGTH) != 0 )
+ || ((this.fFacetsDefined & FACET_TOTALDIGITS) != 0 ) ){
this.fFinite = true;
}
- else {// (!fBase.fFinite)
- if ( ((this.fFacetsDefined & FACET_LENGTH) != 0 ) ||
((this.fFacetsDefined & FACET_MAXLENGTH) != 0 )
- || ((this.fFacetsDefined & FACET_TOTALDIGITS) != 0 ) ){
+ else if( (((this.fFacetsDefined & FACET_MININCLUSIVE) != 0 ) ||
((this.fFacetsDefined & FACET_MINEXCLUSIVE) != 0 ))
+ && (((this.fFacetsDefined & FACET_MAXINCLUSIVE) != 0 ) ||
((this.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0 )) ){
+ if( ((this.fFacetsDefined & FACET_FRACTIONDIGITS) != 0 ) ||
specialCardinalityCheck()){
this.fFinite = true;
}
- else if( (((this.fFacetsDefined & FACET_MININCLUSIVE) != 0 )
|| ((this.fFacetsDefined & FACET_MINEXCLUSIVE) != 0 ))
- && (((this.fFacetsDefined & FACET_MAXINCLUSIVE) != 0 )
|| ((this.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0 )) ){
- if( ((this.fFacetsDefined & FACET_FRACTIONDIGITS) != 0 )
|| specialCardinalityCheck()){
- this.fFinite = true;
- }
- else{
- this.fFinite = false;
- }
- }
else{
this.fFinite = false;
}
}
- }
- else if(fVariety == VARIETY_LIST){
- if( ((this.fFacetsDefined & FACET_LENGTH) != 0 ) || (
((this.fFacetsDefined & FACET_MINLENGTH) != 0 )
- && ((this.fFacetsDefined & FACET_MAXLENGTH) != 0 )) ){
- this.fFinite = true;
- }
else{
this.fFinite = false;
}
-
}
- else if(fVariety == VARIETY_UNION){
- XSSimpleType [] memberTypes = fMemberTypes;
- for(int i = 0 ; i < memberTypes.length ; i++){
- if(!(memberTypes[i].getFinite()) ){
- this.fFinite = false;
- return;
- }
- }
- this.fFinite = true;
- }
-
}//setCardinality
private short getPrimitiveDV(short validationDV){
- if (validationDV == DV_ID || validationDV == DV_IDREF || validationDV
== DV_ENTITY){
- return DV_STRING;
- }
- else if (validationDV == DV_INTEGER) {
+ if (validationDV == DV_INTEGER) {
return DV_DECIMAL;
}
else if (Constants.SCHEMA_1_1_SUPPORT && (validationDV ==
DV_YEARMONTHDURATION || validationDV == DV_DAYTIMEDURATION)) {
@@ -2683,25 +2191,9 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
}
}
- // list
- if ((derivationMethod & DERIVATION_LIST) != 0) {
- if (isDerivedByList(ancestorNS, ancestorName, this)) {
- return true;
- }
- }
-
- // union
- if ((derivationMethod & DERIVATION_UNION) != 0) {
- if (isDerivedByUnion(ancestorNS, ancestorName, this)) {
- return true;
- }
- }
-
// extension
if (((derivationMethod & DERIVATION_EXTENSION) != 0)
- && (((derivationMethod & DERIVATION_RESTRICTION) == 0)
- && ((derivationMethod & DERIVATION_LIST) == 0)
- && ((derivationMethod & DERIVATION_UNION) == 0))) {
+ && (((derivationMethod & DERIVATION_RESTRICTION) == 0))) {
return false;
}
@@ -2709,9 +2201,7 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
// restriction, list, extension or union) is set to 1 for the
// derivationMethod parameter.
if (((derivationMethod & DERIVATION_EXTENSION) == 0)
- && (((derivationMethod & DERIVATION_RESTRICTION) == 0)
- && ((derivationMethod & DERIVATION_LIST) == 0)
- && ((derivationMethod & DERIVATION_UNION) == 0))) {
+ && (((derivationMethod & DERIVATION_RESTRICTION) == 0))) {
return isDerivedByAny(ancestorNS, ancestorName, this);
}
@@ -2748,28 +2238,13 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
break;
}
- // check if derived by restriction or list or union
+ // check if derived by restriction
if (isDerivedByRestriction(ancestorNS, ancestorName, type)) {
return true;
- } else if (isDerivedByList(ancestorNS, ancestorName, type)) {
- return true;
- } else if (isDerivedByUnion(ancestorNS, ancestorName, type)) {
- return true;
}
oldType = type;
- // get the base, item or member type depending on the variety
- if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_ABSENT
- || ((XSSimpleTypeDecl) type).getVariety() ==
VARIETY_ATOMIC) {
- type = type.getBaseType();
- } else if (((XSSimpleTypeDecl) type).getVariety() ==
VARIETY_UNION) {
- for (int i = 0; i < ((XSSimpleTypeDecl)
type).getMemberTypes().getLength(); i++) {
- return isDerivedByAny(ancestorNS, ancestorName,
- (XSTypeDefinition) ((XSSimpleTypeDecl) type)
- .getMemberTypes().item(i));
- }
- } else if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_LIST)
{
- type = ((XSSimpleTypeDecl) type).getItemType();
- }
+ // get the base type
+ type = type.getBaseType();
}
return derivedFrom;
@@ -2806,73 +2281,6 @@ public class XSSimpleTypeDecl implements XSSimpleType,
TypeInfo {
return false;
}
- /**
- * Checks if a type is derived from another by list. See:
- *
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
- *
- * @param ancestorNS
- * The namspace of the ancestor type declaration
- * @param ancestorName
- * The name of the ancestor type declaration
- * @param type
- * The reference type definition
- *
- * @return boolean True if the type is derived by list for the reference
type
- */
- private boolean isDerivedByList (String ancestorNS, String ancestorName,
XSTypeDefinition type) {
- // If the variety is union
- if (type !=null && ((XSSimpleTypeDefinition)type).getVariety() ==
VARIETY_LIST) {
-
- // get the {item type}
- XSTypeDefinition itemType =
((XSSimpleTypeDefinition)type).getItemType();
-
- // T2 is the {item type definition}
- if (itemType != null) {
-
- // T2 is derived from the other type definition by
DERIVATION_RESTRICTION
- if (isDerivedByRestriction(ancestorNS, ancestorName,
itemType)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Checks if a type is derived from another by union. See:
- *
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
- *
- * @param ancestorNS
- * The namspace of the ancestor type declaration
- * @param ancestorName
- * The name of the ancestor type declaration
- * @param type
- * The reference type definition
- *
- * @return boolean True if the type is derived by union for the reference
type
- */
- private boolean isDerivedByUnion (String ancestorNS, String ancestorName,
XSTypeDefinition type) {
-
- // If the variety is union
- if (type !=null && ((XSSimpleTypeDefinition)type).getVariety() ==
VARIETY_UNION) {
-
- // get member types
- XSObjectList memberTypes =
((XSSimpleTypeDefinition)type).getMemberTypes();
-
- for (int i = 0; i < memberTypes.getLength(); i++) {
- // One of the {member type definitions} is T2.
- if (memberTypes.item(i) != null) {
- // T2 is derived from the other type definition by
DERIVATION_RESTRICTION
- if (isDerivedByRestriction(ancestorNS,
ancestorName,(XSSimpleTypeDefinition)memberTypes.item(i))) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
-
static final XSSimpleTypeDecl fAnySimpleType = new XSSimpleTypeDecl(null,
"anySimpleType", DV_ANYSIMPLETYPE, ORDERED_FALSE, false, true, false, true,
XSConstants.ANYSIMPLETYPE_DT);
static final XSSimpleTypeDecl fAnyAtomicType = new
XSSimpleTypeDecl(fAnySimpleType, "anyAtomicType", DV_ANYATOMICTYPE,
ORDERED_FALSE, false, true, false, true, XSSimpleTypeDecl.ANYATOMICTYPE_DT);
diff --git
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/XSSimpleTypeDelegate.java
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/XSSimpleTypeDelegate.java
index 520f5be70a..de5a56f11f 100644
---
a/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/XSSimpleTypeDelegate.java
+++
b/jena-core/src/main/java/org/apache/jena/ext/xerces/impl/dv/xs/XSSimpleTypeDelegate.java
@@ -83,11 +83,6 @@ public class XSSimpleTypeDelegate
return type.getFixedFacets();
}
- @Override
- public XSSimpleTypeDefinition getItemType() {
- return type.getItemType();
- }
-
@Override
public StringList getLexicalEnumeration() {
return type.getLexicalEnumeration();
@@ -103,11 +98,6 @@ public class XSSimpleTypeDelegate
return type.getLexicalPattern();
}
- @Override
- public XSObjectList getMemberTypes() {
- return type.getMemberTypes();
- }
-
@Override
public XSObjectList getMultiValueFacets() {
return type.getMultiValueFacets();
@@ -204,11 +194,6 @@ public class XSSimpleTypeDelegate
type.applyFacets(facets, presentFacet, fixedFacet, context);
}
- @Override
- public short getPrimitiveKind() {
- return type.getPrimitiveKind();
- }
-
@Override
public short getWhitespace() throws DatatypeException {
return type.getWhitespace();
@@ -219,11 +204,6 @@ public class XSSimpleTypeDelegate
return type.isEqual(value1, value2);
}
- @Override
- public boolean isIDType() {
- return type.isIDType();
- }
-
@Override
public void validate(ValidationContext context, ValidatedInfo
validatedInfo)
throws InvalidDatatypeValueException {
diff --git
a/jena-core/src/main/java/org/apache/jena/ext/xerces/xs/XSSimpleTypeDefinition.java
b/jena-core/src/main/java/org/apache/jena/ext/xerces/xs/XSSimpleTypeDefinition.java
index 0c5d23fa3a..45d660b651 100644
---
a/jena-core/src/main/java/org/apache/jena/ext/xerces/xs/XSSimpleTypeDefinition.java
+++
b/jena-core/src/main/java/org/apache/jena/ext/xerces/xs/XSSimpleTypeDefinition.java
@@ -35,14 +35,6 @@ public interface XSSimpleTypeDefinition extends
XSTypeDefinition {
* <code>Atomic</code> type.
*/
public static final short VARIETY_ATOMIC = 1;
- /**
- * <code>List</code> type.
- */
- public static final short VARIETY_LIST = 2;
- /**
- * <code>Union</code> type.
- */
- public static final short VARIETY_UNION = 3;
// Facets
/**
@@ -130,20 +122,6 @@ public interface XSSimpleTypeDefinition extends
XSTypeDefinition {
*/
public short getBuiltInKind();
- /**
- * If variety is <code>list</code> the item type definition (an atomic or
- * union simple type definition) is available, otherwise
- * <code>null</code>.
- */
- public XSSimpleTypeDefinition getItemType();
-
- /**
- * If variety is <code>union</code> the list of member type definitions (a
- * non-empty sequence of simple type definitions) is available,
- * otherwise an empty <code>XSObjectList</code>.
- */
- public XSObjectList getMemberTypes();
-
/**
* [facets]: all facets defined on this type. The value is a bit
* combination of FACET_XXX constants of all defined facets.