elena 2003/07/23 08:51:13
Modified: java/src/org/apache/xerces/impl/dv XSFacets.java
java/src/org/apache/xerces/impl/dv/xs XSSimpleTypeDecl.java
java/src/org/apache/xerces/impl/xs/psvi XSConstants.java
XSFacet.java XSSimpleTypeDefinition.java
java/src/org/apache/xerces/impl/xs/traversers
XSDAbstractTraverser.java
java/src/org/apache/xerces/impl/xs/util
XSObjectListImpl.java
Log:
Store and expose annotation for simpleTypes and facets. Add a new interface to
represent enumeration and pattern facets.
Revision Changes Path
1.6 +34 -1 xml-xerces/java/src/org/apache/xerces/impl/dv/XSFacets.java
Index: XSFacets.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/XSFacets.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSFacets.java 29 Jan 2002 01:15:11 -0000 1.5
+++ XSFacets.java 23 Jul 2003 15:51:11 -0000 1.6
@@ -59,6 +59,9 @@
import java.util.Vector;
+import org.apache.xerces.impl.xs.psvi.XSAnnotation;
+import org.apache.xerces.impl.xs.psvi.XSObjectList;
+
/**
* The class used to pass all facets to [EMAIL PROTECTED] XSSimpleType#applyFacets}.
*
@@ -135,4 +138,34 @@
* value of minExclusive facet.
*/
public String minExclusive;
+
+
+
+ public XSAnnotation lengthAnnotation;
+ public XSAnnotation minLengthAnnotation;
+ public XSAnnotation maxLengthAnnotation;
+ public XSAnnotation whiteSpaceAnnotation;
+ public XSAnnotation totalDigitsAnnotation;
+ public XSAnnotation fractionDigitsAnnotation;
+ public XSObjectList patternAnnotations;
+ public XSObjectList enumAnnotations;
+ public XSAnnotation maxInclusiveAnnotation;
+ public XSAnnotation maxExclusiveAnnotation;
+ public XSAnnotation minInclusiveAnnotation;
+ public XSAnnotation minExclusiveAnnotation;
+
+ public void reset(){
+ lengthAnnotation = null;
+ minLengthAnnotation = null;
+ maxLengthAnnotation = null;
+ whiteSpaceAnnotation = null;
+ totalDigitsAnnotation = null;
+ fractionDigitsAnnotation = null;
+ patternAnnotations = null;
+ enumAnnotations = null;
+ maxInclusiveAnnotation = null;
+ maxExclusiveAnnotation = null;
+ minInclusiveAnnotation = null;
+ minExclusiveAnnotation = null;
+ }
}
1.41 +275 -113
xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
Index: XSSimpleTypeDecl.java
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- XSSimpleTypeDecl.java 24 Jun 2003 21:37:12 -0000 1.40
+++ XSSimpleTypeDecl.java 23 Jul 2003 15:51:11 -0000 1.41
@@ -69,10 +69,10 @@
import org.apache.xerces.impl.dv.XSSimpleType;
import org.apache.xerces.impl.xpath.regex.RegularExpression;
import org.apache.xerces.impl.xs.psvi.StringList;
-import org.apache.xerces.impl.xs.XSAnnotationImpl;
import org.apache.xerces.impl.xs.psvi.XSAnnotation;
import org.apache.xerces.impl.xs.psvi.XSConstants;
import org.apache.xerces.impl.xs.psvi.XSFacet;
+import org.apache.xerces.impl.xs.psvi.XSMultiValueFacet;
import org.apache.xerces.impl.xs.psvi.XSNamespaceItem;
import org.apache.xerces.impl.xs.psvi.XSObjectList;
import org.apache.xerces.impl.xs.psvi.XSSimpleTypeDefinition;
@@ -257,15 +257,34 @@
private Vector fPattern;
private Vector fPatternStr;
private Vector fEnumeration;
+ private StringList fLexicalPattern;
+ private StringList fLexicalEnumeration;
private Object fMaxInclusive;
private Object fMaxExclusive;
private Object fMinExclusive;
private Object fMinInclusive;
+ // annotations for constraining facets
+ public XSAnnotation lengthAnnotation;
+ public XSAnnotation minLengthAnnotation;
+ public XSAnnotation maxLengthAnnotation;
+ public XSAnnotation whiteSpaceAnnotation;
+ public XSAnnotation totalDigitsAnnotation;
+ public XSAnnotation fractionDigitsAnnotation;
+ public XSObjectList patternAnnotations;
+ public XSObjectList enumerationAnnotations;
+ public XSAnnotation maxInclusiveAnnotation;
+ public XSAnnotation maxExclusiveAnnotation;
+ public XSAnnotation minInclusiveAnnotation;
+ public XSAnnotation minExclusiveAnnotation;
+
// facets as objects
private XSObjectListImpl fFacets;
+
+ // enumeration and pattern facets
+ private XSObjectListImpl fMultiValueFacets;
- // optional annotations
+ // simpleType annotations
private XSObjectList fAnnotations = null;
private short fPatternType = SPECIAL_PATTERN_NONE;
@@ -671,6 +690,7 @@
reportError("cos-applicable-facets", new Object[]{"length",
fTypeName});
} else {
fLength = facets.length;
+ lengthAnnotation = facets.lengthAnnotation;
fFacetsDefined |= FACET_LENGTH;
if ((fixedFacet & FACET_LENGTH) != 0)
fFixedFacet |= FACET_LENGTH;
@@ -682,6 +702,7 @@
reportError("cos-applicable-facets", new Object[]{"minLength",
fTypeName});
} else {
fMinLength = facets.minLength;
+ minLengthAnnotation = facets.minLengthAnnotation;
fFacetsDefined |= FACET_MINLENGTH;
if ((fixedFacet & FACET_MINLENGTH) != 0)
fFixedFacet |= FACET_MINLENGTH;
@@ -693,6 +714,7 @@
reportError("cos-applicable-facets", new Object[]{"maxLength",
fTypeName});
} else {
fMaxLength = facets.maxLength;
+ maxLengthAnnotation = facets.maxLengthAnnotation;
fFacetsDefined |= FACET_MAXLENGTH;
if ((fixedFacet & FACET_MAXLENGTH) != 0)
fFixedFacet |= FACET_MAXLENGTH;
@@ -730,6 +752,7 @@
Vector enumVals = facets.enumeration;
Vector enumNSDecls = facets.enumNSDecls;
ValidationContextImpl ctx = new ValidationContextImpl(context);
+ enumerationAnnotations = facets.enumAnnotations;
for (int i = 0; i < enumVals.size(); i++) {
if (enumNSDecls != null)
ctx.setNSContext((NamespaceContext)enumNSDecls.elementAt(i));
@@ -751,6 +774,7 @@
reportError("cos-applicable-facets", new Object[]{"whiteSpace",
fTypeName});
} else {
fWhiteSpace = facets.whiteSpace;
+ whiteSpaceAnnotation = facets.whiteSpaceAnnotation;
fFacetsDefined |= FACET_WHITESPACE;
if ((fixedFacet & FACET_WHITESPACE) != 0)
fFixedFacet |= FACET_WHITESPACE;
@@ -763,6 +787,7 @@
if ((allowedFacet & FACET_MAXINCLUSIVE) == 0) {
reportError("cos-applicable-facets", new Object[]{"maxInclusive",
fTypeName});
} else {
+ maxInclusiveAnnotation = facets.maxInclusiveAnnotation;
try {
fMaxInclusive = getActualValue(facets.maxInclusive, context,
tempInfo, true);
fFacetsDefined |= FACET_MAXINCLUSIVE;
@@ -802,6 +827,7 @@
if ((allowedFacet & FACET_MAXEXCLUSIVE) == 0) {
reportError("cos-applicable-facets", new Object[]{"maxExclusive",
fTypeName});
} else {
+ maxExclusiveAnnotation = facets.maxExclusiveAnnotation;
try {
fMaxExclusive = getActualValue(facets.maxExclusive, context,
tempInfo, true);
fFacetsDefined |= FACET_MAXEXCLUSIVE;
@@ -840,6 +866,7 @@
if ((allowedFacet & FACET_MINEXCLUSIVE) == 0) {
reportError("cos-applicable-facets", new Object[]{"minExclusive",
fTypeName});
} else {
+ minExclusiveAnnotation = facets.minExclusiveAnnotation;
try {
fMinExclusive = getActualValue(facets.minExclusive, context,
tempInfo, true);
fFacetsDefined |= FACET_MINEXCLUSIVE;
@@ -878,6 +905,7 @@
if ((allowedFacet & FACET_MININCLUSIVE) == 0) {
reportError("cos-applicable-facets", new Object[]{"minInclusive",
fTypeName});
} else {
+ minInclusiveAnnotation = facets.minInclusiveAnnotation;
try {
fMinInclusive = getActualValue(facets.minInclusive, context,
tempInfo, true);
fFacetsDefined |= FACET_MININCLUSIVE;
@@ -916,6 +944,7 @@
if ((allowedFacet & FACET_TOTALDIGITS) == 0) {
reportError("cos-applicable-facets", new Object[]{"totalDigits",
fTypeName});
} else {
+ totalDigitsAnnotation = facets.totalDigitsAnnotation;
fTotalDigits = facets.totalDigits;
fFacetsDefined |= FACET_TOTALDIGITS;
if ((fixedFacet & FACET_TOTALDIGITS) != 0)
@@ -928,6 +957,7 @@
reportError("cos-applicable-facets", new Object[]{"fractionDigits",
fTypeName});
} else {
fFractionDigits = facets.fractionDigits;
+ fractionDigitsAnnotation = facets.fractionDigitsAnnotation;
fFacetsDefined |= FACET_FRACTIONDIGITS;
if ((fixedFacet & FACET_FRACTIONDIGITS) != 0)
fFixedFacet |= FACET_FRACTIONDIGITS;
@@ -1284,16 +1314,19 @@
if ( (fFacetsDefined & FACET_LENGTH) == 0 && (fBase.fFacetsDefined &
FACET_LENGTH) != 0 ) {
fFacetsDefined |= FACET_LENGTH;
fLength = fBase.fLength;
+ lengthAnnotation = fBase.lengthAnnotation;
}
// inherit minLength
if ( (fFacetsDefined & FACET_MINLENGTH) == 0 && (fBase.fFacetsDefined &
FACET_MINLENGTH) != 0 ) {
fFacetsDefined |= FACET_MINLENGTH;
fMinLength = fBase.fMinLength;
+ minLengthAnnotation = fBase.minLengthAnnotation;
}
// inherit maxLength
if ((fFacetsDefined & FACET_MAXLENGTH) == 0 && (fBase.fFacetsDefined &
FACET_MAXLENGTH) != 0 ) {
fFacetsDefined |= FACET_MAXLENGTH;
fMaxLength = fBase.fMaxLength;
+ maxLengthAnnotation = fBase.maxLengthAnnotation;
}
// inherit pattern
if ( (fBase.fFacetsDefined & FACET_PATTERN) != 0 ) {
@@ -1313,47 +1346,55 @@
if ( (fFacetsDefined & FACET_WHITESPACE) == 0 && (fBase.fFacetsDefined &
FACET_WHITESPACE) != 0 ) {
fFacetsDefined |= FACET_WHITESPACE;
fWhiteSpace = fBase.fWhiteSpace;
+ whiteSpaceAnnotation = fBase.whiteSpaceAnnotation;
}
// inherit enumeration
if ((fFacetsDefined & FACET_ENUMERATION) == 0 && (fBase.fFacetsDefined &
FACET_ENUMERATION) != 0) {
fFacetsDefined |= FACET_ENUMERATION;
fEnumeration = fBase.fEnumeration;
+ enumerationAnnotations = fBase.enumerationAnnotations;
}
// inherit maxExclusive
if ((( fBase.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) &&
!((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && !((fFacetsDefined &
FACET_MAXINCLUSIVE) != 0)) {
fFacetsDefined |= FACET_MAXEXCLUSIVE;
fMaxExclusive = fBase.fMaxExclusive;
+ maxExclusiveAnnotation = fBase.maxExclusiveAnnotation;
}
// inherit maxInclusive
if ((( fBase.fFacetsDefined & FACET_MAXINCLUSIVE) != 0) &&
!((fFacetsDefined & FACET_MAXEXCLUSIVE) != 0) && !((fFacetsDefined &
FACET_MAXINCLUSIVE) != 0)) {
fFacetsDefined |= FACET_MAXINCLUSIVE;
fMaxInclusive = fBase.fMaxInclusive;
+ maxInclusiveAnnotation = fBase.maxInclusiveAnnotation;
}
// inherit minExclusive
if ((( fBase.fFacetsDefined & FACET_MINEXCLUSIVE) != 0) &&
!((fFacetsDefined & FACET_MINEXCLUSIVE) != 0) && !((fFacetsDefined &
FACET_MININCLUSIVE) != 0)) {
fFacetsDefined |= FACET_MINEXCLUSIVE;
fMinExclusive = fBase.fMinExclusive;
+ minExclusiveAnnotation = fBase.minExclusiveAnnotation;
}
// inherit minExclusive
if ((( fBase.fFacetsDefined & FACET_MININCLUSIVE) != 0) &&
!((fFacetsDefined & FACET_MINEXCLUSIVE) != 0) && !((fFacetsDefined &
FACET_MININCLUSIVE) != 0)) {
fFacetsDefined |= FACET_MININCLUSIVE;
fMinInclusive = fBase.fMinInclusive;
+ minInclusiveAnnotation = fBase.minInclusiveAnnotation;
}
// inherit totalDigits
if ((( fBase.fFacetsDefined & FACET_TOTALDIGITS) != 0) &&
!((fFacetsDefined & FACET_TOTALDIGITS) != 0)) {
fFacetsDefined |= FACET_TOTALDIGITS;
fTotalDigits = fBase.fTotalDigits;
+ totalDigitsAnnotation = fBase.totalDigitsAnnotation;
}
// inherit fractionDigits
if ((( fBase.fFacetsDefined & FACET_FRACTIONDIGITS) != 0)
&& !((fFacetsDefined & FACET_FRACTIONDIGITS) != 0)) {
fFacetsDefined |= FACET_FRACTIONDIGITS;
fFractionDigits = fBase.fFractionDigits;
+ fractionDigitsAnnotation = fBase.fractionDigitsAnnotation;
}
//inherit tokeytype
if ((fPatternType == SPECIAL_PATTERN_NONE ) && (fBase.fPatternType !=
SPECIAL_PATTERN_NONE)) {
@@ -1882,47 +1923,48 @@
}
public StringList getLexicalEnumeration() {
- if (fEnumeration == null)
- return null;
-
- // REVISIT: fEnumeration should be of type StringListImpl
- int size = fEnumeration.size();
- String[] strs = new String[size];
- for (int i = 0; i < size; i++)
- strs[i] = fEnumeration.elementAt(i).toString();
- return new StringListImpl(strs, size);
+ if (fLexicalEnumeration == null){
+ if (fEnumeration == null)
+ return null;
+ int size = fEnumeration.size();
+ String[] strs = new String[size];
+ for (int i = 0; i < size; i++)
+ strs[i] = fEnumeration.elementAt(i).toString();
+ fLexicalEnumeration = new StringListImpl(strs, size);
+ }
+ return fLexicalEnumeration;
}
public StringList getLexicalPattern() {
if (fPatternType == SPECIAL_PATTERN_NONE && fPatternStr == null)
return null;
-
- // REVISIT: fPattern should be of type StringListImpl
- int size = fPatternStr == null ? 0 : fPatternStr.size();
- String[] strs;
- if (fPatternType == SPECIAL_PATTERN_NMTOKEN) {
- strs = new String[size+1];
- strs[size] = "\\c+";
- }
- else if (fPatternType == SPECIAL_PATTERN_NAME) {
- strs = new String[size+1];
- strs[size] = "\\i\\c*";
- }
- else if (fPatternType == SPECIAL_PATTERN_NCNAME) {
- strs = new String[size+2];
- strs[size] = "\\i\\c*";
- strs[size+1] = "[\\i-[:]][\\c-[:]]*";
- }
- else {
- strs = new String[size];
+ if (fLexicalPattern == null){
+ int size = fPatternStr == null ? 0 : fPatternStr.size();
+ String[] strs;
+ if (fPatternType == SPECIAL_PATTERN_NMTOKEN) {
+ strs = new String[size+1];
+ strs[size] = "\\c+";
+ }
+ else if (fPatternType == SPECIAL_PATTERN_NAME) {
+ strs = new String[size+1];
+ strs[size] = "\\i\\c*";
+ }
+ else if (fPatternType == SPECIAL_PATTERN_NCNAME) {
+ strs = new String[size+2];
+ strs[size] = "\\i\\c*";
+ strs[size+1] = "[\\i-[:]][\\c-[:]]*";
+ }
+ else {
+ strs = new String[size];
+ }
+ for (int i = 0; i < size; i++)
+ strs[i] = (String)fPatternStr.elementAt(i);
+ fLexicalPattern = new StringListImpl(strs, size);
}
- for (int i = 0; i < size; i++)
- strs[i] = (String)fPatternStr.elementAt(i);
- return new StringListImpl(strs, size);
+ return fLexicalPattern;
}
public XSObjectList getAnnotations() {
- // REVISIT: SCAPI: to implement
return fAnnotations;
}
@@ -2291,10 +2333,24 @@
fPattern = null;
fPatternStr = null;
fEnumeration = null;
+ fLexicalPattern = null;
+ fLexicalEnumeration = null;
fMaxInclusive = null;
fMaxExclusive = null;
fMinExclusive = null;
fMinInclusive = null;
+ lengthAnnotation = null;
+ minLengthAnnotation = null;
+ maxLengthAnnotation = null;
+ whiteSpaceAnnotation = null;
+ totalDigitsAnnotation = null;
+ fractionDigitsAnnotation = null;
+ patternAnnotations = null;
+ enumerationAnnotations = null;
+ maxInclusiveAnnotation = null;
+ maxExclusiveAnnotation = null;
+ minInclusiveAnnotation = null;
+ minExclusiveAnnotation = null;
fPatternType = SPECIAL_PATTERN_NONE;
fAnnotations = null;
@@ -2321,90 +2377,132 @@
* @see org.apache.xerces.impl.xs.psvi.XSSimpleTypeDefinition#getFacets()
*/
public XSObjectList getFacets() {
- if (fFacets != null){
- return fFacets;
- }
- int pattern = 0;
- int enum = 0;
- if (fPatternStr != null){
- pattern = fPatternStr.size();
- }
- if (fEnumeration != null){
- enum = fEnumeration.size();
- }
- int count = 12 + pattern + enum;
-
- XSFacetImpl[] facets = new XSFacetImpl[count];
-
- count = 0;
- if ((fFacetsDefined & FACET_WHITESPACE) != 0){
- facets[count] = new XSFacetImpl(FACET_WHITESPACE,
- WS_FACET_STRING[fWhiteSpace] ,(fFixedFacet & FACET_WHITESPACE) != 0,
null);
- count++;
- }
- if (fLength != -1){
- facets[count] = new XSFacetImpl(FACET_LENGTH,
- Integer.toString(fLength) ,(fFixedFacet & FACET_LENGTH) != 0, null);
- count++;
- }
- if (fMinLength != -1){
- facets[count] = new XSFacetImpl(FACET_MINLENGTH,
- Integer.toString(fMinLength) ,(fFixedFacet & FACET_MINLENGTH) != 0,
null);
- count++;
- }
- if (fMaxLength != -1){
- facets[count] = new XSFacetImpl(FACET_MAXLENGTH,
- Integer.toString(fMaxLength) ,(fFixedFacet & FACET_MAXLENGTH) != 0,
null);
- count++;
- }
- if (fTotalDigits != -1){
- facets[count] = new XSFacetImpl(FACET_TOTALDIGITS,
- Integer.toString(fTotalDigits) ,(fFixedFacet & FACET_TOTALDIGITS) != 0,
null);
- count++;
- }
- if (fFractionDigits != -1){
- facets[count] = new XSFacetImpl(FACET_FRACTIONDIGITS,
- Integer.toString(fFractionDigits) ,(fFixedFacet & FACET_FRACTIONDIGITS)
!= 0, null);
- count++;
- }
- if (fPatternStr != null){
- for (int i = 0; i < pattern; i++){
- facets[count] = new XSFacetImpl(FACET_PATTERN,
- fPatternStr.elementAt(i).toString(), false, null);
+ if (fFacets == null && fFacetsDefined != 0) {
+
+ XSFacetImpl[] facets = new XSFacetImpl[10];
+ int count = 0;
+ if ((fFacetsDefined & FACET_WHITESPACE) != 0) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_WHITESPACE,
+ WS_FACET_STRING[fWhiteSpace],
+ (fFixedFacet & FACET_WHITESPACE) != 0,
+ whiteSpaceAnnotation);
count++;
}
- }
- if (fEnumeration !=null){
- for (int i = 0; i < enum; i++){
- facets[count] = new XSFacetImpl(FACET_ENUMERATION,
- fEnumeration.elementAt(i).toString(), false, null);
+ if (fLength != -1) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_LENGTH,
+ Integer.toString(fLength),
+ (fFixedFacet & FACET_LENGTH) != 0,
+ lengthAnnotation);
count++;
}
+ if (fMinLength != -1) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_MINLENGTH,
+ Integer.toString(fMinLength),
+ (fFixedFacet & FACET_MINLENGTH) != 0,
+ minLengthAnnotation);
+ count++;
+ }
+ if (fMaxLength != -1) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_MAXLENGTH,
+ Integer.toString(fMaxLength),
+ (fFixedFacet & FACET_MAXLENGTH) != 0,
+ maxLengthAnnotation);
+ count++;
+ }
+ if (fTotalDigits != -1) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_TOTALDIGITS,
+ Integer.toString(fTotalDigits),
+ (fFixedFacet & FACET_TOTALDIGITS) != 0,
+ totalDigitsAnnotation);
+ count++;
+ }
+ if (fFractionDigits != -1) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_FRACTIONDIGITS,
+ Integer.toString(fFractionDigits),
+ (fFixedFacet & FACET_FRACTIONDIGITS) != 0,
+ fractionDigitsAnnotation);
+ count++;
+ }
+ if (fMaxInclusive != null) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_MAXINCLUSIVE,
+ fMaxInclusive.toString(),
+ (fFixedFacet & FACET_MAXINCLUSIVE) != 0,
+ maxInclusiveAnnotation);
+ count++;
+ }
+ if (fMaxExclusive != null) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_MAXEXCLUSIVE,
+ fMaxExclusive.toString(),
+ (fFixedFacet & FACET_MAXEXCLUSIVE) != 0,
+ maxExclusiveAnnotation);
+ count++;
+ }
+ if (fMinExclusive != null) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_MINEXCLUSIVE,
+ fMinExclusive.toString(),
+ (fFixedFacet & FACET_MINEXCLUSIVE) != 0,
+ minExclusiveAnnotation);
+ count++;
+ }
+ if (fMinInclusive != null) {
+ facets[count] =
+ new XSFacetImpl(
+ FACET_MININCLUSIVE,
+ fMinInclusive.toString(),
+ (fFixedFacet & FACET_MININCLUSIVE) != 0,
+ minInclusiveAnnotation);
+ count++;
+ }
+ fFacets = new XSObjectListImpl(facets, count);
}
- if (fMaxInclusive != null){
- facets[count] = new XSFacetImpl(FACET_MAXINCLUSIVE,
- fMaxInclusive.toString() ,(fFixedFacet & FACET_MAXINCLUSIVE) != 0,
null);
- count++;
- }
- if (fMaxExclusive != null){
- facets[count] = new XSFacetImpl(FACET_MAXEXCLUSIVE,
- fMaxExclusive.toString() ,(fFixedFacet & FACET_MAXEXCLUSIVE) != 0,
null);
- count++;
- }
- if (fMinExclusive != null){
- facets[count] = new XSFacetImpl(FACET_MINEXCLUSIVE,
- fMinExclusive.toString() ,(fFixedFacet & FACET_MINEXCLUSIVE) != 0,
null);
- count++;
- }
- if (fMinInclusive != null){
- facets[count] = new XSFacetImpl(FACET_MININCLUSIVE,
- fMinInclusive.toString() ,(fFixedFacet & FACET_MININCLUSIVE) != 0,
null);
- count++;
- }
- fFacets = new XSObjectListImpl(facets, count);
return fFacets;
}
+ public XSObjectList getMultiValueFacets(){
+ if (fMultiValueFacets == null
+ && (fFacetsDefined & FACET_ENUMERATION) != 0
+ || (fFacetsDefined & FACET_PATTERN) != 0) {
+
+ XSMVFacetImpl[] facets = new XSMVFacetImpl[2];
+ int count = 0;
+ if (fPatternStr != null) {
+ facets[count] =
+ new XSMVFacetImpl(
+ FACET_PATTERN,
+ this.getLexicalPattern(),
+ patternAnnotations);
+ count++;
+ }
+ if (fEnumeration != null) {
+ facets[count] =
+ new XSMVFacetImpl(
+ FACET_ENUMERATION,
+ this.getLexicalEnumeration(),
+ enumerationAnnotations);
+ count++;
+ }
+ fMultiValueFacets = new XSObjectListImpl(facets, count);
+ }
+ return fMultiValueFacets;
+ }
private static final class XSFacetImpl implements XSFacet {
final short kind;
@@ -2422,8 +2520,7 @@
* @see org.apache.xerces.impl.xs.psvi.XSFacet#getAnnotation()
*/
public XSAnnotation getAnnotation() {
- // TODO: implement annotation support
- return null;
+ return annotation;
}
/* (non-Javadoc)
@@ -2477,6 +2574,71 @@
}
}
+
+ private static final class XSMVFacetImpl implements XSMultiValueFacet {
+ final short kind;
+ XSObjectList annotations;
+ StringList values;
+
+ public XSMVFacetImpl(short kind, StringList values, XSObjectList
annotations) {
+ this.kind = kind;
+ this.values = values;
+ this.annotations = annotations;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.xerces.impl.xs.psvi.XSFacet#getFacetKind()
+ */
+ public short getFacetKind() {
+ return kind;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.xerces.impl.xs.psvi.XSMultiValueFacet#getAnnotations()
+ */
+ public XSObjectList getAnnotations() {
+ return annotations;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.xerces.impl.xs.psvi.XSMultiValueFacet#getLexicalFacetValues()
+ */
+ public StringList getLexicalFacetValues() {
+ return values;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.xerces.impl.xs.psvi.XSObject#getName()
+ */
+ public String getName() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.xerces.impl.xs.psvi.XSObject#getNamespace()
+ */
+ public String getNamespace() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.xerces.impl.xs.psvi.XSObject#getNamespaceItem()
+ */
+ public XSNamespaceItem getNamespaceItem() {
+ // REVISIT: implement
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.xerces.impl.xs.psvi.XSObject#getType()
+ */
+ public short getType() {
+ return XSConstants.MULTIVALUE_FACET;
+ }
+ }
+
} // class XSSimpleTypeDecl
1.6 +8 -2
xml-xerces/java/src/org/apache/xerces/impl/xs/psvi/XSConstants.java
Index: XSConstants.java
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/psvi/XSConstants.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSConstants.java 24 Jun 2003 21:37:13 -0000 1.5
+++ XSConstants.java 23 Jul 2003 15:51:12 -0000 1.6
@@ -112,9 +112,15 @@
*/
public static final short ANNOTATION = 12;
/**
- * The object describes a facet.
+ * The object describes a constraining facet.
*/
- public static final short FACET = 13;
+ public static final short FACET = 13;
+
+ /**
+ * The object describes enumeration/pattern facets.
+ */
+ public static final short MULTIVALUE_FACET = 14;
+
// Derivation constants
/**
1.2 +2 -5 xml-xerces/java/src/org/apache/xerces/impl/xs/psvi/XSFacet.java
Index: XSFacet.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/psvi/XSFacet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSFacet.java 24 Jun 2003 21:37:13 -0000 1.1
+++ XSFacet.java 23 Jul 2003 15:51:12 -0000 1.2
@@ -58,11 +58,8 @@
package org.apache.xerces.impl.xs.psvi;
/**
- * Describes a constraining facet.
- * TODO: how should we represent enumerations and patterns?
- * Currently the implementation will expose each enumeration/pattern as an
- * XSObject.
- * TODO: we should also expose actual values
+ * Describes a constraining facet. Enumeration and pattern facets are exposed
+ * via XSMultiValueFacet interface.
*/
public interface XSFacet extends XSObject{
/**
1.8 +7 -0
xml-xerces/java/src/org/apache/xerces/impl/xs/psvi/XSSimpleTypeDefinition.java
Index: XSSimpleTypeDefinition.java
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/psvi/XSSimpleTypeDefinition.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSSimpleTypeDefinition.java 24 Jun 2003 21:37:13 -0000 1.7
+++ XSSimpleTypeDefinition.java 23 Jul 2003 15:51:12 -0000 1.8
@@ -249,7 +249,14 @@
public XSObjectList getAnnotations();
/**
* @return list of constraining facets.
+ * This method must not be used to retrieve
+ * values for <code>enumeration</code> and <code>pattern</code> facets.
*/
public XSObjectList getFacets();
+
+ /**
+ * @return list of enumeration and pattern facets.
+ */
+ public XSObjectList getMultiValueFacets();
}
1.30 +55 -15
xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
Index: XSDAbstractTraverser.java
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- XSDAbstractTraverser.java 3 Jul 2003 18:36:50 -0000 1.29
+++ XSDAbstractTraverser.java 23 Jul 2003 15:51:13 -0000 1.30
@@ -75,6 +75,7 @@
import org.apache.xerces.impl.xs.psvi.XSObjectList;
import org.apache.xerces.impl.xs.psvi.XSTypeDefinition;
import org.apache.xerces.impl.xs.util.XInt;
+import org.apache.xerces.impl.xs.util.XSObjectListImpl;
import org.apache.xerces.util.DOMUtil;
import org.apache.xerces.util.NamespaceSupport;
import org.apache.xerces.util.SymbolTable;
@@ -133,7 +134,6 @@
}
// traverse the annotation declaration
- // REVISIT: store annotation information for PSVI
// REVISIT: how to pass the parentAttrs? as DOM attributes?
// as name/value pairs (string)? in parsed form?
// @return XSAnnotationImpl object
@@ -225,14 +225,16 @@
XSDocumentInfo schemaDoc) {
short facetsPresent = 0 ;
- short facetsFixed = 0; // facets that have fixed="true"
-
+ short facetsFixed = 0; // facets that have fixed="true"
String facet;
boolean hasQName = containsQName(baseValidator);
- Vector enumData = new Vector();
- Vector enumNSDecls = hasQName ? new Vector() : null;
+ Vector enumData = null;
+ XSObjectListImpl enumAnnotations = null;
+ XSObjectListImpl patternAnnotations = null;
+ Vector enumNSDecls = hasQName ? new Vector() : null;
int currentFacet = 0;
- while (content != null) {
+ xsFacets.reset();
+ while (content != null) {
// General Attribute Checking
Object[] attrs = null;
facet = DOMUtil.getLocalName(content);
@@ -258,17 +260,21 @@
// restore to the normal namespace context
schemaDoc.fValidationContext.setNamespaceSupport(schemaDoc.fNamespaceSupport);
}
-
+ if (enumData == null){
+ enumData = new Vector();
+ enumAnnotations = new XSObjectListImpl();
+ }
enumData.addElement(enumVal);
+ enumAnnotations.add(null);
if (hasQName)
enumNSDecls.addElement(nsDecls);
Element child = DOMUtil.getFirstChildElement( content );
if (child != null) {
// traverse annotation if any
+
if
(DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
- // REVISIT: change API to provide a receptacle for these
- traverseAnnotationDecl(child, attrs, false, schemaDoc);
+
enumAnnotations.add(enumAnnotations.getLength()-1,traverseAnnotationDecl(child, attrs,
false, schemaDoc));
child = DOMUtil.getNextSiblingElement(child);
}
if (child !=null &&
DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
@@ -291,8 +297,7 @@
if (child != null) {
// traverse annotation if any
if
(DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
- // REVISIT: change API to provide for these
- traverseAnnotationDecl(child, attrs, false, schemaDoc);
+ patternAnnotations.add(traverseAnnotationDecl(child,
attrs, false, schemaDoc));
child = DOMUtil.getNextSiblingElement(child);
}
if (child !=null &&
DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
@@ -385,8 +390,41 @@
if (child != null) {
// traverse annotation if any
if
(DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
- // REVISIT: change API to provide for these
- traverseAnnotationDecl(child, attrs, false, schemaDoc);
+ XSAnnotationImpl annotation = traverseAnnotationDecl(child,
attrs, false, schemaDoc);
+ switch (currentFacet) {
+ case XSSimpleType.FACET_MINLENGTH:
+ xsFacets.minLengthAnnotation = annotation;
+ break;
+ case XSSimpleType.FACET_MAXLENGTH:
+ xsFacets.maxLengthAnnotation = annotation;
+ break;
+ case XSSimpleType.FACET_MAXEXCLUSIVE:
+ xsFacets.maxExclusiveAnnotation = annotation;
+ break;
+ case XSSimpleType.FACET_MAXINCLUSIVE:
+ xsFacets.maxInclusiveAnnotation = annotation;
+ break;
+ case XSSimpleType.FACET_MINEXCLUSIVE:
+ xsFacets.minExclusiveAnnotation = annotation;
+ break;
+ case XSSimpleType.FACET_MININCLUSIVE:
+ xsFacets.minInclusiveAnnotation = annotation;
+ break;
+ case XSSimpleType.FACET_TOTALDIGITS:
+ xsFacets.totalDigitsAnnotation = annotation;
+ break;
+ case XSSimpleType.FACET_FRACTIONDIGITS:
+ xsFacets.fractionDigitsAnnotation = annotation;
+ break;
+ case XSSimpleType.FACET_WHITESPACE:
+ xsFacets.whiteSpaceAnnotation = annotation;
+ break;
+ case XSSimpleType.FACET_LENGTH:
+ xsFacets.lengthAnnotation = annotation;
+ break;
+ }
+
+
child = DOMUtil.getNextSiblingElement(child);
}
if (child !=null &&
DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
@@ -397,10 +435,11 @@
fAttrChecker.returnAttrArray (attrs, schemaDoc);
content = DOMUtil.getNextSiblingElement(content);
}
- if (enumData.size() > 0) {
+ if (enumData !=null) {
facetsPresent |= XSSimpleType.FACET_ENUMERATION;
xsFacets.enumeration = enumData;
xsFacets.enumNSDecls = enumNSDecls;
+ xsFacets.enumAnnotations = enumAnnotations;
}
if (fPattern.length() != 0) {
facetsPresent |= XSSimpleType.FACET_PATTERN;
@@ -416,6 +455,7 @@
fi.fFixedFacets = facetsFixed;
return fi;
}
+
// return whether QName/NOTATION is part of the given type
private boolean containsQName(XSSimpleType type) {
1.6 +22 -1
xml-xerces/java/src/org/apache/xerces/impl/xs/util/XSObjectListImpl.java
Index: XSObjectListImpl.java
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/util/XSObjectListImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSObjectListImpl.java 3 Jul 2003 15:11:51 -0000 1.5
+++ XSObjectListImpl.java 23 Jul 2003 15:51:13 -0000 1.6
@@ -69,10 +69,19 @@
*/
public class XSObjectListImpl implements XSObjectList {
+ private final int DEFAULT_SIZE = 4;
+
// The array to hold all data
private XSObject[] fArray = null;
// Number of elements in this list
private int fLength = 0;
+
+
+
+ public XSObjectListImpl(){
+ fArray = new XSObject[DEFAULT_SIZE];
+ fLength = 0;
+ }
/**
* Construct an XSObjectList implementation
@@ -115,6 +124,18 @@
}
fArray = null;
fLength = 0;
+ }
+
+ public void add (XSObject object){
+ if (fLength == fArray.length){
+ XSObject[] temp = new XSObject[fLength + 4];
+ System.arraycopy(fArray, 0, temp, 0, fLength);
+ fArray = temp;
+ }
+ fArray[fLength++]=object;
+ }
+ public void add (int index, XSObject object){
+ fArray [index] = object;
}
} // class XSObjectList
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]