You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by je...@locus.apache.org on 2000/04/04 22:11:07 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/validators/schema DatatypeContentModel.java SchemaMessageProvider.java
jeffreyr 00/04/04 13:11:07
Modified: java/src/org/apache/xerces/validators/schema
DatatypeContentModel.java
SchemaMessageProvider.java
Log:
Added Tom Changes to support Schema validation
Revision Changes Path
1.2 +33 -33 xml-xerces/java/src/org/apache/xerces/validators/schema/DatatypeContentModel.java
Index: DatatypeContentModel.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/DatatypeContentModel.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DatatypeContentModel.java 1999/11/09 01:11:38 1.1
+++ DatatypeContentModel.java 2000/04/04 20:11:07 1.2
@@ -57,13 +57,13 @@
package org.apache.xerces.validators.schema;
-import org.apache.xerces.framework.XMLContentSpecNode;
+import org.apache.xerces.framework.XMLContentSpec;
import org.apache.xerces.utils.StringPool;
+import org.apache.xerces.validators.common.XMLValidator;
+import org.apache.xerces.validators.common.XMLContentModel;
+import org.apache.xerces.validators.common.InsertableElementsInfo;
import org.apache.xerces.validators.datatype.DatatypeValidator;
import org.apache.xerces.validators.datatype.InvalidDatatypeValueException;
-import org.apache.xerces.validators.dtd.XMLContentModel;
-import org.apache.xerces.validators.dtd.ElementDeclPool;
-import org.apache.xerces.validators.dtd.InsertableElementsInfo;
/**
* DatatypeContentModel provides a content model that knows
@@ -71,8 +71,8 @@
*/
public class DatatypeContentModel implements XMLContentModel
{
- XSchemaValidator.DatatypeValidatorRegistry fDatatypeRegistry = null;
- ElementDeclPool fElementDeclPool = null;
+ SchemaImporter.DatatypeValidatorRegistry fDatatypeRegistry = null;
+ XMLValidator fValidator = null;
StringPool fStringPool = null;
int fChild = -1;
@@ -82,13 +82,13 @@
/**
*/
- public DatatypeContentModel( XSchemaValidator.DatatypeValidatorRegistry reg,
- ElementDeclPool elementDeclPool,
+ public DatatypeContentModel( SchemaImporter.DatatypeValidatorRegistry reg,
+ XMLValidator validator,
StringPool stringPool,
int childIndex)
{
fDatatypeRegistry = reg;
- fElementDeclPool = elementDeclPool;
+ fValidator = validator;
fStringPool = stringPool;
fChild = childIndex;
}
@@ -129,7 +129,7 @@
System.out.println("Checking content of datatype");
String strTmp = fStringPool.toString(elementTypeIndex);
int contentSpecIndex = fElementDeclPool.getContentSpec(elementIndex);
- XMLContentSpecNode csn = new XMLContentSpecNode();
+ XMLContentSpec.Node csn = new XMLContentSpec.Node();
fElementDeclPool.getContentSpecNode(contentSpecIndex, csn);
String contentSpecString = fStringPool.toString(csn.value);
System.out.println
@@ -154,9 +154,9 @@
}
*/
try { // REVISIT - integrate w/ error handling
- int contentSpecIndex = fElementDeclPool.getContentSpec(fChild);
- XMLContentSpecNode csn = new XMLContentSpecNode();
- fElementDeclPool.getContentSpecNode(contentSpecIndex, csn);
+ XMLContentSpec cs = fValidator.getContentSpec(fChild);
+ XMLContentSpec.Node csn = new XMLContentSpec.Node();
+ cs.getNode(cs.getHandle(), csn);
String type = fStringPool.toString(csn.value);
DatatypeValidator v = fDatatypeRegistry.getValidatorFor(type);
if (v != null)
@@ -178,7 +178,7 @@
//
switch(fOp)
{
- case XMLContentSpecNode.CONTENTSPECNODE_LEAF :
+ case XMLContentSpec.CONTENTSPECNODE_LEAF :
// If there is not a child, then report an error at index 0
if (childCount == 0)
return 0;
@@ -192,7 +192,7 @@
return 1;
break;
- case XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_ONE :
+ case XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE :
//
// If there is one child, make sure its the right type. If not,
// then its an error at index 0.
@@ -208,7 +208,7 @@
return 1;
break;
- case XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_MORE :
+ case XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE :
//
// If the child count is zero, that's fine. If its more than
// zero, then make sure that all children are of the element
@@ -225,7 +225,7 @@
}
break;
- case XMLContentSpecNode.CONTENTSPECNODE_ONE_OR_MORE :
+ case XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE :
//
// If the child count is zero, that's an error so report
// an error at index 0.
@@ -245,7 +245,7 @@
}
break;
- case XMLContentSpecNode.CONTENTSPECNODE_CHOICE :
+ case XMLContentSpec.CONTENTSPECNODE_CHOICE :
//
// There must be one and only one child, so if the element count
// is zero, return an error at index 0.
@@ -262,7 +262,7 @@
return 1;
break;
- case XMLContentSpecNode.CONTENTSPECNODE_SEQ :
+ case XMLContentSpec.CONTENTSPECNODE_SEQ :
//
// There must be two children and they must be the two values
// we stored, in the stored order.
@@ -347,15 +347,15 @@
info.canHoldPCData = false;
// See how many children we can possibly report
- if ((fOp == XMLContentSpecNode.CONTENTSPECNODE_LEAF)
- || (fOp == XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_ONE)
- || (fOp == XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_MORE)
- || (fOp == XMLContentSpecNode.CONTENTSPECNODE_ONE_OR_MORE))
+ if ((fOp == XMLContentSpec.CONTENTSPECNODE_LEAF)
+ || (fOp == XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE)
+ || (fOp == XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE)
+ || (fOp == XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE))
{
info.resultsCount = 1;
}
- else if ((fOp == XMLContentSpecNode.CONTENTSPECNODE_CHOICE)
- || (fOp == XMLContentSpecNode.CONTENTSPECNODE_SEQ))
+ else if ((fOp == XMLContentSpec.CONTENTSPECNODE_CHOICE)
+ || (fOp == XMLContentSpec.CONTENTSPECNODE_SEQ))
{
info.resultsCount = 2;
}
@@ -405,8 +405,8 @@
//
switch(fOp)
{
- case XMLContentSpecNode.CONTENTSPECNODE_LEAF :
- case XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_ONE :
+ case XMLContentSpec.CONTENTSPECNODE_LEAF :
+ case XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE :
//
// If there are no current children, then insert at has to be
// zero, so we can have the one leaf element inserted here.
@@ -426,7 +426,7 @@
info.results[0] = true;
}
- if (fOp == XMLContentSpecNode.CONTENTSPECNODE_LEAF)
+ if (fOp == XMLContentSpec.CONTENTSPECNODE_LEAF)
{
// If the insert point is 1, then EOC is valid there
if (info.insertAt == 0)
@@ -439,8 +439,8 @@
}
break;
- case XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_MORE :
- case XMLContentSpecNode.CONTENTSPECNODE_ONE_OR_MORE :
+ case XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE :
+ case XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE :
//
// The one child is always possible to insert, regardless of
// where. The fully valid flag never comes into play since it
@@ -453,14 +453,14 @@
// Its zero/one or more, so EOC is valid in either case but only
// after the 0th index for one or more.
//
- if ((fOp == XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_MORE)
+ if ((fOp == XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE)
|| (info.insertAt > 0))
{
info.isValidEOC = true;
}
break;
- case XMLContentSpecNode.CONTENTSPECNODE_CHOICE :
+ case XMLContentSpec.CONTENTSPECNODE_CHOICE :
//
// If the insert point is zero, then either of the two children
// can be inserted, unless fully valid is set and there are
@@ -480,7 +480,7 @@
info.isValidEOC = true;
break;
- case XMLContentSpecNode.CONTENTSPECNODE_SEQ :
+ case XMLContentSpec.CONTENTSPECNODE_SEQ :
//
// If the insert at is 0, then the first one valid. Else its
// the second one.
1.2 +56 -50 xml-xerces/java/src/org/apache/xerces/validators/schema/SchemaMessageProvider.java
Index: SchemaMessageProvider.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/SchemaMessageProvider.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SchemaMessageProvider.java 1999/11/09 01:11:40 1.1
+++ SchemaMessageProvider.java 2000/04/04 20:11:07 1.2
@@ -123,7 +123,7 @@
throw new RuntimeException(msg);
}
return msg;
- }
+ }
//
//
//
@@ -132,59 +132,65 @@
//
// Major codes
//
- public static final int
+ public static final int
MSG_BAD_MAJORCODE = 0, // majorCode parameter to createMessage was out of bounds
MSG_FORMAT_FAILURE = 1, // exception thrown during messageFormat call
- NoValidatorFor = 2,
- IncorrectDatatype = 3,
- AttMissingType = 4,
- NotADatatype = 5,
- TextOnlyContentWithType = 6,
- FeatureUnsupported = 7,
- NestedOnlyInElemOnly = 8,
- EltRefOnlyInMixedElemOnly = 9,
- OnlyInEltContent = 10,
- OrderIsAll = 11,
- DatatypeWithType = 12,
- DatatypeQualUnsupported = 13,
- GroupContentRestricted = 14,
- UnknownBaseDatatype = 15,
- OneOfTypeRefArchRef = 16,
- NoContentForRef = 17,
- IncorrectDefaultType = 18,
- IllegalAttContent = 19,
- ValueNotInteger = 20,
- DatatypeError = 21,
+ NoValidatorFor = 2,
+ IncorrectDatatype = 3,
+ AttMissingType = 4,
+ NotADatatype = 5,
+ TextOnlyContentWithType = 6,
+ FeatureUnsupported = 7,
+ NestedOnlyInElemOnly = 8,
+ EltRefOnlyInMixedElemOnly = 9,
+ OnlyInEltContent = 10,
+ OrderIsAll = 11,
+ DatatypeWithType = 12,
+ DatatypeQualUnsupported = 13,
+ GroupContentRestricted = 14,
+ UnknownBaseDatatype = 15,
+ OneOfTypeRefArchRef = 16,
+ NoContentForRef = 17,
+ IncorrectDefaultType = 18,
+ IllegalAttContent = 19,
+ ValueNotInteger = 20,
+ DatatypeError = 21,
+ TypeAlreadySet = 22,
+ GenericError = 23,
+ UnclassifiedError = 24,
// ...
- MSG_MAX_CODE = 22;
- //
- // Minor Codes
- //
- public static final int
- MSG_NONE = 0;
+ MSG_MAX_CODE = 31;
+ //
+ // Minor Codes
+ //
+ public static final int
+ MSG_NONE = 0;
- public static final String[] fgMessageKeys = {
+ public static final String[] fgMessageKeys = {
"BadMajorCode", // 0, "The majorCode parameter to createMessage was out of bounds."
"FormatFailed", // 1, "An internal error occurred while formatting the following message:"
- "NoValidatorFor", // 2, "No validator for datatype {0}"
- "IncorrectDatatype", // 3, "Incorrect datatype: {0}"
- "AttMissingType", // 4, "The {0} attribute must appear with a type attribute."
- "NotADatatype", // 5, "{0} is not a datatype."
- "TextOnlyContentWithType", // 6, "The content attribute must be 'textOnly' if you specify a type attribute."
- "FeatureUnsupported", // 7, "{0} is unsupported"
- "NestedOnlyInElemOnly", // 8, "Nested Element decls only allowed in elemOnly content"
- "EltRefOnlyInMixedElemOnly", // 9, "Element references only allowed in mixed or elemOnly content"
- "OnlyInEltContent", // 10, "{0} only allowed in elemOnly content."
- "OrderIsAll", // 11, "{0} not allowed if the order is all."
- "DatatypeWithType", // 12, "Datatype qualifiers can only be used if you specify a type attribute."},
- "DatatypeQualUnsupported", // 13, "The datatype qualifier {0} is not supported."
- "GroupContentRestricted", // 14, "Error: {0} content must be one of element, group, modelGroupRef. Saw {1}"
- "UnknownBaseDatatype", // 15, "Unknown base type {0} for type {1}." },
- "OneOfTypeRefArchRef", // 16, "Can only have one of type, ref, and archRef attributes."},
- "NoContentForRef", // 17, "Cannot have child content for an element declaration that has a ref attribute"
- "IncorrectDefaultType", // 18, "Incorrect type for {0}'s default value: {1}"
- "IllegalAttContent", // 19, "Illegal content {0} in attribute group"
- "ValueNotInteger", // 20, "Value of {0} is not an integer"
- "DatatypeError", // 21, "Datatype error {0}."
- };
+ "NoValidatorFor", // 2, "No validator for datatype {0}"
+ "IncorrectDatatype", // 3, "Incorrect datatype: {0}"
+ "AttMissingType", // 4, "The {0} attribute must appear with a type attribute."
+ "NotADatatype", // 5, "{0} is not a datatype."
+ "TextOnlyContentWithType", // 6, "The content attribute must be 'textOnly' if you specify a type attribute."
+ "FeatureUnsupported", // 7, "{0} is unsupported"
+ "NestedOnlyInElemOnly", // 8, "Nested Element decls only allowed in elemOnly content"
+ "EltRefOnlyInMixedElemOnly", // 9, "Element references only allowed in mixed or elemOnly content"
+ "OnlyInEltContent", // 10, "{0} only allowed in elemOnly content."
+ "OrderIsAll", // 11, "{0} not allowed if the order is all."
+ "DatatypeWithType", // 12, "Datatype qualifiers can only be used if you specify a type attribute."},
+ "DatatypeQualUnsupported", // 13, "The datatype qualifier {0} is not supported."
+ "GroupContentRestricted", // 14, "Error: {0} content must be one of element, group, modelGroupRef. Saw {1}"
+ "UnknownBaseDatatype", // 15, "Unknown base type {0} for type {1}." },
+ "OneOfTypeRefArchRef", // 16, "Can only have one of type, ref, and archRef attributes."},
+ "NoContentForRef", // 17, "Cannot have child content for an element declaration that has a ref attribute"
+ "IncorrectDefaultType", // 18, "Incorrect type for {0}'s default value: {1}"
+ "IllegalAttContent", // 19, "Illegal content {0} in attribute group"
+ "ValueNotInteger", // 20, "Value of {0} is not an integer"
+ "DatatypeError", // 21, "Datatype error {0}."
+ "TypeAlreadySet", // 22, "The type of the element has already been declared."
+ "GenericError", // 23, "Schema error: {0}."
+ "UnclassifiedError", // 24, "Unclassified error."
+ };
}