You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mu...@apache.org on 2009/09/12 15:43:19 UTC
svn commit: r814163 - in
/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces: impl/xs/
impl/xs/traversers/ util/ xs/
Author: mukulg
Date: Sat Sep 12 13:43:19 2009
New Revision: 814163
URL: http://svn.apache.org/viewvc?rev=814163&view=rev
Log:
XML Schema 1.1 inheritable attribute implementation, and related CTA integration (ref, JIRA issue XERCESJ-1391)
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaGrammar.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeDecl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeUseImpl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/XMLAttributesImpl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAttributeDeclaration.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAttributeUse.java
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaGrammar.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaGrammar.java?rev=814163&r1=814162&r2=814163&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaGrammar.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaGrammar.java Sat Sep 12 13:43:19 2009
@@ -420,28 +420,28 @@
XSAttributeUseImpl annotationIDAttr = new XSAttributeUseImpl();
annotationIDAttr.fAttrDecl = new XSAttributeDecl();
annotationIDAttr.fAttrDecl.setValues(SchemaSymbols.ATT_ID, null, (XSSimpleType) fGlobalTypeDecls.get(SchemaSymbols.ATTVAL_ID),
- XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, annotationType, null);
+ XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, annotationType, null, false);
annotationIDAttr.fUse = SchemaSymbols.USE_OPTIONAL;
annotationIDAttr.fConstraintType = XSConstants.VC_NONE;
XSAttributeUseImpl documentationSourceAttr = new XSAttributeUseImpl();
documentationSourceAttr.fAttrDecl = new XSAttributeDecl();
documentationSourceAttr.fAttrDecl.setValues(SchemaSymbols.ATT_SOURCE, null, (XSSimpleType) fGlobalTypeDecls.get(SchemaSymbols.ATTVAL_ANYURI),
- XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, documentationType, null);
+ XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, documentationType, null, false);
documentationSourceAttr.fUse = SchemaSymbols.USE_OPTIONAL;
documentationSourceAttr.fConstraintType = XSConstants.VC_NONE;
XSAttributeUseImpl documentationLangAttr = new XSAttributeUseImpl();
documentationLangAttr.fAttrDecl = new XSAttributeDecl();
documentationLangAttr.fAttrDecl.setValues("lang".intern(), NamespaceContext.XML_URI, (XSSimpleType) fGlobalTypeDecls.get(SchemaSymbols.ATTVAL_LANGUAGE),
- XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, documentationType, null);
+ XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, documentationType, null, false);
documentationLangAttr.fUse = SchemaSymbols.USE_OPTIONAL;
documentationLangAttr.fConstraintType = XSConstants.VC_NONE;
XSAttributeUseImpl appinfoSourceAttr = new XSAttributeUseImpl();
appinfoSourceAttr.fAttrDecl = new XSAttributeDecl();
appinfoSourceAttr.fAttrDecl.setValues(SchemaSymbols.ATT_SOURCE, null, (XSSimpleType) fGlobalTypeDecls.get(SchemaSymbols.ATTVAL_ANYURI),
- XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, appinfoType, null);
+ XSConstants.VC_NONE, XSConstants.SCOPE_LOCAL, null, appinfoType, null, false);
appinfoSourceAttr.fUse = SchemaSymbols.USE_OPTIONAL;
appinfoSourceAttr.fConstraintType = XSConstants.VC_NONE;
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java?rev=814163&r1=814162&r2=814163&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java Sat Sep 12 13:43:19 2009
@@ -143,6 +143,7 @@
public static final String ATT_XPATH_DEFAULT_NS = "xpathDefaultNamespace".intern();
public static final String ATT_MINVERSION = "minVersion".intern();
public static final String ATT_MAXVERSION = "maxVersion".intern();
+ public static final String ATT_INHERITABLE = "inheritable".intern();
// all possible schema attribute values
public static final String ATTVAL_TWOPOUNDANY = "##any";
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java?rev=814163&r1=814162&r2=814163&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java Sat Sep 12 13:43:19 2009
@@ -80,6 +80,7 @@
import org.apache.xerces.xs.ElementPSVI;
import org.apache.xerces.xs.ShortList;
import org.apache.xerces.xs.XSAssert;
+import org.apache.xerces.xs.XSAttributeDeclaration;
import org.apache.xerces.xs.XSComplexTypeDefinition;
import org.apache.xerces.xs.XSConstants;
import org.apache.xerces.xs.XSMultiValueFacet;
@@ -384,8 +385,14 @@
private XMLLocator fLocator;
// assertion processor object reference
- private XMLAssertHandler assertionProcessor = null;
-
+ private XMLAssertHandler fAssertionProcessor = null;
+
+ // a Vector list storing inheritable attributes
+ private Vector fInheritableAttrList = new Vector();
+
+ // a Stack, storing inheritable attribute count for the elements
+ private IntStack fInhrAttrCountStack = new IntStack();
+
/**
* A wrapper of the standard error reporter. We'll store all schema errors
* in this wrapper object, so that we can get all errors (error codes) of
@@ -808,12 +815,12 @@
if (assertProcessorProp == null || assertProcessorProp.equals("")) {
// if assertion processor is not specified via a system
// property, default to the Psychopath processor
- assertionProcessor = new XMLAssertPsychopathImpl();
+ fAssertionProcessor = new XMLAssertPsychopathImpl();
} else {
try {
Class assertClass = ClassLoader.getSystemClassLoader()
.loadClass(assertProcessorProp);
- assertionProcessor = (XMLAssertHandler) assertClass.newInstance();
+ fAssertionProcessor = (XMLAssertHandler) assertClass.newInstance();
} catch (ClassNotFoundException ex) {
throw new XNIException(ex.getMessage(), ex);
} catch (InstantiationException ex) {
@@ -822,7 +829,7 @@
throw new XNIException(ex.getMessage(), ex);
}
}
- assertionProcessor.setProperty("http://apache.org/xml/properties/assert/validator", this);
+ fAssertionProcessor.setProperty("http://apache.org/xml/properties/assert/validator", this);
}
@@ -1790,8 +1797,8 @@
}
// invoke the assertions processor method
- if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1 && assertionProcessor != null) {
- assertionProcessor.characters(text);
+ if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1 && fAssertionProcessor != null) {
+ fAssertionProcessor.characters(text);
}
return text;
@@ -1954,7 +1961,7 @@
storeLocations(sLocation, nsLocation);
// if we are in the content of "skip", then just skip this element
- // REVISIT: is this the correct behaviour for ID constraints? -NG
+ // REVISIT: is this the correct behavior for ID constraints? -NG
if (fSkipValidationDepth >= 0) {
fElementDepth++;
if (fAugPSVI)
@@ -2105,20 +2112,24 @@
processRootTypeQName(fRootTypeQName);
}
}
-
+
//process type alternatives
if (fTypeAlternativesChecking && fCurrentElemDecl != null) {
boolean typeSelected = false;
XSTypeAlternativeImpl[] alternatives = fCurrentElemDecl.getTypeAlternatives();
- if (alternatives != null) {
+ if (alternatives != null) {
+ // construct a list of attributes, needed for CTA processing.
+ // This method call, adds inherited attributes as well, to the list
+ // of attributes.
+ XMLAttributes ctaAttributes = getAttributesForCTA(attributes);
+
for (int i = 0; i < alternatives.length; i++) {
Test test = alternatives[i].getTest();
- if (test != null && test.evaluateTest(element, attributes)) {
+ if (test != null && test.evaluateTest(element, ctaAttributes)) {
fCurrentType = alternatives[i].getTypeDefinition();
typeSelected = true;
break;
}
-
}
//if a type is not selected try to assign the default type
if (!typeSelected) {
@@ -2127,7 +2138,7 @@
fCurrentType = defType.getTypeDefinition();
}
}
- }
+ }
}
// if there was no processor stipulated type
@@ -2146,7 +2157,7 @@
fCurrentType = fCurrentElemDecl.fType;
}
}
-
+
// check if we should be ignoring xsi:type on this element
if (fElementDepth == fIgnoreXSITypeDepth && fCurrentElemDecl == null) {
fIgnoreXSITypeDepth++;
@@ -2347,12 +2358,25 @@
fValueStoreCache.initValueStoresFor(fCurrentElemDecl, this);
}
}
+
processAttributes(element, attributes, attrGrp);
// add default attributes
if (attrGrp != null) {
addDefaultAttributes(element, attributes, attrGrp);
}
+
+ // find attributes among the attributes of this element, which are
+ // declared inheritable. The inheritable attributes will later be used
+ // for processing CTA.
+ if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+ fInhrAttrCountStack.push(fInheritableAttrList.size());
+ if (attributes.getLength() > 0) {
+ // get inheritable attributes, only if an element has a complex type (i.e, has
+ // > 0 attributes.
+ saveInheritableAttributes(attributes);
+ }
+ }
// call all active identity constraints
int count = fMatcherStack.getMatcherCount();
@@ -2363,7 +2387,7 @@
if (fAugPSVI) {
augs = getEmptyAugs(augs);
-
+
// PSVI: add validation context
fCurrentPSVI.fValidationContext = fValidationRoot;
// PSVI: add element declaration
@@ -2384,9 +2408,12 @@
return augs;
} // handleStartElement(QName,XMLAttributes,boolean)
+
/** Add assertions for processing */
- private void addAssertsForEvaluation(QName element, XMLAttributes attributes) {
+ private void addAssertsForEvaluation(QName element,
+ XMLAttributes attributes) {
+
XSTypeDefinition typeDef = fCurrentPSVI.getTypeDefinition();
Object assertObject = null;
@@ -2424,7 +2451,7 @@
if (assertions.size() > 0) {
assertObject = assertions;
// instantiate the assertions processor
- if (assertionProcessor == null) {
+ if (fAssertionProcessor == null) {
initializeAssertProcessor();
}
}
@@ -2437,7 +2464,7 @@
if (facet.getFacetKind() == XSSimpleTypeDefinition.FACET_ASSERT) {
assertObject = facet.getAsserts();
// instantiate the assertions processor
- if (assertionProcessor == null) {
+ if (fAssertionProcessor == null) {
initializeAssertProcessor();
}
break;
@@ -2446,13 +2473,14 @@
}
// invoke the assertions processor method
- if (assertionProcessor != null) {
+ if (fAssertionProcessor != null) {
// construct the augmentations object, for assertions
AugmentationsImpl assertAugs = new AugmentationsImpl();
assertAugs.putItem("ASSERT", assertObject);
- assertionProcessor.startElement(element, attributes, assertAugs);
+ fAssertionProcessor.startElement(element, attributes, assertAugs);
}
}
+
/**
* Handle end element. If there is not text content, and there is a
@@ -2464,6 +2492,15 @@
if (DEBUG) {
System.out.println("==>handleEndElement:" + element);
}
+
+ // inheritable attribute processing
+
+ // modify the Vector list, 'fInheritableAttrList' and pop the stack,
+ // 'fInhrAttrCountStack', to reflect inheritable attributes processing.
+ if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+ fInheritableAttrList.setSize(fInhrAttrCountStack.pop());
+ }
+
// if we are skipping, return
if (fSkipValidationDepth >= 0) {
// but if this is the top element that we are skipping,
@@ -2575,7 +2612,7 @@
}
// invoke the assertions processor method
- if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1 && assertionProcessor != null) {
+ if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1 && fAssertionProcessor != null) {
try {
// create the ElementPSVImpl object, for assertions
ElementPSVImpl assertPSVI = new ElementPSVImpl();
@@ -2588,7 +2625,7 @@
// store assertPSVI into the augmentations
AugmentationsImpl assertAugs = new AugmentationsImpl();
assertAugs.putItem(Constants.ELEMENT_PSVI, assertPSVI);
- assertionProcessor.endElement(element, assertAugs);
+ fAssertionProcessor.endElement(element, assertAugs);
} catch (Exception ex) {
throw new XNIException(ex.getMessage(), ex);
}
@@ -2978,7 +3015,7 @@
if (DEBUG) {
System.out.println("==>processAttributes: " + attributes.getLength());
}
-
+
// whether we have seen a Wildcard ID.
String wildcardIDName = null;
@@ -3001,7 +3038,10 @@
}
// Element Locally Valid (Complex Type)
- // 3 For each attribute information item in the element information item's [attributes] excepting those whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is one of type, nil, schemaLocation or noNamespaceSchemaLocation, the appropriate case among the following must be true:
+ // 3 For each attribute information item in the element information item's [attributes] excepting
+ // those whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose
+ // [local name] is one of type, nil, schemaLocation or noNamespaceSchemaLocation, the appropriate
+ // case among the following must be true:
// get the corresponding attribute decl
for (int index = 0; index < attCount; index++) {
@@ -3122,14 +3162,14 @@
}
// if can't find
- if (currDecl == null) {
+ if (currDecl == null) {
// if strict, report error
if (attrWildcard.fProcessContents == XSWildcardDecl.PC_STRICT) {
reportSchemaError(
- "cvc-complex-type.3.2.2",
- new Object[] { element.rawname, fTempQName.rawname });
- }
-
+ "cvc-complex-type.3.2.2",
+ new Object[] { element.rawname, fTempQName.rawname });
+ }
+
// then continue to the next attribute
continue;
} else {
@@ -4743,4 +4783,158 @@
}
}
+
+ /*
+ * A class representing an inheritable attribute. This is used as an
+ * intermediate storage, for inheritable attribute information.
+ */
+ class InheritableAttribute {
+ String localName = "";
+ String prefix = "";
+ String uri = "";
+ String value = "";
+ String type = "";
+
+ public InheritableAttribute(String localName,
+ String prefix,
+ String uri,
+ String value,
+ String type) {
+ this.localName = localName;
+ this.prefix = prefix;
+ this.uri = uri;
+ this.value = value;
+ this.type = type;
+ }
+
+ public String getLocalName() {
+ return localName;
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public String getType() {
+ return type;
+ }
+ } // class, InheritableAttribute
+
+
+ /*
+ * For the current element being handled by the Schema validator, find
+ * all inheritable attributes for this element. Save these inheritable
+ * attributes, in a global Vector list.
+ */
+ private void saveInheritableAttributes(XMLAttributes attributes) {
+
+ if (fCurrentElemDecl != null && fCurrentElemDecl.fType instanceof XSComplexTypeDecl) {
+ XSComplexTypeDecl currentComplexType = (XSComplexTypeDecl) fCurrentElemDecl.fType;
+ XSObjectListImpl attributeUses = (XSObjectListImpl) currentComplexType.getAttributeUses();
+
+ // iterate all the attributes, being passed to this method
+ for (int attrIndx = 0; attrIndx < attributes.getLength(); attrIndx++) {
+ String attrName = attributes.getLocalName(attrIndx);
+ String attrUri = attributes.getURI(attrIndx);
+ // iterate all the attributes declarations, of the complex type,
+ // for the current element.
+ for (int attrUsesIndx = 0; attrUsesIndx < attributeUses.getLength(); attrUsesIndx++) {
+ XSAttributeUseImpl attrUseImpl = (XSAttributeUseImpl) attributeUses.get(attrUsesIndx);
+ XSAttributeDeclaration attrDecl = attrUseImpl.getAttrDeclaration();
+ // the current element, has an inheritable attribute
+ if (attrName.equals(attrDecl.getName()) &&
+ uriEqual(attrUri, attrDecl.getNamespace()) &&
+ attrUseImpl.getInheritable()) {
+ InheritableAttribute inhrAttr = new InheritableAttribute(
+ attributes.getLocalName(attrIndx),
+ attributes.getPrefix(attrIndx),
+ attributes.getURI(attrIndx),
+ attributes.getValue(attrIndx),
+ attributes.getType(attrIndx)) ;
+ fInheritableAttrList.add(inhrAttr);
+ }
+ }
+ }
+ }
+
+ } // saveInheritableAttributes
+
+
+ // construct a list of attributes, needed for CTA processing. This includes
+ // inherited attributes as well.
+ private XMLAttributes getAttributesForCTA(XMLAttributes attributes) {
+
+ // copy attributes from the original list of attributes
+ XMLAttributes ctaAttributes = new XMLAttributesImpl();
+ for (int attrIndx = 0; attrIndx < attributes.getLength(); attrIndx++) {
+ QName qName = new QName();
+ attributes.getName(attrIndx, qName);
+ ctaAttributes.addAttribute(qName, attributes.getType(attrIndx),
+ attributes.getValue(attrIndx));
+ }
+
+ // traverse up the XML tree, to find inherited attributes.
+ // attributes only from the nearest ancestor, are added to the list
+ for (int elemIndx = fInheritableAttrList.size() - 1; elemIndx > -1; elemIndx--) {
+ InheritableAttribute inhAttr = (InheritableAttribute) fInheritableAttrList.elementAt(elemIndx);
+ // if an inheritable attribute doesn't already exist, in the attributes
+ // list, add it to the list.
+ if (!attributeExists(ctaAttributes, inhAttr)) {
+ String rawName = "".equals(inhAttr.getPrefix()) ? inhAttr.getLocalName() :
+ inhAttr.getPrefix() + ":" + inhAttr.getLocalName();
+ fTempQName.setValues(inhAttr.getPrefix(), inhAttr.getLocalName(), rawName, inhAttr.getUri());
+ ctaAttributes.addAttribute(fTempQName, inhAttr.getType(), inhAttr.getValue());
+ }
+ }
+
+ return ctaAttributes;
+
+ } // getAttributesForCTA
+
+
+ /*
+ * Check if an inheritable attribute, exists in the attributes list
+ */
+ private boolean attributeExists(XMLAttributes attributes, InheritableAttribute inhAttr) {
+ boolean attrExists = false;
+
+ for (int attrIndx = 0; attrIndx < attributes.getLength(); attrIndx++) {
+ String localName = attributes.getLocalName(attrIndx);
+ String uri = attributes.getURI(attrIndx);
+ if (localName.equals(inhAttr.getLocalName()) &&
+ uriEqual(uri, inhAttr.getUri())) {
+ attrExists = true;
+ break;
+ }
+ }
+
+ return attrExists;
+ } // attributeExists
+
+
+ /*
+ * Check if two URI values are equal
+ */
+ private boolean uriEqual(String a, String b) {
+ boolean nsEqual = false;
+
+ if ((a != null && b == null) ||
+ (a == null && b != null)) {
+ nsEqual = false;
+ } else if ((a == null && b == null) ||
+ a.equals(b)) {
+ nsEqual = true;
+ }
+
+ return nsEqual;
+ } // uriEqual
+
} // class SchemaValidator
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeDecl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeDecl.java?rev=814163&r1=814162&r2=814163&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeDecl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeDecl.java Sat Sep 12 13:43:19 2009
@@ -65,11 +65,13 @@
// The namespace schema information item corresponding to the target namespace
// of the attribute declaration, if it is globally declared; or null otherwise.
private XSNamespaceItem fNamespaceItem = null;
+
+ boolean fInheritable = false;
public void setValues(String name, String targetNamespace,
XSSimpleType simpleType, short constraintType, short scope,
ValidatedInfo valInfo, XSComplexTypeDecl enclosingCT,
- XSObjectList annotations) {
+ XSObjectList annotations, boolean inheritable) {
fName = name;
fTargetNamespace = targetNamespace;
fType = simpleType;
@@ -78,6 +80,7 @@
fDefault = valInfo;
fEnclosingCT = enclosingCT;
fAnnotations = annotations;
+ fInheritable = inheritable;
}
public void reset(){
@@ -88,6 +91,7 @@
fScope = XSConstants.SCOPE_ABSENT;
fDefault = null;
fAnnotations = null;
+ fInheritable = false;
}
/**
@@ -205,5 +209,9 @@
null :
fDefault.itemValueTypes;
}
+
+ public boolean getInheritable() {
+ return fInheritable;
+ }
} // class XSAttributeDecl
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeUseImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeUseImpl.java?rev=814163&r1=814162&r2=814163&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeUseImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeUseImpl.java Sat Sep 12 13:43:19 2009
@@ -48,12 +48,15 @@
// optional annotation
public XSObjectList fAnnotations = null;
+ public boolean fInheritable = false;
+
public void reset(){
fDefault = null;
fAttrDecl = null;
fUse = SchemaSymbols.USE_OPTIONAL;
fConstraintType = XSConstants.VC_NONE;
fAnnotations = null;
+ fInheritable = false;
}
/**
@@ -147,4 +150,8 @@
return (fAnnotations != null) ? fAnnotations : XSObjectListImpl.EMPTY_LIST;
}
+ public boolean getInheritable() {
+ return fInheritable;
+ }
+
} // class XSAttributeUseImpl
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java?rev=814163&r1=814162&r2=814163&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java Sat Sep 12 13:43:19 2009
@@ -50,7 +50,7 @@
* - reports an error for invalid element (invalid namespace, invalid name)
* - reports an error for invalid attribute (invalid namespace, invalid name)
* - reports an error for invalid attribute value
- * - return compiled values for attriute values
+ * - return compiled values for attribute values
* - provide default value for missing optional attributes
* - provide default value for incorrect attribute values
*
@@ -133,7 +133,8 @@
public static final int ATTIDX_MODE = ATTIDX_COUNT++;
public static final int ATTIDX_NOTNAMESPACE = ATTIDX_COUNT++;
public static final int ATTIDX_NOTQNAME = ATTIDX_COUNT++;
- public static final int ATTIDX_XPATHDEFAULTNS = ATTIDX_COUNT++;
+ public static final int ATTIDX_XPATHDEFAULTNS = ATTIDX_COUNT++;
+ public static final int ATTIDX_INHERITABLE = ATTIDX_COUNT++;
private static final XIntPool fXIntPool = new XIntPool();
// constants to return
@@ -168,7 +169,7 @@
// used to store the map from element name to attribute list
// for 15 global elements
private static final Hashtable fEleAttrs11MapG = new Hashtable(31);
- // for 47 local elememnts
+ // for 47 local elements
private static final Hashtable fEleAttrs11MapL = new Hashtable(97);
// used to initialize fEleAttrsMap
@@ -300,6 +301,7 @@
int ATT_NOTNAMESPACE_N = attCount++;
int ATT_NOTQNAME_N = attCount++;
int ATT_TEST_XPATH_R = attCount++;
+ int ATT_INHERITABLE_N = attCount++;
// step 3: store all these attributes in an array
OneAttr[] allAttrs = new OneAttr[attCount];
@@ -537,7 +539,10 @@
DT_XPATH1,
ATTIDX_XPATH,
null);
-
+ allAttrs[ATT_INHERITABLE_N] = new OneAttr(SchemaSymbols.ATT_INHERITABLE,
+ DT_BOOLEAN,
+ ATTIDX_INHERITABLE,
+ Boolean.FALSE);
// step 4: for each element, make a list of possible attributes
Container attrList;
@@ -554,8 +559,21 @@
attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
// type = QName
attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
- fEleAttrsMapG.put(SchemaSymbols.ELT_ATTRIBUTE, attrList);
- // XML Schema 1.1 - same list
+ fEleAttrsMapG.put(SchemaSymbols.ELT_ATTRIBUTE, attrList);
+ // XML Schema 1.1
+ attrList = Container.getContainer(6);
+ // default = string
+ attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
+ // fixed = string
+ attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
+ // id = ID
+ attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
+ // name = NCName
+ attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
+ // type = QName
+ attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
+ // inheritable = boolean
+ attrList.put(SchemaSymbols.ATT_INHERITABLE, allAttrs[ATT_INHERITABLE_N]);
fEleAttrs11MapG.put(SchemaSymbols.ELT_ATTRIBUTE, attrList);
// for element "attribute" - local name
@@ -575,7 +593,7 @@
// use = (optional | prohibited | required) : optional
attrList.put(SchemaSymbols.ATT_USE, allAttrs[ATT_USE_D]);
fEleAttrsMapL.put(ATTRIBUTE_N, attrList);
-
+
// for element "attribute" - local ref
attrList = Container.getContainer(5);
// default = string
@@ -588,8 +606,21 @@
attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
// use = (optional | prohibited | required) : optional
attrList.put(SchemaSymbols.ATT_USE, allAttrs[ATT_USE_D]);
- fEleAttrsMapL.put(ATTRIBUTE_R, attrList);
- // XML Schema 1.1 - same list
+ fEleAttrsMapL.put(ATTRIBUTE_R, attrList);
+ // XML Schema 1.1
+ attrList = Container.getContainer(6);
+ // default = string
+ attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
+ // fixed = string
+ attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
+ // id = ID
+ attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
+ // ref = QName
+ attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
+ // use = (optional | prohibited | required) : optional
+ attrList.put(SchemaSymbols.ATT_USE, allAttrs[ATT_USE_D]);
+ // inheritable = boolean
+ attrList.put(SchemaSymbols.ATT_INHERITABLE, allAttrs[ATT_INHERITABLE_N]);
fEleAttrs11MapL.put(ATTRIBUTE_R, attrList);
// for element "element" - global
@@ -1122,7 +1153,7 @@
fEleAttrs11MapG.put(SchemaSymbols.ELT_SCHEMA, attrList);
// for element "attribute" - local name
- attrList = Container.getContainer(8);
+ attrList = Container.getContainer(9);
// default = string
attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
// fixed = string
@@ -1139,6 +1170,8 @@
attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
// use = (optional | prohibited | required) : optional
attrList.put(SchemaSymbols.ATT_USE, allAttrs[ATT_USE_D]);
+ // inheritable = boolean
+ attrList.put(SchemaSymbols.ATT_INHERITABLE, allAttrs[ATT_INHERITABLE_N]);
fEleAttrs11MapL.put(ATTRIBUTE_N, attrList);
// for element "element" - local name
@@ -1261,7 +1294,7 @@
attrList.put(SchemaSymbols.ATT_XPATH_DEFAULT_NS, allAttrs[ATT_DEFAULT_XPATH_NS_N]);
fEleAttrs11MapL.put(SchemaSymbols.ELT_ALTERNATIVE, attrList);
- // for element "assert" - local // mukul
+ // for element "assert" - local
attrList = Container.getContainer(3);
// id = ID
attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
@@ -1270,7 +1303,7 @@
// xpathDefaultNamespace = (anyURI | (##defaultNamespace | ##targetNamespace | ##local))
attrList.put(SchemaSymbols.ATT_XPATH_DEFAULT_NS, allAttrs[ATT_DEFAULT_XPATH_NS_N]);
fEleAttrs11MapL.put(SchemaSymbols.ELT_ASSERT, attrList);
- // for element "assertion" - local // mukul
+ // for element "assertion" - local
fEleAttrs11MapL.put(SchemaSymbols.ELT_ASSERTION, attrList);
// for element "defaultOpenContent" - global
@@ -1319,7 +1352,7 @@
}
/**
- * Check whether the specified element conforms to the attributes restriction
+ * Check whether the specified element conforms to the attributes restriction.
* an array of attribute values is returned. the caller must call
* <code>returnAttrArray</code> to return that array.
*
@@ -1334,7 +1367,7 @@
}
/**
- * Check whether the specified element conforms to the attributes restriction
+ * Check whether the specified element conforms to the attributes restriction.
* an array of attribute values is returned. the caller must call
* <code>returnAttrArray</code> to return that array. This method also takes
* an extra parameter: if the element is "enumeration", whether to make a
@@ -1507,7 +1540,7 @@
if (attrValues[ATTIDX_SUBSGROUP] == null) {
attrValues[ATTIDX_SUBSGROUP] = new Vector();
}
- if (fSchemaHandler.fSchemaVersion==Constants.SCHEMA_VERSION_1_1) {
+ if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
StringTokenizer st = new StringTokenizer(attrVal, " ");
while (st.hasMoreTokens()) {
Object avalue = dv.validate(st.nextToken(), schemaDoc.fValidationContext, null);
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java?rev=814163&r1=814162&r2=814163&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java Sat Sep 12 13:43:19 2009
@@ -49,6 +49,7 @@
* ref = QName
* type = QName
* use = (optional | prohibited | required) : optional
+ * inheritable = boolean
* {any attributes with non-schema namespace . . .}>
* Content: (annotation?, (simpleType?))
* </attribute>
@@ -79,6 +80,7 @@
String nameAtt = (String) attrValues[XSAttributeChecker.ATTIDX_NAME];
QName refAtt = (QName) attrValues[XSAttributeChecker.ATTIDX_REF];
XInt useAtt = (XInt) attrValues[XSAttributeChecker.ATTIDX_USE];
+ Boolean inheritableAtt = (Boolean) attrValues[XSAttributeChecker.ATTIDX_INHERITABLE];
// get 'attribute declaration'
XSAttributeDecl attribute = null;
@@ -101,7 +103,8 @@
if (child != null) {
reportSchemaError("src-attribute.3.2", new Object[]{refAtt.rawname}, child);
- }
+ }
+
// for error reporting
nameAtt = refAtt.localpart;
} else {
@@ -135,7 +138,15 @@
attrUse.fDefault = new ValidatedInfo();
attrUse.fDefault.normalizedValue = defaultAtt;
}
- // Get the annotation associated witht the local attr decl
+
+ if (attrDecl.getAttributeNode(SchemaSymbols.ATT_INHERITABLE) != null) {
+ attrUse.fInheritable = inheritableAtt.booleanValue();
+ }
+ else {
+ attrUse.fInheritable = attribute.getInheritable();
+ }
+
+ // Get the annotation associated with the local attr decl
if (attrDecl.getAttributeNode(SchemaSymbols.ATT_REF) == null) {
attrUse.fAnnotations = attribute.getAnnotations();
} else {
@@ -228,16 +239,17 @@
boolean isGlobal,
XSComplexTypeDecl enclosingCT) {
- String defaultAtt = (String) attrValues[XSAttributeChecker.ATTIDX_DEFAULT];
- String fixedAtt = (String) attrValues[XSAttributeChecker.ATTIDX_FIXED];
- XInt formAtt = (XInt) attrValues[XSAttributeChecker.ATTIDX_FORM];
- String nameAtt = (String) attrValues[XSAttributeChecker.ATTIDX_NAME];
- String targetNsAtt = (String) attrValues[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
- QName typeAtt = (QName) attrValues[XSAttributeChecker.ATTIDX_TYPE];
+ String defaultAtt = (String) attrValues[XSAttributeChecker.ATTIDX_DEFAULT];
+ String fixedAtt = (String) attrValues[XSAttributeChecker.ATTIDX_FIXED];
+ XInt formAtt = (XInt) attrValues[XSAttributeChecker.ATTIDX_FORM];
+ String nameAtt = (String) attrValues[XSAttributeChecker.ATTIDX_NAME];
+ String targetNsAtt = (String) attrValues[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
+ QName typeAtt = (QName) attrValues[XSAttributeChecker.ATTIDX_TYPE];
+ Boolean inheritableAtt = (Boolean) attrValues[XSAttributeChecker.ATTIDX_INHERITABLE];
// Step 1: get declaration information
XSAttributeDecl attribute = null;
- if (fSchemaHandler.fDeclPool !=null) {
+ if (fSchemaHandler.fDeclPool != null) {
attribute = fSchemaHandler.fDeclPool.getAttributeDecl();
} else {
attribute = new XSAttributeDecl();
@@ -335,8 +347,14 @@
} else {
annotations = XSObjectListImpl.EMPTY_LIST;
}
+
+ boolean inheritable = false;
+ if (inheritableAtt != null) {
+ inheritable = inheritableAtt.booleanValue();
+ }
+
attribute.setValues(nameAtt, tnsAtt, attrType, constraintType, scope,
- attDefault, enclCT, annotations);
+ attDefault, enclCT, annotations, inheritable);
// Step 2: register attribute decl to the grammar
if (isGlobal && nameAtt != null)
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/XMLAttributesImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/XMLAttributesImpl.java?rev=814163&r1=814162&r2=814163&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/XMLAttributesImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/XMLAttributesImpl.java Sat Sep 12 13:43:19 2009
@@ -305,6 +305,7 @@
}
fLength--;
} // removeAttributeAt(int)
+
/**
* Sets the name of the attribute at the specified index.
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAttributeDeclaration.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAttributeDeclaration.java?rev=814163&r1=814162&r2=814163&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAttributeDeclaration.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAttributeDeclaration.java Sat Sep 12 13:43:19 2009
@@ -59,8 +59,7 @@
* NOT_SUPPORTED_ERR: Raised if the implementation does not support this
* method.
*/
- public Object getActualVC()
- throws XSException;
+ public Object getActualVC() throws XSException;
/**
* The actual constraint value built-in datatype, e.g.
@@ -76,8 +75,7 @@
* NOT_SUPPORTED_ERR: Raised if the implementation does not support this
* method.
*/
- public short getActualVCType()
- throws XSException;
+ public short getActualVCType() throws XSException;
/**
* In the case the actual constraint value represents a list, i.e. the
@@ -92,8 +90,7 @@
* NOT_SUPPORTED_ERR: Raised if the implementation does not support this
* method.
*/
- public ShortList getItemValueTypes()
- throws XSException;
+ public ShortList getItemValueTypes() throws XSException;
/**
* An annotation if it exists, otherwise <code>null</code>.
@@ -104,5 +101,10 @@
/**
* A sequence of [annotations] or an empty <code>XSObjectList</code>.
*/
- public XSObjectList getAnnotations();
+ public XSObjectList getAnnotations();
+
+ /**
+ * Inheritable flag for the attribute.
+ */
+ public boolean getInheritable();
}
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAttributeUse.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAttributeUse.java?rev=814163&r1=814162&r2=814163&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAttributeUse.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAttributeUse.java Sat Sep 12 13:43:19 2009
@@ -92,5 +92,7 @@
/**
* A sequence of [annotations] or an empty <code>XSObjectList</code>.
*/
- public XSObjectList getAnnotations();
+ public XSObjectList getAnnotations();
+
+ public boolean getInheritable();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org