You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2003/06/23 18:35:23 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/xs/identity IdentityConstraint.java
neilg 2003/06/23 09:35:23
Modified: java/src/org/apache/xerces/impl/xs SchemaGrammar.java
XSAttributeDecl.java XSAttributeGroupDecl.java
XSComplexTypeDecl.java XSElementDecl.java
XSGroupDecl.java XSModelGroupImpl.java
XSModelImpl.java XSNotationDecl.java
XSWildcardDecl.java
java/src/org/apache/xerces/impl/xs/traversers
XSDAbstractIDConstraintTraverser.java
XSDAbstractParticleTraverser.java
XSDAbstractTraverser.java
XSDAttributeGroupTraverser.java
XSDAttributeTraverser.java
XSDComplexTypeTraverser.java
XSDElementTraverser.java XSDGroupTraverser.java
XSDHandler.java XSDNotationTraverser.java
XSDSimpleTypeTraverser.java
XSDWildcardTraverser.java
java/src/org/apache/xerces/impl/xs/identity
IdentityConstraint.java
Log:
ensure that annotations are passed to all components that may possess them.
Revision Changes Path
1.30 +32 -7 xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java
Index: SchemaGrammar.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- SchemaGrammar.java 24 Mar 2003 21:10:58 -0000 1.29
+++ SchemaGrammar.java 23 Jun 2003 16:35:21 -0000 1.30
@@ -64,6 +64,7 @@
import org.apache.xerces.impl.dv.XSSimpleType;
import org.apache.xerces.impl.xs.identity.IdentityConstraint;
import org.apache.xerces.impl.xs.psvi.StringList;
+import org.apache.xerces.impl.xs.psvi.XSAnnotation;
import org.apache.xerces.impl.xs.psvi.XSAttributeDeclaration;
import org.apache.xerces.impl.xs.psvi.XSAttributeGroupDefinition;
import org.apache.xerces.impl.xs.psvi.XSConstants;
@@ -83,7 +84,6 @@
import org.apache.xerces.impl.xs.util.XSNamedMapImpl;
import org.apache.xerces.impl.xs.util.XSObjectListImpl;
import org.apache.xerces.util.SymbolHash;
-import org.apache.xerces.xni.grammars.Grammar;
import org.apache.xerces.xni.grammars.XMLGrammarDescription;
import org.apache.xerces.xni.grammars.XSGrammar;
@@ -102,7 +102,7 @@
* @version $Id$
*/
-public class SchemaGrammar implements Grammar, XSGrammar, XSNamespaceItem {
+public class SchemaGrammar implements XSGrammar, XSNamespaceItem {
// the target namespace of grammar
String fTargetNamespace;
@@ -119,6 +119,12 @@
// the XMLGrammarDescription member
XSDDescription fGrammarDescription = null;
+ // annotations associated with the "root" schema of this targetNamespace
+ XSAnnotationImpl [] fAnnotations = null;
+
+ // number of annotations declared
+ int fNumAnnotations;
+
//
// Constructors
//
@@ -237,7 +243,7 @@
// xsi:schemaLocation
name = SchemaSymbols.XSI_SCHEMALOCATION;
tns = SchemaSymbols.URI_XSI;
- type = schemaFactory.createTypeList(null, SchemaSymbols.URI_XSI, (short)0, anyURI);
+ type = schemaFactory.createTypeList(null, SchemaSymbols.URI_XSI, (short)0, anyURI, null);
fGlobalAttrDecls.put(name, new BuiltinAttrDecl(name, tns, type, scope));
// xsi:noNamespaceSchemaLocation
@@ -372,7 +378,7 @@
* register one identity constraint
*/
public final void addIDConstraintDecl(XSElementDecl elmDecl, IdentityConstraint decl) {
- elmDecl.addIDConstaint(decl);
+ elmDecl.addIDConstraint(decl);
fGlobalIDConstraintDecls.put(decl.getIdentityConstraintName(), decl);
}
@@ -624,6 +630,10 @@
return particleG;
}
+
+ public XSObjectList getAnnotations() {
+ return null;
+ }
}
private static class BuiltinAttrDecl extends XSAttributeDecl {
public BuiltinAttrDecl(String name, String tns,
@@ -643,6 +653,9 @@
public void reset () {
// also ignore this call.
}
+ public XSAnnotation getAnnotation() {
+ return null;
+ }
} // class BuiltinAttrDecl
// the grammars to hold components of the schema namespace
@@ -872,8 +885,20 @@
* @see org.apache.xerces.impl.xs.psvi.XSNamespaceItem#getAnnotations()
*/
public XSObjectList getAnnotations() {
- // REVISIT: implement
- return null;
+ return new XSObjectListImpl(fAnnotations, fNumAnnotations);
}
+
+ public void addAnnotation(XSAnnotationImpl annotation) {
+ if(annotation == null)
+ return;
+ if(fAnnotations == null) {
+ fAnnotations = new XSAnnotationImpl[2];
+ } else if(fNumAnnotations == fAnnotations.length) {
+ XSAnnotationImpl[] newArray = new XSAnnotationImpl[fNumAnnotations << 1];
+ System.arraycopy(fAnnotations, 0, newArray, 0, fNumAnnotations);
+ fAnnotations = newArray;
+ }
+ fAnnotations[fNumAnnotations++] = annotation;
+ }
} // class SchemaGrammar
1.13 +9 -5 xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeDecl.java
Index: XSAttributeDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeDecl.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XSAttributeDecl.java 21 Feb 2003 17:03:48 -0000 1.12
+++ XSAttributeDecl.java 23 Jun 2003 16:35:21 -0000 1.13
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -88,12 +88,15 @@
short fScope = XSConstants.SCOPE_ABSENT;
// enclosing complex type, when the scope is local
XSComplexTypeDecl fEnclosingCT = null;
+ // optional annotation
+ XSAnnotationImpl fAnnotation = null;
// value constraint value
ValidatedInfo fDefault = null;
public void setValues(String name, String targetNamespace,
XSSimpleType simpleType, short constraintType, short scope,
- ValidatedInfo valInfo, XSComplexTypeDecl enclosingCT) {
+ ValidatedInfo valInfo, XSComplexTypeDecl enclosingCT,
+ XSAnnotationImpl annotation) {
fName = name;
fTargetNamespace = targetNamespace;
fType = simpleType;
@@ -101,6 +104,7 @@
fScope = scope;
fDefault = valInfo;
fEnclosingCT = enclosingCT;
+ fAnnotation = annotation;
}
public void reset(){
@@ -110,6 +114,7 @@
fConstraintType = XSConstants.VC_NONE;
fScope = XSConstants.SCOPE_ABSENT;
fDefault = null;
+ fAnnotation = null;
}
/**
@@ -185,8 +190,7 @@
* Optional. Annotation.
*/
public XSAnnotation getAnnotation() {
- // REVISIT: SCAPI: to implement
- return null;
+ return fAnnotation;
}
public ValidatedInfo getValInfo() {
1.14 +7 -4 xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java
Index: XSAttributeGroupDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- XSAttributeGroupDecl.java 18 Jun 2003 15:16:52 -0000 1.13
+++ XSAttributeGroupDecl.java 23 Jun 2003 16:35:21 -0000 1.14
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -91,6 +91,9 @@
// whether there is an attribute use whose type is or is derived from ID.
public String fIDAttrName = null;
+ // optional annotation
+ public XSAnnotationImpl fAnnotation;
+
// add an attribute use
// if the type is derived from ID, but there is already another attribute
// use of type ID, then return the name of the other attribute use;
@@ -333,6 +336,7 @@
}
fAttrUseNum = 0;
fAttributeWC = null;
+ fAnnotation = null;
fIDAttrName = null;
}
@@ -379,8 +383,7 @@
* Optional. Annotation.
*/
public XSAnnotation getAnnotation() {
- // REVISIT: SCAPI: to implement
- return null;
+ return fAnnotation;
}
/**
1.14 +15 -5 xml-xerces/java/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java
Index: XSComplexTypeDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- XSComplexTypeDecl.java 14 Jan 2003 20:21:45 -0000 1.13
+++ XSComplexTypeDecl.java 23 Jun 2003 16:35:21 -0000 1.14
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -61,6 +61,7 @@
import org.apache.xerces.impl.xs.psvi.*;
import org.apache.xerces.impl.xs.models.XSCMValidator;
import org.apache.xerces.impl.xs.models.CMBuilder;
+import org.apache.xerces.impl.xs.util.XSObjectListImpl;;
/**
* The XML representation for a complexType
@@ -109,6 +110,9 @@
// if there is a particle, the content model corresponding to that particle
XSCMValidator fCMValidator = null;
+ // list of annotations affiliated with this type
+ XSObjectListImpl fAnnotations = null;
+
public XSComplexTypeDecl() {
// do-nothing constructor for now.
}
@@ -117,7 +121,8 @@
XSTypeDefinition baseType, short derivedBy, short schemaFinal,
short block, short contentType,
boolean isAbstract, XSAttributeGroupDecl attrGrp,
- XSSimpleType simpleType, XSParticleDecl particle) {
+ XSSimpleType simpleType, XSParticleDecl particle,
+ XSObjectListImpl annotations) {
fTargetNamespace = targetNamespace;
fBaseType = baseType;
fDerivedBy = derivedBy;
@@ -129,6 +134,7 @@
fAttrGrp = attrGrp;
fXSSimpleType = simpleType;
fParticle = particle;
+ fAnnotations = annotations;
}
public void setName(String name) {
@@ -270,6 +276,11 @@
fXSSimpleType = null;
fParticle = null;
fCMValidator = null;
+ if(fAnnotations != null) {
+ // help out the garbage collector
+ fAnnotations.reset();
+ }
+ fAnnotations = null;
}
/**
@@ -416,8 +427,7 @@
* Optional. Annotation.
*/
public XSObjectList getAnnotations() {
- // REVISIT: SCAPI: to implement
- return null;
+ return fAnnotations;
}
/**
1.12 +8 -6 xml-xerces/java/src/org/apache/xerces/impl/xs/XSElementDecl.java
Index: XSElementDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSElementDecl.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- XSElementDecl.java 14 Jan 2003 20:21:45 -0000 1.11
+++ XSElementDecl.java 23 Jun 2003 16:35:21 -0000 1.12
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -98,6 +98,8 @@
public short fBlock = XSConstants.DERIVATION_NONE;
// final set (substitution group exclusions) of the element
public short fFinal = XSConstants.DERIVATION_NONE;
+ // optional annotation
+ public XSAnnotationImpl fAnnotation = null;
// value constraint value
public ValidatedInfo fDefault = null;
// the substitution group affiliation of the element
@@ -132,7 +134,7 @@
fEnclosingCT = enclosingCT;
}
- public void addIDConstaint(IdentityConstraint idc) {
+ public void addIDConstraint(IdentityConstraint idc) {
if (fIDCPos == fIDConstraints.length) {
fIDConstraints = resize(fIDConstraints, fIDCPos*2);
}
@@ -202,6 +204,7 @@
fBlock = XSConstants.DERIVATION_NONE;
fFinal = XSConstants.DERIVATION_NONE;
fDefault = null;
+ fAnnotation = null;
fSubGroup = null;
// reset identity constraints
for (int i=0;i<fIDCPos;i++) {
@@ -362,8 +365,7 @@
* Optional. Annotation.
*/
public XSAnnotation getAnnotation() {
- // REVISIT: SCAPI: to implement
- return null;
+ return fAnnotation;
}
@@ -375,4 +377,4 @@
return null;
}
-} // class XMLElementDecl
+} // class XSElementDecl
1.7 +5 -4 xml-xerces/java/src/org/apache/xerces/impl/xs/XSGroupDecl.java
Index: XSGroupDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSGroupDecl.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XSGroupDecl.java 14 Jan 2003 20:21:45 -0000 1.6
+++ XSGroupDecl.java 23 Jun 2003 16:35:21 -0000 1.7
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -74,6 +74,8 @@
public String fTargetNamespace = null;
// model group of the group
public XSModelGroupImpl fModelGroup = null;
+ // optional annotation
+ public XSAnnotationImpl fAnnotation = null;
/**
* Get the type of the object, i.e ELEMENT_DECLARATION.
@@ -110,8 +112,7 @@
* Optional. Annotation.
*/
public XSAnnotation getAnnotation() {
- // REVISIT: SCAPI: to implement
- return null;
+ return fAnnotation;
}
/**
1.4 +8 -5 xml-xerces/java/src/org/apache/xerces/impl/xs/XSModelGroupImpl.java
Index: XSModelGroupImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSModelGroupImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XSModelGroupImpl.java 21 Feb 2003 16:36:15 -0000 1.3
+++ XSModelGroupImpl.java 23 Jun 2003 16:35:21 -0000 1.4
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2002,2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -84,6 +84,9 @@
public XSParticleDecl[] fParticles = null;
public int fParticleCount = 0;
+ // this particle's optional annotation
+ public XSAnnotationImpl fAnnotation;
+
// whether this model group contains nothing
public boolean isEmpty() {
for (int i = 0; i < fParticleCount; i++) {
@@ -201,6 +204,7 @@
fParticles = null;
fParticleCount = 0;
fDescription = null;
+ fAnnotation = null;
}
/**
@@ -251,8 +255,7 @@
* Optional. Annotation.
*/
public XSAnnotation getAnnotation() {
- // REVISIT: SCAPI: to implement
- return null;
+ return fAnnotation;
}
/**
@@ -262,4 +265,4 @@
return null;
}
-} // class XSParticle
+} // class XSModelGroupImpl
1.9 +24 -5 xml-xerces/java/src/org/apache/xerces/impl/xs/XSModelImpl.java
Index: XSModelImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSModelImpl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XSModelImpl.java 22 Apr 2003 21:13:50 -0000 1.8
+++ XSModelImpl.java 23 Jun 2003 16:35:21 -0000 1.9
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2002, 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -75,6 +75,7 @@
import org.apache.xerces.impl.xs.util.StringListImpl;
import org.apache.xerces.impl.xs.util.XSNamedMap4Types;
import org.apache.xerces.impl.xs.util.XSNamedMapImpl;
+import org.apache.xerces.impl.xs.util.XSObjectListImpl;
import org.apache.xerces.util.SymbolHash;
import org.apache.xerces.util.XMLSymbols;
@@ -136,6 +137,9 @@
private XSNamedMap[] fGlobalComponents;
// store a certain kind of components from one namespace
private XSNamedMap[][] fNSComponents;
+
+ // store all annotations
+ private XSObjectListImpl fAnnotations = null;
/**
* Construct an XSModelImpl, by storing some grammars and grammars imported
@@ -439,9 +443,24 @@
/**
* {annotations} A set of annotations.
*/
- public XSObjectList getAnnotations() {
- // REVISIT: SCAPI: to implement
- return null;
+ public synchronized XSObjectList getAnnotations() {
+ if(fAnnotations != null)
+ return fAnnotations;
+
+ // do this in two passes to avoid inaccurate array size
+ int totalAnnotations = 0;
+ for (int i = 0; i < fGrammarCount; i++) {
+ totalAnnotations += fGrammarList[i].fNumAnnotations;
+ }
+ XSAnnotationImpl [] annotations = new XSAnnotationImpl [totalAnnotations];
+ int currPos = 0;
+ for (int i = 0; i < fGrammarCount; i++) {
+ SchemaGrammar currGrammar = fGrammarList[i];
+ System.arraycopy(currGrammar.fAnnotations, 0, annotations, currPos, currGrammar.fNumAnnotations);
+ currPos += currGrammar.fNumAnnotations;
+ }
+ fAnnotations = new XSObjectListImpl(annotations, annotations.length);
+ return fAnnotations;
}
private static final String null2EmptyString(String str) {
1.5 +6 -4 xml-xerces/java/src/org/apache/xerces/impl/xs/XSNotationDecl.java
Index: XSNotationDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSNotationDecl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XSNotationDecl.java 14 Jan 2003 20:21:45 -0000 1.4
+++ XSNotationDecl.java 23 Jun 2003 16:35:21 -0000 1.5
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -80,6 +80,9 @@
// system id of the notation
public String fSystemId = null;
+ // optional annotation
+ public XSAnnotationImpl fAnnotation = null;
+
/**
* Get the type of the object, i.e ELEMENT_DECLARATION.
*/
@@ -123,8 +126,7 @@
* Optional. Annotation.
*/
public XSAnnotation getAnnotation() {
- // REVISIT: SCAPI: to implement
- return null;
+ return fAnnotation;
}
/**
1.13 +6 -4 xml-xerces/java/src/org/apache/xerces/impl/xs/XSWildcardDecl.java
Index: XSWildcardDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSWildcardDecl.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XSWildcardDecl.java 18 Jun 2003 15:16:52 -0000 1.12
+++ XSWildcardDecl.java 23 Jun 2003 16:35:21 -0000 1.13
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -86,6 +86,9 @@
// for NSCONSTRAINT_NOT, it means not any of the namespaces in the list
public String[] fNamespaceList;
+ // optional annotation
+ public XSAnnotationImpl fAnnotation = null;
+
// I'm trying to implement the following constraint exactly as what the
// spec describes. Sometimes it seems redundant, and sometimes there seems
// to be much easier solutions. But it makes it easy to understand,
@@ -609,8 +612,7 @@
* Optional. Annotation.
*/
public XSAnnotation getAnnotation() {
- // REVISIT: SCAPI: to implement
- return null;
+ return fAnnotation;
}
1.8 +5 -5 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java
Index: XSDAbstractIDConstraintTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSDAbstractIDConstraintTraverser.java 18 Jun 2003 15:16:52 -0000 1.7
+++ XSDAbstractIDConstraintTraverser.java 23 Jun 2003 16:35:22 -0000 1.8
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -95,7 +95,7 @@
// General Attribute Checking on sElem
// first child could be an annotation
if (DOMUtil.getLocalName(sElem).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(sElem, icElemAttrs, false, schemaDoc);
+ ic.addAnnotation(traverseAnnotationDecl(sElem, icElemAttrs, false, schemaDoc));
sElem = DOMUtil.getNextSiblingElement(sElem);
}
// if no more children report an error
@@ -115,7 +115,7 @@
if (selChild !=null) {
// traverse annotation if any
if (DOMUtil.getLocalName(selChild).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(selChild, attrValues, false, schemaDoc);
+ ic.addAnnotation(traverseAnnotationDecl(selChild, attrValues, false, schemaDoc));
selChild = DOMUtil.getNextSiblingElement(selChild);
}
else {
@@ -167,7 +167,7 @@
if (fieldChild != null) {
// traverse annotation
if (DOMUtil.getLocalName(fieldChild).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(fieldChild, attrValues, false, schemaDoc);
+ ic.addAnnotation(traverseAnnotationDecl(fieldChild, attrValues, false, schemaDoc));
fieldChild = DOMUtil.getNextSiblingElement(fieldChild);
}
}
1.14 +27 -37 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractParticleTraverser.java
Index: XSDAbstractParticleTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractParticleTraverser.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- XSDAbstractParticleTraverser.java 18 Jun 2003 15:16:52 -0000 1.13
+++ XSDAbstractParticleTraverser.java 23 Jun 2003 16:35:22 -0000 1.14
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -61,6 +61,7 @@
import org.apache.xerces.impl.xs.SchemaSymbols;
import org.apache.xerces.impl.xs.XSParticleDecl;
import org.apache.xerces.impl.xs.XSModelGroupImpl;
+import org.apache.xerces.impl.xs.XSAnnotationImpl;
import org.apache.xerces.impl.xs.XSComplexTypeDecl;
import org.apache.xerces.util.DOMUtil;
import org.apache.xerces.impl.xs.util.XInt;
@@ -101,10 +102,11 @@
Element child = DOMUtil.getFirstChildElement(allDecl);
+ XSAnnotationImpl annotation = null;
if (child !=null) {
// traverse Annotation
if (DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(child, attrValues, false, schemaDoc);
+ annotation = traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
}
}
@@ -131,34 +133,26 @@
}
particle = null;
- // REVISIT: model group
- // Quick fix for the case that particle <all> does not have any children.
- // For now we return null. In the future we might want to return model group decl.
- if (fPArray.getParticleCount() != 0) {
-
- XInt minAtt = (XInt)attrValues[XSAttributeChecker.ATTIDX_MINOCCURS];
- XInt maxAtt = (XInt)attrValues[XSAttributeChecker.ATTIDX_MAXOCCURS];
- Long defaultVals = (Long)attrValues[XSAttributeChecker.ATTIDX_FROMDEFAULT];
+ XInt minAtt = (XInt)attrValues[XSAttributeChecker.ATTIDX_MINOCCURS];
+ XInt maxAtt = (XInt)attrValues[XSAttributeChecker.ATTIDX_MAXOCCURS];
+ Long defaultVals = (Long)attrValues[XSAttributeChecker.ATTIDX_FROMDEFAULT];
- XSModelGroupImpl group = new XSModelGroupImpl();
- group.fCompositor = XSModelGroupImpl.MODELGROUP_ALL;
- group.fParticleCount = fPArray.getParticleCount();
- group.fParticles = fPArray.popContext();
- particle = new XSParticleDecl();
- particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
- particle.fMinOccurs = minAtt.intValue();
- particle.fMaxOccurs = maxAtt.intValue();
- particle.fValue = group;
-
- particle = checkOccurrences(particle,
- SchemaSymbols.ELT_ALL,
- (Element)allDecl.getParentNode(),
- allContextFlags,
- defaultVals.longValue());
- }
- else {
- fPArray.discardContext();
- }
+ XSModelGroupImpl group = new XSModelGroupImpl();
+ group.fCompositor = XSModelGroupImpl.MODELGROUP_ALL;
+ group.fParticleCount = fPArray.getParticleCount();
+ group.fParticles = fPArray.popContext();
+ group.fAnnotation = annotation;
+ particle = new XSParticleDecl();
+ particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
+ particle.fMinOccurs = minAtt.intValue();
+ particle.fMaxOccurs = maxAtt.intValue();
+ particle.fValue = group;
+
+ particle = checkOccurrences(particle,
+ SchemaSymbols.ELT_ALL,
+ (Element)allDecl.getParentNode(),
+ allContextFlags,
+ defaultVals.longValue());
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
return particle;
@@ -232,10 +226,11 @@
Object[] attrValues = fAttrChecker.checkAttributes(decl, false, schemaDoc);
Element child = DOMUtil.getFirstChildElement(decl);
+ XSAnnotationImpl annotation = null;
if (child !=null) {
// traverse Annotation
if (DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(child, attrValues, false, schemaDoc);
+ annotation = traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
}
}
@@ -299,6 +294,7 @@
group.fCompositor = choice ? XSModelGroupImpl.MODELGROUP_CHOICE : XSModelGroupImpl.MODELGROUP_SEQUENCE;
group.fParticleCount = fPArray.getParticleCount();
group.fParticles = fPArray.popContext();
+ group.fAnnotation = annotation;
particle = new XSParticleDecl();
particle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
particle.fMinOccurs = minAtt.intValue();
@@ -393,12 +389,6 @@
return array;
}
- void discardContext() {
- // clear the particle array, to release memory
- for (int i = fPos[fContextCount-1]; i < fPos[fContextCount]; i++)
- fParticles[i] = null;
- fContextCount--;
- }
}
// the big particle array to hold all particles in model groups
1.27 +9 -5 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.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- XSDAbstractTraverser.java 18 Jun 2003 15:16:52 -0000 1.26
+++ XSDAbstractTraverser.java 23 Jun 2003 16:35:22 -0000 1.27
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -65,6 +65,7 @@
import org.apache.xerces.impl.validation.ValidationState;
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
+import org.apache.xerces.impl.xs.XSAnnotationImpl;
import org.apache.xerces.impl.xs.XSAttributeGroupDecl;
import org.apache.xerces.impl.xs.XSAttributeUseImpl;
import org.apache.xerces.impl.xs.XSComplexTypeDecl;
@@ -133,8 +134,8 @@
// REVISIT: store annotation information for PSVI
// REVISIT: how to pass the parentAttrs? as DOM attributes?
// as name/value pairs (string)? in parsed form?
- // REVISIT: what to return
- void traverseAnnotationDecl(Element annotationDecl, Object[] parentAttrs,
+ // @return XSAnnotationImpl object
+ XSAnnotationImpl traverseAnnotationDecl(Element annotationDecl, Object[] parentAttrs,
boolean isGlobal, XSDocumentInfo schemaDoc) {
// General Attribute Checking
Object[] attrValues = fAttrChecker.checkAttributes(annotationDecl, isGlobal, schemaDoc);
@@ -159,7 +160,7 @@
fAttrChecker.returnAttrArray(attrValues, schemaDoc);
}
- // REVISIT: an annotation decl should be returned when we support PSVI
+ return null;
}
// the QName simple type used to resolve qnames
@@ -222,6 +223,7 @@
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);
child = DOMUtil.getNextSiblingElement(child);
}
@@ -245,6 +247,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);
child = DOMUtil.getNextSiblingElement(child);
}
@@ -338,6 +341,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);
child = DOMUtil.getNextSiblingElement(child);
}
1.11 +7 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAttributeGroupTraverser.java
Index: XSDAttributeGroupTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAttributeGroupTraverser.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XSDAttributeGroupTraverser.java 18 Jun 2003 15:16:52 -0000 1.10
+++ XSDAttributeGroupTraverser.java 23 Jun 2003 16:35:22 -0000 1.11
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -58,6 +58,7 @@
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
+import org.apache.xerces.impl.xs.XSAnnotationImpl;
import org.apache.xerces.impl.xs.XSAttributeGroupDecl;
import org.apache.xerces.util.DOMUtil;
import org.apache.xerces.util.XMLSymbols;
@@ -154,11 +155,12 @@
// check the content
Element child = DOMUtil.getFirstChildElement(elmNode);
+ XSAnnotationImpl annotation = null;
if (child!=null) {
String childName = DOMUtil.getLocalName(child);
if (childName.equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(child, attrValues, false, schemaDoc);
+ annotation = traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
}
}
@@ -188,6 +190,8 @@
reportSchemaError("src-redefine.7.2.2", new Object [] {nameAttr, errArgs[errArgs.length-1]}, child);
}
}
+
+ attrGrp.fAnnotation = annotation;
// make an entry in global declarations.
grammar.addGlobalAttributeGroupDecl(attrGrp);
1.25 +7 -4 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java
Index: XSDAttributeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- XSDAttributeTraverser.java 18 Jun 2003 15:16:52 -0000 1.24
+++ XSDAttributeTraverser.java 23 Jun 2003 16:35:22 -0000 1.25
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -63,6 +63,7 @@
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
import org.apache.xerces.impl.xs.XSAttributeDecl;
+import org.apache.xerces.impl.xs.XSAnnotationImpl;
import org.apache.xerces.impl.xs.XSAttributeUseImpl;
import org.apache.xerces.impl.xs.XSComplexTypeDecl;
import org.apache.xerces.impl.xs.psvi.XSConstants;
@@ -122,6 +123,7 @@
Element child = DOMUtil.getFirstChildElement(attrDecl);
if (child != null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ // REVISIT: put this somewhere
traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
}
@@ -293,8 +295,9 @@
// get 'annotation'
Element child = DOMUtil.getFirstChildElement(attrDecl);
+ XSAnnotationImpl annotation = null;
if (child != null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(child, attrValues, false, schemaDoc);
+ annotation = traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
}
@@ -327,7 +330,7 @@
}
attribute.setValues(nameAtt, tnsAtt, attrType,
- constraintType, scope, attDefault, enclCT);
+ constraintType, scope, attDefault, enclCT, annotation);
// Step 2: register attribute decl to the grammar
if (isGlobal && nameAtt != null)
1.37 +32 -9 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
Index: XSDComplexTypeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- XSDComplexTypeTraverser.java 18 Jun 2003 15:16:52 -0000 1.36
+++ XSDComplexTypeTraverser.java 23 Jun 2003 16:35:22 -0000 1.37
@@ -62,6 +62,7 @@
import org.apache.xerces.impl.dv.XSSimpleType;
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
+import org.apache.xerces.impl.xs.XSAnnotationImpl;
import org.apache.xerces.impl.xs.XSAttributeGroupDecl;
import org.apache.xerces.impl.xs.XSAttributeUseImpl;
import org.apache.xerces.impl.xs.XSComplexTypeDecl;
@@ -73,6 +74,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.xni.QName;
import org.w3c.dom.Element;
@@ -98,7 +100,7 @@
class XSDComplexTypeTraverser extends XSDAbstractParticleTraverser {
// size of stack to hold globals:
- private final static int GLOBAL_NUM = 10;
+ private final static int GLOBAL_NUM = 11;
// globals for building XSComplexTypeDecls
private String fName = null;
@@ -113,6 +115,7 @@
private XSParticleDecl fParticle = null;
private boolean fIsAbstract = false;
private XSComplexTypeDecl fComplexTypeDecl = null;
+ private XSAnnotationImpl [] fAnnotations = null;
private XSParticleDecl fEmptyParticle = null;
@@ -240,7 +243,7 @@
if (child != null) {
// traverse annotation if any
if (DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(child, attrValues, false, schemaDoc);
+ addAnnotation(traverseAnnotationDecl(child, attrValues, false, schemaDoc));
child = DOMUtil.getNextSiblingElement(child);
}
if (child !=null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
@@ -312,7 +315,8 @@
}
fComplexTypeDecl.setValues(fName, fTargetNamespace, fBaseType,
fDerivedBy, fFinal, fBlock, fContentType, fIsAbstract,
- fAttrGrp, fXSSimpleType, fParticle);
+ fAttrGrp, fXSSimpleType, fParticle, new XSObjectListImpl(fAnnotations,
+ fAnnotations == null? 0 : fAnnotations.length));
return fComplexTypeDecl;
}
@@ -336,7 +340,7 @@
if (simpleContent != null) {
// traverse annotation if any
if (DOMUtil.getLocalName(simpleContent).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(simpleContent, simpleContentAttrValues, false, schemaDoc);
+ addAnnotation(traverseAnnotationDecl(simpleContent, simpleContentAttrValues, false, schemaDoc));
simpleContent = DOMUtil.getNextSiblingElement(simpleContent);
}
}
@@ -455,7 +459,7 @@
// traverse annotation if any
if (DOMUtil.getLocalName(simpleContent).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(simpleContent, derivationTypeAttrValues, false, schemaDoc);
+ addAnnotation(traverseAnnotationDecl(simpleContent, derivationTypeAttrValues, false, schemaDoc));
simpleContent = DOMUtil.getNextSiblingElement(simpleContent);
}
@@ -529,7 +533,7 @@
fixedFacets = fi.fFixedFacets;
}
- fXSSimpleType = schemaFactory.createTypeRestriction(null,schemaDoc.fTargetNamespace,(short)0,baseValidator);
+ fXSSimpleType = schemaFactory.createTypeRestriction(null,schemaDoc.fTargetNamespace,(short)0,baseValidator,null);
try{
fValidationState.setNamespaceSupport(schemaDoc.fNamespaceSupport);
fXSSimpleType.applyFacets(facetData, presentFacets, fixedFacets, fValidationState);
@@ -655,7 +659,7 @@
if (complexContent != null) {
// traverse annotation if any
if (DOMUtil.getLocalName(complexContent).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(complexContent, complexContentAttrValues, false, schemaDoc);
+ addAnnotation(traverseAnnotationDecl(complexContent, complexContentAttrValues, false, schemaDoc));
complexContent = DOMUtil.getNextSiblingElement(complexContent);
}
}
@@ -744,7 +748,7 @@
if (complexContent != null) {
// traverse annotation if any
if (DOMUtil.getLocalName(complexContent).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(complexContent, derivationTypeAttrValues, false, schemaDoc);
+ addAnnotation(traverseAnnotationDecl(complexContent, derivationTypeAttrValues, false, schemaDoc));
complexContent = DOMUtil.getNextSiblingElement(complexContent);
}
if (complexContent !=null &&
@@ -1169,9 +1173,11 @@
fGlobalStore[fGlobalStorePos++] = fAttrGrp;
fGlobalStore[fGlobalStorePos++] = fParticle;
fGlobalStore[fGlobalStorePos++] = fXSSimpleType;
+ fGlobalStore[fGlobalStorePos++] = fAnnotations;
}
private void contentRestore() {
+ fAnnotations = (XSAnnotationImpl [])fGlobalStore[--fGlobalStorePos];
fXSSimpleType = (XSSimpleType)fGlobalStore[--fGlobalStorePos];
fParticle = (XSParticleDecl)fGlobalStore[--fGlobalStorePos];
fAttrGrp = (XSAttributeGroupDecl)fGlobalStore[--fGlobalStorePos];
@@ -1186,5 +1192,22 @@
fName = (String)fGlobalStore[--fGlobalStorePos];
fIsAbstract = ((Boolean)fGlobalStore[--fGlobalStorePos]).booleanValue();
fComplexTypeDecl = (XSComplexTypeDecl)fGlobalStore[--fGlobalStorePos];
+ }
+
+ private void addAnnotation(XSAnnotationImpl annotation) {
+ if(annotation == null)
+ return;
+ // it isn't very likely that there will be more than one annotation
+ // in a complexType decl. This saves us fromhaving to push/pop
+ // one more object from the fGlobalStore, and that's bound
+ // to be a savings for most applications
+ if(fAnnotations == null) {
+ fAnnotations = new XSAnnotationImpl[1];
+ } else {
+ XSAnnotationImpl [] tempArray = new XSAnnotationImpl[fAnnotations.length + 1];
+ System.arraycopy(fAnnotations, 0, tempArray, 0, fAnnotations.length);
+ fAnnotations = tempArray;
+ }
+ fAnnotations[fAnnotations.length-1] = annotation;
}
}
1.25 +7 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
Index: XSDElementTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- XSDElementTraverser.java 18 Jun 2003 15:16:53 -0000 1.24
+++ XSDElementTraverser.java 23 Jun 2003 16:35:22 -0000 1.25
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -61,6 +61,7 @@
import org.apache.xerces.impl.dv.XSSimpleType;
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
+import org.apache.xerces.impl.xs.XSAnnotationImpl;
import org.apache.xerces.impl.xs.XSComplexTypeDecl;
import org.apache.xerces.impl.xs.XSConstraints;
import org.apache.xerces.impl.xs.XSElementDecl;
@@ -191,6 +192,7 @@
Element child = DOMUtil.getFirstChildElement(elmDecl);
if (child != null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ // REVISIT: put this somewhere
traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
}
@@ -335,10 +337,12 @@
// get 'annotation'
Element child = DOMUtil.getFirstChildElement(elmDecl);
+ XSAnnotationImpl annotation = null;
if(child != null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(child, attrValues, false, schemaDoc);
+ annotation = traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
}
+ element.fAnnotation = annotation;
// get 'type definition'
XSTypeDefinition elementType = null;
1.18 +7 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java
Index: XSDGroupTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- XSDGroupTraverser.java 18 Jun 2003 15:16:53 -0000 1.17
+++ XSDGroupTraverser.java 23 Jun 2003 16:35:22 -0000 1.18
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -58,6 +58,7 @@
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
+import org.apache.xerces.impl.xs.XSAnnotationImpl;
import org.apache.xerces.impl.xs.XSGroupDecl;
import org.apache.xerces.impl.xs.XSModelGroupImpl;
import org.apache.xerces.impl.xs.XSParticleDecl;
@@ -113,6 +114,7 @@
// no children other than "annotation?" are allowed
Element child = DOMUtil.getFirstChildElement(elmNode);
if (child != null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
+ // REVISIT: put this somewhere
traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
}
@@ -165,6 +167,7 @@
// must have at least one child
Element l_elmChild = DOMUtil.getFirstChildElement(elmNode);
+ XSAnnotationImpl annotation = null;
if (l_elmChild == null) {
reportSchemaError("s4s-elt-must-match.2",
new Object[]{"group (global)", "(annotation?, (all | choice | sequence))"},
@@ -172,7 +175,7 @@
} else {
String childName = l_elmChild.getLocalName();
if (childName.equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(l_elmChild, attrValues, true, schemaDoc);
+ annotation = traverseAnnotationDecl(l_elmChild, attrValues, true, schemaDoc);
l_elmChild = DOMUtil.getNextSiblingElement(l_elmChild);
if (l_elmChild != null)
childName = l_elmChild.getLocalName();
@@ -209,6 +212,7 @@
group.fTargetNamespace = schemaDoc.fTargetNamespace;
if (particle != null)
group.fModelGroup = (XSModelGroupImpl)particle.fValue;
+ group.fAnnotation = annotation;
grammar.addGlobalGroupDecl(group);
}
}
1.71 +11 -5 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
Index: XSDHandler.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- XSDHandler.java 18 Jun 2003 22:13:45 -0000 1.70
+++ XSDHandler.java 23 Jun 2003 16:35:22 -0000 1.71
@@ -634,7 +634,9 @@
if(importChild != null ) {
String importComponentType = DOMUtil.getLocalName(importChild);
if (importComponentType.equals(SchemaSymbols.ELT_ANNOTATION)) {
- fElementTraverser.traverseAnnotationDecl(importChild, importAttrs, true, currSchemaInfo);
+ // promoting annotations to parent component
+ sg.addAnnotation(
+ fElementTraverser.traverseAnnotationDecl(importChild, importAttrs, true, currSchemaInfo));
} else {
reportSchemaError("s4s-elt-must-match.1", new Object [] {localName, "annotation?", importComponentType}, child);
}
@@ -701,7 +703,9 @@
if(includeChild != null ) {
String includeComponentType = DOMUtil.getLocalName(includeChild);
if (includeComponentType.equals(SchemaSymbols.ELT_ANNOTATION)) {
- fElementTraverser.traverseAnnotationDecl(includeChild, includeAttrs, true, currSchemaInfo);
+ // promoting annotations to parent component
+ sg.addAnnotation(
+ fElementTraverser.traverseAnnotationDecl(includeChild, includeAttrs, true, currSchemaInfo));
} else {
reportSchemaError("s4s-elt-must-match.1", new Object [] {localName, "annotation?", includeComponentType}, child);
}
@@ -716,7 +720,9 @@
redefinedChild = DOMUtil.getNextSiblingElement(redefinedChild)) {
String redefinedComponentType = DOMUtil.getLocalName(redefinedChild);
if (redefinedComponentType.equals(SchemaSymbols.ELT_ANNOTATION)) {
- fElementTraverser.traverseAnnotationDecl(redefinedChild, includeAttrs, true, currSchemaInfo);
+ // promoting annotations to parent component
+ sg.addAnnotation(
+ fElementTraverser.traverseAnnotationDecl(redefinedChild, includeAttrs, true, currSchemaInfo));
DOMUtil.setHidden(redefinedChild);
}
// catch all other content errors later
@@ -1007,7 +1013,7 @@
fSimpleTypeTraverser.traverseGlobal(globalComp, currSchemaDoc, currSG);
}
else if (componentType.equals(SchemaSymbols.ELT_ANNOTATION)) {
- fElementTraverser.traverseAnnotationDecl(globalComp, currSchemaDoc.getSchemaAttrs(), true, currSchemaDoc);
+ currSG.addAnnotation(fElementTraverser.traverseAnnotationDecl(globalComp, currSchemaDoc.getSchemaAttrs(), true, currSchemaDoc));
}
else {
reportSchemaError("s4s-elt-invalid-content.1", new Object [] {SchemaSymbols.ELT_SCHEMA, DOMUtil.getLocalName(globalComp)}, globalComp);
1.11 +6 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDNotationTraverser.java
Index: XSDNotationTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDNotationTraverser.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XSDNotationTraverser.java 18 Jun 2003 15:16:53 -0000 1.10
+++ XSDNotationTraverser.java 23 Jun 2003 16:35:22 -0000 1.11
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -59,6 +59,7 @@
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
+import org.apache.xerces.impl.xs.XSAnnotationImpl;
import org.apache.xerces.impl.xs.XSNotationDecl;
import org.apache.xerces.util.DOMUtil;
import org.w3c.dom.Element;
@@ -115,14 +116,16 @@
//check content
Element content = DOMUtil.getFirstChildElement(elmNode);
+ XSAnnotationImpl annotation = null;
if (content != null) {
// traverse annotation if any
if (DOMUtil.getLocalName(content).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(content, attrValues, false, schemaDoc);
+ annotation = traverseAnnotationDecl(content, attrValues, false, schemaDoc);
content = DOMUtil.getNextSiblingElement(content);
}
}
+ notation.fAnnotation = annotation;
if (content!=null){
Object[] args = new Object [] {SchemaSymbols.ELT_NOTATION, "(annotation?)", DOMUtil.getLocalName(content)};
reportSchemaError("s4s-elt-must-match.1", args, content);
1.25 +29 -11 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java
Index: XSDSimpleTypeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- XSDSimpleTypeTraverser.java 18 Jun 2003 15:16:53 -0000 1.24
+++ XSDSimpleTypeTraverser.java 23 Jun 2003 16:35:22 -0000 1.25
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -65,9 +65,11 @@
import org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl;
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
+import org.apache.xerces.impl.xs.XSAnnotationImpl;
import org.apache.xerces.impl.xs.psvi.XSConstants;
import org.apache.xerces.impl.xs.psvi.XSObjectList;
import org.apache.xerces.impl.xs.psvi.XSTypeDefinition;
+import org.apache.xerces.impl.xs.util.XSObjectListImpl;
import org.apache.xerces.impl.xs.util.XInt;
import org.apache.xerces.util.DOMUtil;
import org.apache.xerces.xni.QName;
@@ -176,10 +178,13 @@
// annotation?,(list|restriction|union)
Element child = DOMUtil.getFirstChildElement(simpleTypeDecl);
+ XSAnnotationImpl [] annotations = null;
if (child != null) {
// traverse annotation if any
if (DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(child, attrValues, false, schemaDoc);
+ XSAnnotationImpl annotation = traverseAnnotationDecl(child, attrValues, false, schemaDoc);
+ if (annotation != null)
+ annotations = new XSAnnotationImpl [] {annotation};
child = DOMUtil.getNextSiblingElement(child);
}
}
@@ -231,7 +236,17 @@
if (content != null) {
// traverse annotation if any
if (DOMUtil.getLocalName(content).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(content, contentAttrs, false, schemaDoc);
+ XSAnnotationImpl annotation = traverseAnnotationDecl(content, contentAttrs, false, schemaDoc);
+ if(annotation != null ) {
+ if(annotations == null)
+ annotations = new XSAnnotationImpl [] {annotation};
+ else {
+ XSAnnotationImpl [] tempArray = new XSAnnotationImpl[2];
+ tempArray[0] = annotations[0];
+ annotations = tempArray;
+ annotations[1] = annotation;
+ }
+ }
content = DOMUtil.getNextSiblingElement(content);
}
}
@@ -272,7 +287,7 @@
}
}
- // when there is an error finding the base type of a restriciton
+ // when there is an error finding the base type of a restriction
// we use anySimpleType as the base, then we should skip the facets,
// because anySimpleType doesn't recognize any facet.
boolean skipFacets = false;
@@ -347,16 +362,19 @@
// create the simple type based on the "base" type
XSSimpleType newDecl = null;
if (restriction) {
- newDecl = schemaFactory.createTypeRestriction(name, schemaDoc.fTargetNamespace, (short)finalProperty, baseValidator);
+ newDecl = schemaFactory.createTypeRestriction(name, schemaDoc.fTargetNamespace, (short)finalProperty, baseValidator,
+ annotations == null? null : new XSObjectListImpl(annotations, annotations.length));
}
else if (list) {
- newDecl = schemaFactory.createTypeList(name, schemaDoc.fTargetNamespace, (short)finalProperty, baseValidator);
+ newDecl = schemaFactory.createTypeList(name, schemaDoc.fTargetNamespace, (short)finalProperty, baseValidator,
+ annotations == null? null : new XSObjectListImpl(annotations, annotations.length));
}
else if (union) {
XSSimpleType[] memberDecls = new XSSimpleType[dTValidators.size()];
for (int i = 0; i < dTValidators.size(); i++)
memberDecls[i] = (XSSimpleType)dTValidators.elementAt(i);
- newDecl = schemaFactory.createTypeUnion(name, schemaDoc.fTargetNamespace, (short)finalProperty, memberDecls);
+ newDecl = schemaFactory.createTypeUnion(name, schemaDoc.fTargetNamespace, (short)finalProperty, memberDecls,
+ annotations == null? null : new XSObjectListImpl(annotations, annotations.length));
}
// now traverse facets, if it's derived by restriction
@@ -467,13 +485,13 @@
switch (refType) {
case XSConstants.DERIVATION_RESTRICTION:
return schemaFactory.createTypeRestriction(name, namespace, (short)0,
- SchemaGrammar.fAnySimpleType);
+ SchemaGrammar.fAnySimpleType, null);
case XSConstants.DERIVATION_LIST:
return schemaFactory.createTypeList(name, namespace, (short)0,
- SchemaGrammar.fAnySimpleType);
+ SchemaGrammar.fAnySimpleType, null);
case XSConstants.DERIVATION_UNION:
return schemaFactory.createTypeUnion(name, namespace, (short)0,
- new XSSimpleType[]{SchemaGrammar.fAnySimpleType});
+ new XSSimpleType[]{SchemaGrammar.fAnySimpleType}, null);
}
return null;
1.11 +6 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDWildcardTraverser.java
Index: XSDWildcardTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDWildcardTraverser.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XSDWildcardTraverser.java 18 Jun 2003 15:16:53 -0000 1.10
+++ XSDWildcardTraverser.java 23 Jun 2003 16:35:22 -0000 1.11
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -59,6 +59,7 @@
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
+import org.apache.xerces.impl.xs.XSAnnotationImpl;
import org.apache.xerces.impl.xs.XSParticleDecl;
import org.apache.xerces.impl.xs.XSWildcardDecl;
import org.apache.xerces.impl.xs.util.XInt;
@@ -193,10 +194,11 @@
//check content
Element child = DOMUtil.getFirstChildElement(elmNode);
+ XSAnnotationImpl annotation = null;
if (child != null)
{
if (DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
- traverseAnnotationDecl(child, attrValues, false, schemaDoc);
+ annotation = traverseAnnotationDecl(child, attrValues, false, schemaDoc);
child = DOMUtil.getNextSiblingElement(child);
}
@@ -204,6 +206,7 @@
reportSchemaError("s4s-elt-must-match.1", new Object[]{"wildcard", "(annotation?)", DOMUtil.getLocalName(child)}, elmNode);
}
}
+ wildcard.fAnnotation = annotation;
return wildcard;
1.8 +29 -5 xml-xerces/java/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java
Index: IdentityConstraint.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- IdentityConstraint.java 20 Jan 2003 13:55:57 -0000 1.7
+++ IdentityConstraint.java 23 Jun 2003 16:35:23 -0000 1.8
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001, 2002 The Apache Software Foundation.
+ * Copyright (c) 2001-2003 The Apache Software Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -57,8 +57,14 @@
package org.apache.xerces.impl.xs.identity;
-import org.apache.xerces.impl.xs.psvi.*;
+import org.apache.xerces.impl.xs.psvi.XSIDCDefinition;
+import org.apache.xerces.impl.xs.psvi.StringList;
+import org.apache.xerces.impl.xs.psvi.XSNamespaceItem;
+import org.apache.xerces.impl.xs.psvi.XSObjectList;
+import org.apache.xerces.impl.xs.psvi.XSConstants;
import org.apache.xerces.impl.xs.util.StringListImpl;
+import org.apache.xerces.impl.xs.util.XSObjectListImpl;
+import org.apache.xerces.impl.xs.XSAnnotationImpl;
/**
* Base class of Schema identity constraint.
@@ -93,6 +99,12 @@
/** Fields. */
protected Field[] fFields;
+ // optional annotations
+ protected XSAnnotationImpl [] fAnnotations = null;
+
+ // number of annotations in this identity constraint
+ protected int fNumAnnotations;
+
//
// Constructors
//
@@ -247,8 +259,7 @@
* Optional. Annotation.
*/
public XSObjectList getAnnotations() {
- // REVISIT: SCAPI: to implement
- return null;
+ return new XSObjectListImpl(fAnnotations, fNumAnnotations);
}
/**
@@ -258,5 +269,18 @@
// REVISIT: implement
return null;
}
+
+ public void addAnnotation(XSAnnotationImpl annotation) {
+ if(annotation == null)
+ return;
+ if(fAnnotations == null) {
+ fAnnotations = new XSAnnotationImpl[2];
+ } else if(fNumAnnotations == fAnnotations.length) {
+ XSAnnotationImpl[] newArray = new XSAnnotationImpl[fNumAnnotations << 1];
+ System.arraycopy(fAnnotations, 0, newArray, 0, fNumAnnotations);
+ fAnnotations = newArray;
+ }
+ fAnnotations[fNumAnnotations++] = annotation;
+ }
} // class IdentityConstraint
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org