Author: knoaman
Date: Thu Apr 15 15:31:22 2010
New Revision: 934452
URL: http://svn.apache.org/viewvc?rev=934452&view=rev
Log:
Support multiple attributes of type ID - patch by Kun Xu (with a slight
modification)
Jira bug: https://issues.apache.org/jira/browse/XERCESJ-1440
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java?rev=934452&r1=934451&r2=934452&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java
Thu Apr 15 15:31:22 2010
@@ -91,6 +91,33 @@ public class XSAttributeGroupDecl implem
return null;
}
+ public String addAttributeUse(XSAttributeUseImpl attrUse, boolean
allowMultipleIds) {
+
+ // if this attribute use is prohibited, then don't check whether it's
+ // of type ID
+ //
+ // XML Schema 1.1 allows multiple attributes of type ID, so no need to
set
+ // fIDAttrName
+ if (attrUse.fUse != SchemaSymbols.USE_PROHIBITED && !allowMultipleIds)
{
+ if (attrUse.fAttrDecl.fType.isIDType()) {
+ // if there is already an attribute use of type ID,
+ // return its name (and don't add it to the list, to avoid
+ // interruption to instance validation.
+ if (fIDAttrName == null)
+ fIDAttrName = attrUse.fAttrDecl.fName;
+ else
+ return fIDAttrName;
+ }
+ }
+
+ if (fAttrUseNum == fAttributeUses.length) {
+ fAttributeUses = resize(fAttributeUses, fAttrUseNum*2);
+ }
+ fAttributeUses[fAttrUseNum++] = attrUse;
+
+ return null;
+ }
+
public void replaceAttributeUse(XSAttributeUse oldUse, XSAttributeUseImpl
newUse) {
for (int i=0; i<fAttrUseNum; i++) {
if (fAttributeUses[i] == oldUse) {
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java?rev=934452&r1=934451&r2=934452&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
Thu Apr 15 15:31:22 2010
@@ -795,6 +795,8 @@ abstract class XSDAbstractTraverser {
enclosingParent);
if (tempAttrUse == null) continue;
if (tempAttrUse.fUse == SchemaSymbols.USE_PROHIBITED) {
+ // Revisit: not passing schema version information, since
we do not check for
+ // attributes of type id when the attribute use
is prohibited.
attrGrp.addAttributeUse(tempAttrUse);
continue;
}
@@ -802,9 +804,9 @@ abstract class XSDAbstractTraverser {
tempAttrUse.fAttrDecl.getNamespace(),
tempAttrUse.fAttrDecl.getName());
if (otherUse==null) {
- String idName = attrGrp.addAttributeUse(tempAttrUse);
- // Only applies to XML Schema 1.0
- if (fSchemaHandler.fSchemaVersion <
Constants.SCHEMA_VERSION_1_1 && idName != null) {
+ String idName = attrGrp.addAttributeUse(tempAttrUse,
fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1);
+ // For XML Schema 1.1, we return null
+ if (idName != null) {
String code = (enclosingParent instanceof
XSAttributeGroupDecl) ? "ag-props-correct.3" : "ct-props-correct.5";
String name = enclosingParent.getName();
reportSchemaError(code, new Object[]{name,
tempAttrUse.fAttrDecl.getName(), idName}, child);
@@ -827,6 +829,8 @@ abstract class XSDAbstractTraverser {
for (int i=0; i<attrCount; i++) {
oneAttrUse = (XSAttributeUseImpl)attrUseS.item(i);
if (oneAttrUse.fUse == SchemaSymbols.USE_PROHIBITED) {
+ // Revisit: not passing schema version information,
since we do not check for
+ // attributes of type id when the attribute
use is prohibited.
attrGrp.addAttributeUse(oneAttrUse);
continue;
}
@@ -834,9 +838,9 @@ abstract class XSDAbstractTraverser {
oneAttrUse.fAttrDecl.getNamespace(),
oneAttrUse.fAttrDecl.getName());
if (otherUse==null) {
- String idName = attrGrp.addAttributeUse(oneAttrUse);
- // Only applies to XML Schema 1.0
- if (fSchemaHandler.fSchemaVersion <
Constants.SCHEMA_VERSION_1_1 && idName != null) {
+ String idName = attrGrp.addAttributeUse(oneAttrUse,
fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1);
+ // For XML Schema 1.1, we return null
+ if (idName != null) {
String code = (enclosingParent instanceof
XSAttributeGroupDecl) ? "ag-props-correct.3" : "ct-props-correct.5";
String name = enclosingParent.getName();
reportSchemaError(code, new Object[]{name,
oneAttrUse.fAttrDecl.getName(), idName}, child);
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java?rev=934452&r1=934451&r2=934452&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
Thu Apr 15 15:31:22 2010
@@ -1317,9 +1317,8 @@ class XSDComplexTypeTraverser extends X
oneAttrUse.fAttrDecl.getName());
if (existingAttrUse == null) {
- String idName = toAttrGrp.addAttributeUse(oneAttrUse);
- // Only applies to XML Schema 1.0
- if (fSchemaHandler.fSchemaVersion <
Constants.SCHEMA_VERSION_1_1 && idName != null) {
+ String idName = toAttrGrp.addAttributeUse(oneAttrUse,
fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1);
+ if (idName != null) {
throw new ComplexTypeRecoverableError("ct-props-correct.5",
new Object[]{typeName, idName,
oneAttrUse.fAttrDecl.getName()},
elem);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]