You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by er...@locus.apache.org on 2000/05/10 05:31:34 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/validators/schema SchemaGrammar.java SchemaSymbols.java TraverseSchema.java
ericye 00/05/09 20:31:33
Modified: java/src/org/apache/xerces/validators/schema Tag: schemawork
SchemaGrammar.java SchemaSymbols.java
TraverseSchema.java
Log:
bug fixes: tested with ibm4_3_3v21-26 --ericye
Revision Changes Path
No revision
No revision
1.1.2.10 +37 -36 xml-xerces/java/src/org/apache/xerces/validators/schema/Attic/SchemaGrammar.java
Index: SchemaGrammar.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/Attic/SchemaGrammar.java,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- SchemaGrammar.java 2000/05/06 02:21:55 1.1.2.9
+++ SchemaGrammar.java 2000/05/10 03:31:32 1.1.2.10
@@ -56,7 +56,7 @@
* <http://www.apache.org/>.
*/
/*
- * @version $Id: SchemaGrammar.java,v 1.1.2.9 2000/05/06 02:21:55 ericye Exp $
+ * @version $Id: SchemaGrammar.java,v 1.1.2.10 2000/05/10 03:31:32 ericye Exp $
*/
package org.apache.xerces.validators.schema;
@@ -64,12 +64,14 @@
import org.apache.xerces.utils.QName;
import org.apache.xerces.framework.XMLContentSpec;
import org.apache.xerces.validators.datatype.DatatypeValidator;
+import org.apache.xerces.validators.datatype.DatatypeValidatorRegistry;
import org.apache.xerces.validators.common.XMLAttributeDecl;
import org.apache.xerces.validators.common.XMLContentModel;
import org.apache.xerces.validators.common.XMLElementDecl;
import org.apache.xerces.validators.common.Grammar;
import org.w3c.dom.Document;
+import java.util.Hashtable;
public class SchemaGrammar extends Grammar{
@@ -104,35 +106,17 @@
private TraverseSchema.ComplexTypeInfo fComplexTypeInfo[][] =
new TraverseSchema.ComplexTypeInfo[INITIAL_CHUNK_COUNT][];
- /*
- private int fElementDeclCount;
- private int fElementDeclNameIndex[][] = new int[INITIAL_CHUNK_COUNT][];
- private int fElementDeclType[][] = new int[INITIAL_CHUNK_COUNT][];
- private DatatypeValidator fElementDeclDatatypeValidator[][] = new DatatypeValidator[INITIAL_CHUNK_COUNT][];
- private int fElementDeclContentSpecIndex[][] = new int[INITIAL_CHUNK_COUNT][];
- private XMLContentModel fElementDeclContentModelValidator[][] = new XMLContentModel[INITIAL_CHUNK_COUNT][];
- private int fElementDeclFirstAttributeDeclIndex[][] = new int[INITIAL_CHUNK_COUNT][];
- private int fElementDeclLastAttributeDeclIndex[][] = new int[INITIAL_CHUNK_COUNT][];
- //
-
- // content spec tables
-
- private int fContentSpecCount;
- private int fContentSpecType[][] = new int[INITIAL_CHUNK_COUNT][];
- private int fContentSpecValue[][] = new int[INITIAL_CHUNK_COUNT][];
- private int fContentSpecOtherValue[][] = new int[INITIAL_CHUNK_COUNT][];
-
- // attribute decl tables
-
- private int fAttributeDeclCount;
- private QName fAttributeDeclName[][] = new QName[INITIAL_CHUNK_COUNT][];
- private DatatypeValidator fAttributeDeclDatatypeValidator[][] = new DatatypeValidator[INITIAL_CHUNK_COUNT][];
- private String fAttributeDeclDefaultValue[][] = new String[INITIAL_CHUNK_COUNT][];
- private int fAttributeDeclNextAttributeDeclIndex[][] = new int[INITIAL_CHUNK_COUNT][];
- // scope mapping tables
+ //ComplexType and SimpleTypeRegistries
+ private Hashtable fComplexTypeRegistry = null;
+ private DatatypeValidatorRegistry fDatatypeRegistry = null;
- */
+ public Hashtable getComplexTypeRegistry(){
+ return fComplexTypeRegistry;
+ }
+ public DatatypeValidatorRegistry getDatatypeRegistry(){
+ return fDatatypeRegistry;
+ }
//
// Public methods
@@ -175,6 +159,12 @@
//
// Protected methods
//
+ protected void setComplexTypeRegistry(Hashtable cTypeReg){
+ fComplexTypeRegistry = cTypeReg;
+ }
+ protected void setDatatypeRegistry(DatatypeValidatorRegistry dTypeReg){
+ fDatatypeRegistry = dTypeReg;
+ }
protected int createElementDecl() {
@@ -260,7 +250,7 @@
//note, this is the scope defined by the element, not its enclosing scope
setElementDefinedScope(elementDeclIndex, scopeDefined);
// debugging
-//System.out.println("xxxxxEltIndex :" + elementDeclIndex + ", contentSpecType: " + contentSpecType);
+//System.out.println("#######EltIndex :" + elementDeclIndex + ", contentSpecType: " + contentSpecType);
}
//debugging
@@ -295,6 +285,24 @@
super.setAttributeDecl(templateElementIndex, attrDeclIndex, fTempAttributeDecl);
}
+
+ protected int getAttributeDeclIndex(int elementIndex, QName attribute) {
+ if (elementIndex == -1) {
+ return -1;
+ }
+ int attDefIndex = getFirstAttributeDeclIndex(elementIndex);
+ while (attDefIndex != -1) {
+ getAttributeDecl(attDefIndex, fTempAttributeDecl);
+ if (fTempAttributeDecl.name.localpart == attribute.localpart &&
+ fTempAttributeDecl.name.uri == attribute.uri ) {
+ return attDefIndex;
+ }
+ attDefIndex = getNextAttributeDeclIndex(attDefIndex);
+ }
+ return -1;
+
+ } // getAttDef(int,QName)
+
/**
*@return the new contentSpec Index
*/
@@ -339,13 +347,6 @@
return true;
}
- /*private boolean ensureContentSpecCapacity(int chunk) {
- return true;
- }
-
- private boolean ensureAttributeDeclCapacity(int chunk) {
- return true;
- }*/
// resize initial chunk
1.1.2.6 +12 -11 xml-xerces/java/src/org/apache/xerces/validators/schema/Attic/SchemaSymbols.java
Index: SchemaSymbols.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/Attic/SchemaSymbols.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- SchemaSymbols.java 2000/05/09 22:11:06 1.1.2.5
+++ SchemaSymbols.java 2000/05/10 03:31:32 1.1.2.6
@@ -68,6 +68,7 @@
*/
public final class SchemaSymbols {
public static final String URI_XSI = "http://www.w3.org/1999/XMLSchema-instance";
+ public static final String URI_SCHEMAFORSCHEMA = "http://www.w3.org/1999/XMLSchema";
public static final String XSI_SCHEMALOCACTION = "schemaLocation";
public static final String XSI_NONAMESPACESCHEMALOCACTION = "noNamespaceSchemaLocation";
@@ -169,19 +170,19 @@
public static final String ATTVAL_EQUIVCLASS = "equivclass";
- public static final int EMPTY_SET = 0;
- public static final int EXTENSION = 1;
- public static final int RESTRICTION = 2;
- public static final int REPRODUCTION = 4;
- public static final int LIST = 8;
- public static final int ENUMERATION = 16;
- public static final int EQUIVCLASS = 32;
+ public static final int EMPTY_SET = 0;
+ public static final int EXTENSION = 1;
+ public static final int RESTRICTION = 2;
+ public static final int REPRODUCTION = 4;
+ public static final int LIST = 8;
+ public static final int ENUMERATION = 16;
+ public static final int EQUIVCLASS = 32;
- public static final int CHOICE = 0; // group orders
- public static final int SEQUENCE = 1; // group orders
- public static final int ALL = 2; // group orders
+ public static final int CHOICE = 0; // group orders
+ public static final int SEQUENCE = 1; // group orders
+ public static final int ALL = 2; // group orders
- public static final int INFINITY = -1; // used for maxOccurs
+ public static final int INFINITY = -1; // used for maxOccurs
}
1.1.2.24 +162 -82 xml-xerces/java/src/org/apache/xerces/validators/schema/Attic/TraverseSchema.java
Index: TraverseSchema.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/Attic/TraverseSchema.java,v
retrieving revision 1.1.2.23
retrieving revision 1.1.2.24
diff -u -r1.1.2.23 -r1.1.2.24
--- TraverseSchema.java 2000/05/09 21:39:42 1.1.2.23
+++ TraverseSchema.java 2000/05/10 03:31:32 1.1.2.24
@@ -58,6 +58,7 @@
package org.apache.xerces.validators.schema;
import org.apache.xerces.framework.XMLErrorReporter;
+import org.apache.xerces.validators.common.Grammar;
import org.apache.xerces.validators.common.GrammarResolver;
import org.apache.xerces.validators.common.GrammarResolverImpl;
import org.apache.xerces.validators.common.XMLElementDecl;
@@ -373,7 +374,7 @@
* Eric Ye
* @see org.apache.xerces.validators.common.Grammar
*
- * @version $Id: TraverseSchema.java,v 1.1.2.23 2000/05/09 21:39:42 ericye Exp $
+ * @version $Id: TraverseSchema.java,v 1.1.2.24 2000/05/10 03:31:32 ericye Exp $
*/
public class TraverseSchema implements
@@ -408,6 +409,8 @@
private String fTargetNSURIString = "";
private NamespacesScope fNamespacesScope = null;
+ private XMLAttributeDecl fTempAttributeDecl = new XMLAttributeDecl();
+
// REVISIT: maybe need to be moved into SchemaGrammar class
public class ComplexTypeInfo {
public String typeName;
@@ -466,6 +469,16 @@
fSchemaGrammar = schemaGrammar;
fGrammarResolver = grammarResolver;
+ if (fGrammarResolver == null) {
+ reportGenericSchemaError("Internal error: don't have a GrammarResolver for TraverseSchem");
+ }
+ else{
+ fSchemaGrammar.setComplexTypeRegistry(fComplexTypeRegistry);
+ fSchemaGrammar.setDatatypeRegistry(fDatatypeRegistry);
+ fGrammarResolver.putGrammar(fTargetNSURIString, fSchemaGrammar);
+ }
+
+
if (root == null) {
// REVISIT: Anything to do?
return;
@@ -545,12 +558,6 @@
}
} // for each child node
- if (fGrammarResolver == null) {
- reportGenericSchemaError("Internal error: don't have a GrammarResolver for TraverseSchem");
- }
- else{
- fGrammarResolver.putGrammar(fTargetNSURIString, fSchemaGrammar);
- }
} // traverseSchema(Element)
private void checkTopLevelDuplicateNames(Element root) {
@@ -772,6 +779,8 @@
//int parsedderivedBy = parseComplexDerivedBy(derivedBy);
//handle the inhreitance here.
if (base.length()>0) {
+
+ //first check if derivedBy is present
if (derivedBy.length() == 0) {
reportGenericSchemaError("derivedBy must be present when base is present in "
+SchemaSymbols.ELT_COMPLEXTYPE
@@ -791,10 +800,21 @@
}
int localpartIndex = fStringPool.addSymbol(localpart);
String typeURI = resolvePrefixToURI(prefix);
- if (!typeURI.equals(fTargetNSURIString)) {
+
+ // check if the base type is from the same Schema;
+ if (!typeURI.equals(fTargetNSURIString) && !typeURI.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA) ) {
baseTypeInfo = getTypeInfoFromNS(typeURI, localpart);
- //TO DO
- // REVISIT: baseTypeValidator = getTypeValidatorFromNS(typeURI, localpart);
+ if (baseTypeInfo == null) {
+ baseTypeValidator = getTypeValidatorFromNS(typeURI, localpart);
+ if (baseTypeValidator == null) {
+ //TO DO: report error here;
+ System.out.println("Counld not find base type " +localpart
+ + " in schema " + typeURI);
+ }
+ else{
+ baseIsSimpleSimple = true;
+ }
+ }
}
else {
@@ -812,7 +832,7 @@
if (baseTypeNode != null) {
baseTypeSymbol = traverseComplexTypeDecl( baseTypeNode );
baseTypeInfo = (ComplexTypeInfo)
- fComplexTypeRegistry.get(fStringPool.toString(baseTypeSymbol)); //REVIST: should it be fullBaseName;
+ fComplexTypeRegistry.get(fStringPool.toString(baseTypeSymbol)); //REVISIT: should it be fullBaseName;
}
else {
baseTypeNode = getTopLevelComponentByName(SchemaSymbols.ELT_SIMPLETYPE, localpart);
@@ -835,47 +855,46 @@
baseIsSimpleSimple = true;
}
}
+ }
//Schema Spec : 5.11: Complex Type Definition Properties Correct : 2
- if (baseIsSimpleSimple && derivedByRestriction) {
- reportGenericSchemaError("base is a simpledType, can't derive by restriction in " + typeName);
- }
+ if (baseIsSimpleSimple && derivedByRestriction) {
+ reportGenericSchemaError("base is a simpledType, can't derive by restriction in " + typeName);
+ }
- //if the base is a complexType
- if (baseTypeInfo != null ) {
+ //if the base is a complexType
+ if (baseTypeInfo != null ) {
- //Schema Spec : 5.11: Derivation Valid ( Extension ) 1.1.1
- // 5.11: Derivation Valid ( Restriction, Complex ) 1.2.1
- if (derivedByRestriction) {
- //REVISIT: check base Type's finalset does not include "restriction"
- }
- else {
- //REVISIT: check base Type's finalset doest not include "extension"
- }
+ //Schema Spec : 5.11: Derivation Valid ( Extension ) 1.1.1
+ // 5.11: Derivation Valid ( Restriction, Complex ) 1.2.1
+ if (derivedByRestriction) {
+ //REVISIT: check base Type's finalset does not include "restriction"
+ }
+ else {
+ //REVISIT: check base Type's finalset doest not include "extension"
+ }
- if ( baseTypeInfo.contentSpecHandle > -1) {
- if (derivedByRestriction) {
- //REVISIT: !!! really hairy staff to check the particle derivation OK in 5.10
- checkParticleDerivationOK(complexTypeDecl, baseTypeNode);
- }
- baseContentSpecHandle = baseTypeInfo.contentSpecHandle;
- }
- else if ( baseTypeInfo.datatypeValidator != null ) {
- baseTypeValidator = baseTypeInfo.datatypeValidator;
- baseIsComplexSimple = true;
+ if ( baseTypeInfo.contentSpecHandle > -1) {
+ if (derivedByRestriction) {
+ //REVISIT: !!! really hairy staff to check the particle derivation OK in 5.10
+ checkParticleDerivationOK(complexTypeDecl, baseTypeNode);
}
+ baseContentSpecHandle = baseTypeInfo.contentSpecHandle;
}
-
- //Schema Spec : 5.11: Derivation Valid ( Extension ) 1.1.1
- if (baseIsComplexSimple && !derivedByRestriction ) {
- reportGenericSchemaError("base is ComplexSimple, can't derive by extension in " + typeName);
+ else if ( baseTypeInfo.datatypeValidator != null ) {
+ baseTypeValidator = baseTypeInfo.datatypeValidator;
+ baseIsComplexSimple = true;
}
-
+ }
-
+ //Schema Spec : 5.11: Derivation Valid ( Extension ) 1.1.1
+ if (baseIsComplexSimple && !derivedByRestriction ) {
+ reportGenericSchemaError("base is ComplexSimple, can't derive by extension in " + typeName);
}
- }
- }
+
+ } // END of if (derivedBy.length() == 0) {} else {}
+ } // END of if (base.length() > 0) {}
+
// skip refinement and annotations
child = null;
@@ -939,10 +958,7 @@
}
// if content = textonly, base is a datatype
- if (content.length() == 0 && base.length() == 0) {
- contentSpecType = XMLElementDecl.TYPE_ANY;
- }
- else if (content.equals(SchemaSymbols.ATTVAL_TEXTONLY)) {
+ if (content.equals(SchemaSymbols.ATTVAL_TEXTONLY)) {
//TO DO
if (fDatatypeRegistry.getDatatypeValidator(base) == null) // must be datatype
reportSchemaError(SchemaMessageProvider.NotADatatype,
@@ -1077,7 +1093,7 @@
left, -1, false);
}
}
-
+
// if derived by extension and base complextype has a content model,
// compose the final content model by concatenating the base and the
// current in sequence.
@@ -1088,8 +1104,13 @@
false);
}
+ // REVISIT: this is when sees a topelevel <complexType name="abc">attrs*</complexType>
+ if (content.length() == 0 && base.length() == 0 && left == -2) {
+ contentSpecType = XMLElementDecl.TYPE_ANY;
+ }
+
//debugging
-// System.out.println("!!!!!>>>>>" + typeName+", "+ baseTypeInfo + ", " + baseContentSpecHandle +", " + left);
+// System.out.println("!!!!!>>>>>" + typeName+", "+ baseTypeInfo + ", " + baseContentSpecHandle +", " + left +", "+scopeDefined);
ComplexTypeInfo typeInfo = new ComplexTypeInfo();
typeInfo.baseComplexTypeInfo = baseTypeInfo;
@@ -1128,20 +1149,32 @@
traverseAttributeDecl(child, typeInfo);
}
else if ( childName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ) {
-
traverseAttributeGroupDecl(child,typeInfo);
}
}
typeInfo.attlistHead = fSchemaGrammar.getFirstAttributeDeclIndex(typeInfo.templateElementIndex);
- if (baseTypeInfo != null)
- if ( !derivedByRestriction) {
- //TO DO: add the base attributes here, if duplicates happens, signal error.
- }
- else{
- //TO DO, add base attributes that is not duplicates
+ // merge in base type's attribute decls
+ if (baseTypeInfo != null && baseTypeInfo.attlistHead > -1 ) {
+ int attDefIndex = baseTypeInfo.attlistHead;
+ while ( attDefIndex > -1 ) {
+ fSchemaGrammar.getAttributeDecl(attDefIndex, fTempAttributeDecl);
+ attDefIndex = fSchemaGrammar.getNextAttributeDeclIndex(attDefIndex);
+ // if found a duplicate, if it is derived by restriction. then skip the one from the base type
+ if (fSchemaGrammar.getAttributeDeclIndex(typeInfo.templateElementIndex, fTempAttributeDecl.name) > -1) {
+ if (derivedByRestriction) {
+ continue;
+ }
+ }
+ //REVISIT:
+ // int enumeration = ????
+ fSchemaGrammar.addAttDef( typeInfo.templateElementIndex,
+ fTempAttributeDecl.name, fTempAttributeDecl.type,
+ -1, fTempAttributeDecl.defaultType,
+ fTempAttributeDecl.defaultValue, fTempAttributeDecl.datatypeValidator);
}
-
+ }
+
if (!typeName.startsWith("#")) {
typeName = fTargetNSURIString + "," + typeName;
}
@@ -1150,6 +1183,7 @@
// before exit the complex type definition, restore the scope, mainly for nested Anonymous Types
fCurrentScope = previousScope;
+ typeNameIndex = fStringPool.addSymbol(typeName);
return typeNameIndex;
@@ -1467,6 +1501,7 @@
QName attQName = new QName(-1,attName,attName,uriIndex);
//debugging
// System.out.println(" the dataType Validator for " + fStringPool.toString(attName) + " is " + dv);
+
// add attribute to attr decl pool in fSchemaGrammar,
fSchemaGrammar.addAttDef( typeInfo.templateElementIndex,
attQName, attType,
@@ -1506,12 +1541,13 @@
localpart = ref.substring(colonptr+1);
}
if (!resolvePrefixToURI(prefix).equals(fTargetNSURIString)) {
+ // TO DO
// REVISIST: different NS, not supported yet.
reportGenericSchemaError("Feature not supported: see an attribute from different NS");
}
Element referredAttrGrp = getTopLevelComponentByName(SchemaSymbols.ELT_ATTRIBUTEGROUP,localpart);
if (referredAttrGrp != null) {
- traverseAttributeDecl(referredAttrGrp, typeInfo);
+ traverseAttributeGroupDecl(referredAttrGrp, typeInfo);
}
else {
reportGenericSchemaError ( "Couldn't find top level attributegroup " + ref);
@@ -1686,6 +1722,7 @@
fStringPool.addSymbol(resolvePrefixToURI(prefix)) );
int elementIndex = fSchemaGrammar.getElementDeclIndex(localpartIndex, TOP_LEVEL_SCOPE);
//if not found, traverse the top level element that if referenced
+
if (elementIndex == -1 ) {
eltName=
traverseElementDecl(
@@ -1727,7 +1764,8 @@
fComplexTypeRegistry.get(fStringPool.toString(typeNameIndex));
haveAnonType = true;
-
+//debugging
+//System.out.println("--------element Typeinfo : " + name + " : " + typeInfo.scopeDefined + "," + fCurrentScope);
}
else if (childName.equals(SchemaSymbols.ELT_SIMPLETYPE)) {
// TO DO: the Default and fixed attribute handling should be here.
@@ -1762,33 +1800,47 @@
localpart = type.substring(colonptr+1);
}
String typeURI = resolvePrefixToURI(prefix);
- if (!typeURI.equals(fTargetNSURIString)) {
+
+ // check if the type is from the same Schema
+ if (!typeURI.equals(fTargetNSURIString) && !typeURI.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)) {
fromAnotherSchema = typeURI;
typeInfo = getTypeInfoFromNS(typeURI, localpart);
- }
- typeInfo = (ComplexTypeInfo) fComplexTypeRegistry.get(typeURI+","+localpart);
- if (typeInfo == null) {
- dv = fDatatypeRegistry.getDatatypeValidator(localpart);
- if (dv == null) {
- Element topleveltype = getTopLevelComponentByName(SchemaSymbols.ELT_COMPLEXTYPE,localpart);
- if (topleveltype != null) {
- typeNameIndex = traverseComplexTypeDecl( topleveltype );
- typeInfo = (ComplexTypeInfo)
- fComplexTypeRegistry.get(fStringPool.toString(typeNameIndex));
+ if (typeInfo == null) {
+ dv = getTypeValidatorFromNS(typeURI, localpart);
+ if (dv == null) {
+ //TO DO: report error here;
+ System.out.println("Counld not find base type " +localpart
+ + " in schema " + typeURI);
}
- else {
- topleveltype = getTopLevelComponentByName(SchemaSymbols.ELT_SIMPLETYPE, localpart);
+ }
+ }
+ else {
+//debugging
+//System.out.println("typeURI : " + typeURI + ","+fCurrentScope + "," + name);
+ typeInfo = (ComplexTypeInfo) fComplexTypeRegistry.get(typeURI+","+localpart);
+ if (typeInfo == null) {
+ dv = fDatatypeRegistry.getDatatypeValidator(localpart);
+ if (dv == null) {
+ Element topleveltype = getTopLevelComponentByName(SchemaSymbols.ELT_COMPLEXTYPE,localpart);
if (topleveltype != null) {
- typeNameIndex = traverseSimpleTypeDecl( topleveltype );
- dv = fDatatypeRegistry.getDatatypeValidator(localpart);
- // TO DO: the Default and fixed attribute handling should be here.
+ typeNameIndex = traverseComplexTypeDecl( topleveltype );
+ typeInfo = (ComplexTypeInfo)
+ fComplexTypeRegistry.get(fStringPool.toString(typeNameIndex));
}
else {
- reportGenericSchemaError("type not found : " + localpart);
+ topleveltype = getTopLevelComponentByName(SchemaSymbols.ELT_SIMPLETYPE, localpart);
+ if (topleveltype != null) {
+ typeNameIndex = traverseSimpleTypeDecl( topleveltype );
+ dv = fDatatypeRegistry.getDatatypeValidator(localpart);
+ // TO DO: the Default and fixed attribute handling should be here.
+ }
+ else {
+ reportGenericSchemaError("type not found : " + localpart);
+ }
+
}
}
-
}
}
@@ -1845,7 +1897,7 @@
// add element decl to pool
int attrListHead = -1 ;
-
+
// copy up attribute decls from type object
if (typeInfo != null) {
attrListHead = typeInfo.attlistHead;
@@ -1853,9 +1905,13 @@
int elementIndex = fSchemaGrammar.addElementDecl(eltQName, enclosingScope, scopeDefined,
contentSpecType, contentSpecNodeIndex,
attrListHead, dv);
- // System.out.println("elementIndex:"+elementIndex+" "+elementDecl.getAttribute(ATT_NAME)+" eltType:"+elementName+" contentSpecType:"+contentSpecType+
- // " SpecNodeIndex:"+ contentSpecNodeIndex);
-
+//debugging
+ /***
+ System.out.println("########elementIndex:"+elementIndex+" "+elementDecl.getAttribute(SchemaSymbols.ATT_NAME)
+ +" eltType:"+name+" contentSpecType:"+contentSpecType+
+ " SpecNodeIndex:"+ contentSpecNodeIndex +" enclosingScope: " +enclosingScope +
+ " scopeDefined: " +scopeDefined);
+ /***/
if (typeInfo != null) {
fSchemaGrammar.setElementComplexTypeInfo(elementIndex, typeInfo);
}
@@ -1925,10 +1981,31 @@
return false;
}
- DatatypeValidator getTypeValidatorFromNS(String typeURI, String localpart){
+ DatatypeValidator getTypeValidatorFromNS(String newSchemaURI, String localpart){
+ Grammar grammar = fGrammarResolver.getGrammar(newSchemaURI);
+ if (grammar != null && grammar instanceof SchemaGrammar) {
+ SchemaGrammar sGrammar = (SchemaGrammar) grammar;
+ DatatypeValidator dv = (DatatypeValidator) fSchemaGrammar.getDatatypeRegistry().getDatatypeValidator(localpart);
+ return dv;
+ }
+ else {
+ //TO DO: report internal erro here
+ System.out.println("could not resolver URI : " + newSchemaURI + " to a SchemaGrammar");
+ }
return null;
}
- ComplexTypeInfo getTypeInfoFromNS(String typeURI, String localpart){
+
+ ComplexTypeInfo getTypeInfoFromNS(String newSchemaURI, String localpart){
+ Grammar grammar = fGrammarResolver.getGrammar(newSchemaURI);
+ if (grammar != null && grammar instanceof SchemaGrammar) {
+ SchemaGrammar sGrammar = (SchemaGrammar) grammar;
+ ComplexTypeInfo typeInfo = (ComplexTypeInfo) fSchemaGrammar.getComplexTypeRegistry().get(newSchemaURI+","+localpart);
+ return typeInfo;
+ }
+ else {
+ //TO DO: report internal erro here
+ System.out.println("could not resolver URI : " + newSchemaURI + " to a SchemaGrammar");
+ }
return null;
}
/**
@@ -1999,6 +2076,9 @@
localpart = ref.substring(colonptr+1);
}
int localpartIndex = fStringPool.addSymbol(localpart);
+
+ //TO DO;
+ // here also need to address the issue if the named group is from another schema
int contentSpecIndex =
traverseGroupDecl(
getTopLevelComponentByName(SchemaSymbols.ELT_GROUP,localpart)