You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by el...@apache.org on 2001/10/22 21:27:15 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/v2 XSDAbstractIDConstraintTraverser.java XSDAbstractParticleTraverser.java XSDAbstractTraverser.java XSDComplexTypeTraverser.java XSDNotationTraverser.java XSDSimpleTypeTraverser.java
elena 01/10/22 12:27:15
Modified: java/src/org/apache/xerces/impl/v2
XSDAbstractIDConstraintTraverser.java
XSDAbstractParticleTraverser.java
XSDAbstractTraverser.java
XSDComplexTypeTraverser.java
XSDNotationTraverser.java
XSDSimpleTypeTraverser.java
Log:
get rid of checkContent method.
Revision Changes Path
1.8 +6 -6 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractIDConstraintTraverser.java
Index: XSDAbstractIDConstraintTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractIDConstraintTraverser.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSDAbstractIDConstraintTraverser.java 2001/10/19 20:25:27 1.7
+++ XSDAbstractIDConstraintTraverser.java 2001/10/22 19:27:15 1.8
@@ -68,7 +68,7 @@
* traversers (the XSDUniqueTraverser, XSDKeyTraverser and
* XSDKeyrefTraverser) rely upon.
*
- * @version $Id: XSDAbstractIDConstraintTraverser.java,v 1.7 2001/10/19 20:25:27 elena Exp $
+ * @version $Id: XSDAbstractIDConstraintTraverser.java,v 1.8 2001/10/22 19:27:15 elena Exp $
*/
class XSDAbstractIDConstraintTraverser extends XSDAbstractTraverser {
@@ -92,7 +92,7 @@
// General Attribute Checking on sElem
// first child could be an annotation
- if (sElem.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
+ if (DOMUtil.getLocalName(sElem).equals(SchemaSymbols.ELT_ANNOTATION)) {
traverseAnnotationDecl(sElem, icElemAttrs, false, schemaDoc);
sElem = DOMUtil.getNextSiblingElement(sElem);
}
@@ -105,7 +105,7 @@
Object [] attrValues = fAttrChecker.checkAttributes(sElem, false, schemaDoc);
// if more than one annotation report an error
- if(!sElem.getLocalName().equals(SchemaSymbols.ELT_SELECTOR)) {
+ if(!DOMUtil.getLocalName(sElem).equals(SchemaSymbols.ELT_SELECTOR)) {
// REVISIT: localize
reportGenericSchemaError("The content of an identity constraint must match (annotation?, selector, field+)");
}
@@ -114,7 +114,7 @@
if (selChild !=null) {
// traverse annotation if any
- if (selChild.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
+ if (DOMUtil.getLocalName(selChild).equals(SchemaSymbols.ELT_ANNOTATION)) {
traverseAnnotationDecl(selChild, attrValues, false, schemaDoc);
selChild = DOMUtil.getNextSiblingElement(selChild);
}
@@ -161,7 +161,7 @@
// General Attribute Checking
attrValues = fAttrChecker.checkAttributes(fElem, false, schemaDoc);
- if(!fElem.getLocalName().equals(SchemaSymbols.ELT_FIELD))
+ if(!DOMUtil.getLocalName(fElem).equals(SchemaSymbols.ELT_FIELD))
// REVISIT: localize
reportGenericSchemaError("The content of an identity constraint must match (annotation?, selector, field+)");
@@ -169,7 +169,7 @@
Element fieldChild = DOMUtil.getFirstChildElement(fElem);
if (fieldChild != null) {
// traverse annotation
- if (fieldChild.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
+ if (DOMUtil.getLocalName(fieldChild).equals(SchemaSymbols.ELT_ANNOTATION)) {
traverseAnnotationDecl(fieldChild, attrValues, false, schemaDoc);
fieldChild = DOMUtil.getNextSiblingElement(fieldChild);
}
1.18 +5 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractParticleTraverser.java
Index: XSDAbstractParticleTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractParticleTraverser.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- XSDAbstractParticleTraverser.java 2001/10/19 20:25:27 1.17
+++ XSDAbstractParticleTraverser.java 2001/10/22 19:27:15 1.18
@@ -65,7 +65,7 @@
/**
* @author Elena Litani, IBM
* @author Sandy Gao, IBM
- * @version $Id: XSDAbstractParticleTraverser.java,v 1.17 2001/10/19 20:25:27 elena Exp $
+ * @version $Id: XSDAbstractParticleTraverser.java,v 1.18 2001/10/22 19:27:15 elena Exp $
*/
abstract class XSDAbstractParticleTraverser extends XSDAbstractTraverser {
@@ -99,7 +99,7 @@
if (child !=null) {
// traverse Annotation
- if (child.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
+ if (DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
}
@@ -111,7 +111,7 @@
for (; child != null; child = DOMUtil.getNextSiblingElement(child)) {
particle = null;
- childName = child.getLocalName();
+ childName = DOMUtil.getLocalName(child);
// Only elements are allowed in <all>
if (childName.equals(SchemaSymbols.ELT_ELEMENT)) {
@@ -238,7 +238,7 @@
Element child = DOMUtil.getFirstChildElement(decl);
if (child !=null) {
// traverse Annotation
- if (child.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
+ if (DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
}
@@ -252,7 +252,7 @@
particle = null;
- childName = child.getLocalName();
+ childName = DOMUtil.getLocalName(child);
if (childName.equals(SchemaSymbols.ELT_ELEMENT)) {
particle = fSchemaHandler.fElementTraverser.traverseLocal(child, schemaDoc, grammar, NOT_ALL_CONTEXT);
}
1.36 +48 -33 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractTraverser.java
Index: XSDAbstractTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractTraverser.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- XSDAbstractTraverser.java 2001/10/22 18:53:02 1.35
+++ XSDAbstractTraverser.java 2001/10/22 19:27:15 1.36
@@ -77,7 +77,7 @@
* @author Elena Litani, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: XSDAbstractTraverser.java,v 1.35 2001/10/22 18:53:02 sandygao Exp $
+ * @version $Id: XSDAbstractTraverser.java,v 1.36 2001/10/22 19:27:15 elena Exp $
*/
abstract class XSDAbstractTraverser {
@@ -131,7 +131,7 @@
for (Element child = DOMUtil.getFirstChildElement(annotationDecl);
child != null;
child = DOMUtil.getNextSiblingElement(child)) {
- String name = child.getLocalName();
+ String name = DOMUtil.getLocalName(child);
// the only valid children of "annotation" are
// "appinfo" and "documentation"
@@ -213,7 +213,16 @@
short flags = 0; // flag facets that have fixed="true"
int numEnumerationLiterals = 0;
Vector enumData = new Vector();
- content = checkContent(content , contentAttrs, schemaDoc);
+ if (content != null) {
+ // traverse annotation if any
+ if (DOMUtil.getLocalName(content).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ traverseAnnotationDecl(content, contentAttrs, false, schemaDoc);
+ content = DOMUtil.getNextSiblingElement(content);
+ }
+ if (content !=null && DOMUtil.getLocalName(content).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ reportGenericSchemaError("Facets have more than one annotation.");
+ }
+ }
String facet;
int numFacets=0;
@@ -248,7 +257,18 @@
fSymbolTable.addSymbol(enumVal);
}
enumData.addElement(enumVal);
- checkContent(DOMUtil.getFirstChildElement( content ), attrs, schemaDoc);
+ Element child = DOMUtil.getFirstChildElement( content );
+
+ if (child != null) {
+ // traverse annotation if any
+ if (DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ traverseAnnotationDecl(child, attrs, false, schemaDoc);
+ child = DOMUtil.getNextSiblingElement(child);
+ }
+ if (child !=null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ reportGenericSchemaError("Enumeration facet has more than one annotation.");
+ }
+ }
}
else if (facet.equals(SchemaSymbols.ELT_ANNOTATION) || facet.equals(SchemaSymbols.ELT_SIMPLETYPE)) {
//REVISIT:
@@ -270,7 +290,18 @@
// ---------------------------------------------
fPattern.append("|");
fPattern.append(DOMUtil.getAttrValue(content, SchemaSymbols.ATT_VALUE ));
- checkContent(DOMUtil.getFirstChildElement( content ), attrs, schemaDoc);
+
+ Element child = DOMUtil.getFirstChildElement( content );
+ if (child != null) {
+ // traverse annotation if any
+ if (DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ traverseAnnotationDecl(child, attrs, false, schemaDoc);
+ child = DOMUtil.getNextSiblingElement(child);
+ }
+ if (child !=null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ reportGenericSchemaError("Pattern facet has more than one annotation.");
+ }
+ }
}
}
else {
@@ -322,7 +353,18 @@
flags |= facetType;
}
fFacetData.put(facet,content.getAttribute( SchemaSymbols.ATT_VALUE ));
- checkContent(DOMUtil.getFirstChildElement( content ), attrs, schemaDoc);
+
+ Element child = DOMUtil.getFirstChildElement( content );
+ if (child != null) {
+ // traverse annotation if any
+ if (DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ traverseAnnotationDecl(child, attrs, false, schemaDoc);
+ child = DOMUtil.getNextSiblingElement(child);
+ }
+ if (child !=null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ reportGenericSchemaError(facet+" facet has more than one annotation.");
+ }
+ }
}
// REVISIT: when to return the array
fAttrChecker.returnAttrArray (attrs, schemaDoc);
@@ -447,33 +489,6 @@
XMLErrorReporter.SEVERITY_ERROR);
}
- //
- // Evaluates content of Annotation if present.
- //
- // @param: content - the first child of <code>elm</code> that needs to be checked
- // @param parentAttrs: attributes of the parent element; needed for PSVI.
- // @param schemaDoc: the currently active schema document.
- //
-
- //REVISIT: if we want to expose annotation information to the application,
- // then it may be difficult to use this method because traversers
- // will need to store the <annotation> component in the grammar.
- // We would then have to provide some means of accessing that component.
- // Note that it is assumed this method is never invoked in a global context.
-
- Element checkContent( Element content, Object[] parentAttrs, XSDocumentInfo schemaDoc ) {
-
- if (content == null) {
- return content;
- }
- String tag = content.getLocalName();
- if (tag != null && tag.equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(content, parentAttrs, false, schemaDoc);
- content = DOMUtil.getNextSiblingElement(content);
- }
-
- return content;
- }
/**
* Element/Attribute traversers call this method to check whether
1.32 +54 -11 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDComplexTypeTraverser.java
Index: XSDComplexTypeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDComplexTypeTraverser.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- XSDComplexTypeTraverser.java 2001/10/22 18:52:16 1.31
+++ XSDComplexTypeTraverser.java 2001/10/22 19:27:15 1.32
@@ -80,7 +80,7 @@
* ((group | all | choice | sequence)?,
* ((attribute | attributeGroup)*, anyAttribute?))))
* </complexType>
- * @version $Id: XSDComplexTypeTraverser.java,v 1.31 2001/10/22 18:52:16 sandygao Exp $
+ * @version $Id: XSDComplexTypeTraverser.java,v 1.32 2001/10/22 19:27:15 elena Exp $
*/
class XSDComplexTypeTraverser extends XSDAbstractParticleTraverser {
@@ -183,8 +183,18 @@
// ---------------------------------------------------------------
// First, handle any ANNOTATION declaration and get next child
// ---------------------------------------------------------------
- child = checkContent( DOMUtil.getFirstChildElement(complexTypeDecl), attrValues, schemaDoc);
+ child = DOMUtil.getFirstChildElement(complexTypeDecl);
+ if (child != null) {
+ // traverse annotation if any
+ if (DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ traverseAnnotationDecl(child, attrValues, false, schemaDoc);
+ child = DOMUtil.getNextSiblingElement(child);
+ }
+ if (child !=null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ reportGenericSchemaError("ComplexType "+complexTypeName+" has more than one annotation.");
+ }
+ }
// ---------------------------------------------------------------
// Process the content of the complex type definition
// ---------------------------------------------------------------
@@ -263,9 +273,15 @@
// -----------------------------------------------------------------------
typeInfo.fContentType = XSComplexTypeDecl.CONTENTTYPE_SIMPLE;
typeInfo.fParticle = null;
-
- Element simpleContent = checkContent(DOMUtil.getFirstChildElement(simpleContentElement), attrValues, schemaDoc);
+ Element simpleContent = DOMUtil.getFirstChildElement(simpleContentElement);
+ if (simpleContent != null) {
+ // traverse annotation if any
+ if (DOMUtil.getLocalName(simpleContent).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ traverseAnnotationDecl(simpleContent, attrValues, false, schemaDoc);
+ simpleContent = DOMUtil.getNextSiblingElement(simpleContent);
+ }
+ }
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
// If there are no children, return
@@ -338,7 +354,7 @@
else {
baseValidator = (DatatypeValidator)type;
if (typeInfo.fDerivedBy == SchemaSymbols.RESTRICTION) {
- reportGenericSchemaError("ComplexTYpe " + typeName + ": " +
+ reportGenericSchemaError("ComplexType " + typeName + ": " +
"ct-props-correct.2: The base is a simple type. It cannot be used in a derivation by restriction");
throw new ComplexTypeRecoverableError();
}
@@ -358,8 +374,19 @@
// -----------------------------------------------------------------------
// Skip over any potential annotations
// -----------------------------------------------------------------------
- simpleContent = checkContent(DOMUtil.getFirstChildElement(simpleContent),
- null, schemaDoc);
+ simpleContent = DOMUtil.getFirstChildElement(simpleContent);
+ if (simpleContent != null) {
+ // traverse annotation if any
+
+ if (DOMUtil.getLocalName(simpleContent).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ traverseAnnotationDecl(simpleContent, null, false, schemaDoc);
+ simpleContent = DOMUtil.getNextSiblingElement(simpleContent);
+ }
+
+ if (simpleContent !=null && DOMUtil.getLocalName(simpleContent).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ reportGenericSchemaError("ComplexType "+typeName+" simpleContent has more than one annotation.");
+ }
+ }
// -----------------------------------------------------------------------
// Process a RESTRICTION
@@ -370,7 +397,7 @@
// There may be a simple type definition in the restriction element
// The data type validator will be based on it, if specified
// -----------------------------------------------------------------------
- if (DOMUtil.getLocalName(simpleContent).equals(SchemaSymbols.ELT_SIMPLETYPE )) {
+ if (simpleContent !=null && DOMUtil.getLocalName(simpleContent).equals(SchemaSymbols.ELT_SIMPLETYPE )) {
DatatypeValidator dv =fSchemaHandler.fSimpleTypeTraverser.traverseLocal(simpleContent, schemaDoc, grammar);
if (dv == null)
throw new ComplexTypeRecoverableError();
@@ -487,7 +514,14 @@
// -----------------------------------------------------------------------
typeInfo.fDatatypeValidator = null;
- Element complexContent = checkContent(DOMUtil.getFirstChildElement(complexContentElement), attrValues, schemaDoc);
+ Element complexContent = DOMUtil.getFirstChildElement(complexContentElement);
+ if (complexContent != null) {
+ // traverse annotation if any
+ if (DOMUtil.getLocalName(complexContent).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ traverseAnnotationDecl(complexContent, attrValues, false, schemaDoc);
+ complexContent = DOMUtil.getNextSiblingElement(complexContent);
+ }
+ }
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
// If there are no children, return
@@ -560,9 +594,18 @@
// -----------------------------------------------------------------------
// Skip over any potential annotations
// -----------------------------------------------------------------------
- complexContent = checkContent(DOMUtil.getFirstChildElement(complexContent),
- null, schemaDoc);
+ complexContent = DOMUtil.getFirstChildElement(complexContent);
+ if (complexContent != null) {
+ // traverse annotation if any
+ if (DOMUtil.getLocalName(complexContent).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ traverseAnnotationDecl(complexContent, null, false, schemaDoc);
+ complexContent = DOMUtil.getNextSiblingElement(complexContent);
+ }
+ if (complexContent !=null && DOMUtil.getLocalName(complexContent).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ reportGenericSchemaError("ComplexType "+typeName+" complexContent has more than one annotation.");
+ }
+ }
// -----------------------------------------------------------------------
// Process the content. Note: should I try to catch any complexType errors
// here in order to return the attr array?
1.14 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDNotationTraverser.java
Index: XSDNotationTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDNotationTraverser.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- XSDNotationTraverser.java 2001/10/19 20:25:27 1.13
+++ XSDNotationTraverser.java 2001/10/22 19:27:15 1.14
@@ -75,7 +75,7 @@
*
* @author Rahul Srivastava, Sun Microsystems Inc.
* @author Elena Litani, IBM
- * @version $Id: XSDNotationTraverser.java,v 1.13 2001/10/19 20:25:27 elena Exp $
+ * @version $Id: XSDNotationTraverser.java,v 1.14 2001/10/22 19:27:15 elena Exp $
*/
class XSDNotationTraverser extends XSDAbstractTraverser {
@@ -117,13 +117,13 @@
if (content != null) {
// traverse annotation if any
- if (content.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
+ if (DOMUtil.getLocalName(content).equals(SchemaSymbols.ELT_ANNOTATION)) {
traverseAnnotationDecl(content, attrValues, false, schemaDoc);
content = DOMUtil.getNextSiblingElement(content);
}
}
if (content!=null){
- Object[] args = new Object [] { content.getLocalName() };
+ Object[] args = new Object [] { DOMUtil.getLocalName(content) };
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"NotationContentRestricted",
args,
1.27 +5 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDSimpleTypeTraverser.java
Index: XSDSimpleTypeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDSimpleTypeTraverser.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- XSDSimpleTypeTraverser.java 2001/10/22 19:16:17 1.26
+++ XSDSimpleTypeTraverser.java 2001/10/22 19:27:15 1.27
@@ -108,7 +108,7 @@
* </union>
*
* @author Elena Litani, IBM
- * @version $Id: XSDSimpleTypeTraverser.java,v 1.26 2001/10/22 19:16:17 sandygao Exp $
+ * @version $Id: XSDSimpleTypeTraverser.java,v 1.27 2001/10/22 19:27:15 elena Exp $
*/
class XSDSimpleTypeTraverser extends XSDAbstractTraverser {
@@ -191,7 +191,7 @@
Element content = DOMUtil.getFirstChildElement(simpleTypeDecl);
if (content != null) {
// traverse annotation if any
- if (content.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
+ if (DOMUtil.getLocalName(content).equals(SchemaSymbols.ELT_ANNOTATION)) {
traverseAnnotationDecl(content, attrValues, false, schemaDoc);
content = DOMUtil.getNextSiblingElement(content);
}
@@ -276,7 +276,7 @@
//check content (annotation?, ...)
if (content != null) {
// traverse annotation if any
- if (content.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
+ if (DOMUtil.getLocalName(content).equals(SchemaSymbols.ELT_ANNOTATION)) {
traverseAnnotationDecl(content, attrValues, false, schemaDoc);
content = DOMUtil.getNextSiblingElement(content);
}
@@ -378,13 +378,13 @@
if (memberTypes != null) {
if (content != null) {
// traverse annotation if any
- if (content.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
+ if (DOMUtil.getLocalName(content).equals(SchemaSymbols.ELT_ANNOTATION)) {
traverseAnnotationDecl(content, attrValues, false, schemaDoc);
content = DOMUtil.getNextSiblingElement(content);
}
}
if (content !=null) {
- if (content.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
+ if (DOMUtil.getLocalName(content).equals(SchemaSymbols.ELT_ANNOTATION)) {
reportGenericSchemaError(nameProperty+" union should match the content Content: (annotation?, (simpleType*)");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org