/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* The XML representation for an attribute group declaration
* schema component is a global <attributeGroup> element information item
*
* @xerces.internal
*
* @author Sandy Gao, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
* @version $Id: XSAttributeGroupDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
// name of the attribute group
// target namespace of the attribute group
// number of attribute uses included by this attribute group
// attribute uses included by this attribute group
// attribute wildcard included by this attribute group
// whether there is an attribute use whose type is or is derived from ID.
// optional annotation
// The namespace schema information item corresponding to the target namespace
// of the attribute group definition, if it is globally declared; or null otherwise.
// 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;
// otherwise, return null
// if this attribute use is prohibited, then don't check whether it's
// of type ID
// 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)
else
return fIDAttrName;
}
}
}
return null;
}
for (int i=0; i<fAttrUseNum; i++) {
if (fAttributeUses[i] == oldUse) {
fAttributeUses[i] = newUse;
}
}
}
for (int i=0; i<fAttrUseNum; i++) {
return fAttributeUses[i];
}
return null;
}
for (int i=0; i<fAttrUseNum; i++) {
return fAttributeUses[i];
}
return null;
}
public void removeProhibitedAttrs() {
if (fAttrUseNum == 0) return;
// Remove all prohibited attributes.
int count = 0;
for (int i = 0; i < fAttrUseNum; i++) {
}
}
fAttrUseNum = count;
// Do not remove attributes that have the same name as the prohibited
// ones, because they are specified at the same level. Prohibited
// attributes are only to remove attributes from the base type in a
// restriction.
// int newCount = 0;
// if (pCount > 0) {
// OUTER: for (int i = 0; i < fAttrUseNum; i++) {
// if (fAttributeUses[i].fUse == SchemaSymbols.USE_PROHIBITED)
// continue;
// for (int j = 1; j <= pCount; j++) {
// if (fAttributeUses[i].fAttrDecl.fName == pUses[fAttrUseNum-pCount].fAttrDecl.fName &&
// fAttributeUses[i].fAttrDecl.fTargetNamespace == pUses[fAttrUseNum-pCount].fAttrDecl.fTargetNamespace) {
// continue OUTER;
// }
// }
// pUses[newCount++] = fAttributeUses[i];
// }
// fAttributeUses = pUses;
// fAttrUseNum = newCount;
// }
}
/**
* Check that the attributes in this group validly restrict those from a base group.
* If an error is found, an Object[] is returned. This contains the arguments for the error message
* describing the error. The last element in the array (at index arr.length - 1) is the the error code.
* Returns null if there is no error.
*
* REVISIT: is there a better way of returning the appropriate information for the error?
*
* @param typeName the name of the type containing this attribute group, used for error reporting purposes
* @param baseGroup the XSAttributeGroupDecl that is the base we are checking against
*/
for (int i=0; i<fAttrUseNum; i++) {
attrUse = fAttributeUses[i];
// Look for a match in the base
baseAttrUse = (XSAttributeUseImpl)baseGroup.getAttributeUse(attrDecl.fTargetNamespace,attrDecl.fName);
if (baseAttrUse != null) {
//
// derivation-ok-restriction. Constraint 2.1.1
//
attrUse.fUse == SchemaSymbols.USE_OPTIONAL ? SchemaSymbols.ATTVAL_OPTIONAL : SchemaSymbols.ATTVAL_PROHIBITED,
"derivation-ok-restriction.2.1.1"};
return errorArgs;
}
// if this attribute is prohibited in the derived type, don't
// need to check any of the following constraints.
continue;
}
//
// derivation-ok-restriction. Constraint 2.1.1
//
return errorArgs;
}
//
// derivation-ok-restriction. Constraint 2.1.3
//
"derivation-ok-restriction.2.1.3.a"};
return errorArgs;
} else {
// check the values are the same.
return errorArgs;
}
}
}
} else {
// No matching attribute in base - there should be a matching wildcard
//
// derivation-ok-restriction. Constraint 2.2
//
"derivation-ok-restriction.2.2.a"};
return errorArgs;
}
"derivation-ok-restriction.2.2.b"};
return errorArgs;
}
}
}
//
// Check that any REQUIRED attributes in the base have matching attributes
// in this group
// derivation-ok-restriction. Constraint 3
//
// Look for a match in this group
"derivation-ok-restriction.3"};
return errorArgs;
}
}
}
// Now, check wildcards
//
// derivation-ok-restriction. Constraint 4
//
if (fAttributeWC != null) {
return errorArgs;
}
return errorArgs;
}
"derivation-ok-restriction.4.3"};
return errorArgs;
}
}
return null;
}
return newArray;
}
// reset the attribute group declaration
public void reset(){
// reset attribute uses
for (int i=0;i<fAttrUseNum;i++) {
fAttributeUses[i] = null;
}
fAttrUseNum = 0;
fAttributeWC = null;
fAnnotations = null;
fIDAttrName = null;
}
/**
* Get the type of the object, i.e ELEMENT_DECLARATION.
*/
public short getType() {
return XSConstants.ATTRIBUTE_GROUP;
}
/**
* The <code>name</code> of this <code>XSObject</code> depending on the
* <code>XSObject</code> type.
*/
return fName;
}
/**
* The namespace URI of this node, or <code>null</code> if it is
* unspecified. defines how a namespace URI is attached to schema
* components.
*/
return fTargetNamespace;
}
/**
* {attribute uses} A set of attribute uses.
*/
}
return fAttrUses;
}
/**
* {attribute wildcard} Optional. A wildcard.
*/
return fAttributeWC;
}
/**
* Optional. Annotation.
*/
}
/**
* Optional. Annotations.
*/
}
/**
* @see org.apache.xerces.xs.XSObject#getNamespaceItem()
*/
return fNamespaceItem;
}
}
} // class XSAttributeGroupDecl