001: package net.sf.saxon.type;
002:
003: /**
004: * A complex type as defined in XML Schema: either a user-defined complex type, or xs:anyType.
005: * In the non-schema-aware version of the Saxon product, the only complex type encountered is xs:anyType.
006: */
007:
008: public interface ComplexType extends SchemaType {
009:
010: /**
011: * Test whether this complex type has been marked as abstract.
012: * @return true if this complex type is abstract.
013: **/
014:
015: public boolean isAbstract();
016:
017: /**
018: * Test whether this complex type has complex content
019: * @return true if this complex type has a complex content model, false if it has a simple content model
020: */
021:
022: public boolean isComplexContent();
023:
024: /**
025: * Test whether this complexType has simple content
026: * @return true if this complex type has a simple content model, false if it has a complex content model
027: */
028:
029: public boolean isSimpleContent();
030:
031: /**
032: * Test whether this complex type has "all" content, that is, a content model
033: * using an xs:all compositor
034: */
035:
036: public boolean isAllContent();
037:
038: /**
039: * Get the simple content type
040: * @return For a complex type with simple content, returns the simple type of the content.
041: * Otherwise, returns null.
042: */
043:
044: public SimpleType getSimpleContentType();
045:
046: /**
047: * Test whether this complex type is derived by restriction
048: * @return true if this complex type is derived by restriction
049: */
050:
051: public boolean isRestricted();
052:
053: /**
054: * Test whether the content model of this complex type is empty
055: * @return true if the content model is defined as empty
056: */
057:
058: public boolean isEmptyContent();
059:
060: /**
061: * Test whether the content model of this complex type allows empty content
062: * @return true if empty content is valid
063: */
064:
065: public boolean isEmptiable() throws SchemaException,
066: ValidationException;
067:
068: /**
069: * Test whether this complex type allows mixed content
070: * @return true if mixed content is allowed
071: */
072:
073: public boolean isMixedContent();
074:
075: /**
076: * Test whether this complex type subsumes another complex type. The algorithm
077: * used is as published by Thompson and Tobin, XML Europe 2003.
078: * @param sub the other type (the type that is derived by restriction, validly or otherwise)
079: * @return null indicating that this type does indeed subsume the other; or a string indicating
080: * why it doesn't.
081: */
082:
083: public String subsumes(ComplexType sub) throws ValidationException;
084:
085: /**
086: * Find an element particle within this complex type definition having a given element name
087: * (identified by fingerprint), and return the schema type associated with that element particle.
088: * If there is no such particle, return null. If the fingerprint matches an element wildcard,
089: * return the type of the global element declaration with the given name if one exists, or AnyType
090: * if none exists and lax validation is permitted by the wildcard.
091: * @param fingerprint Identifies the name of the child element within this content model
092: */
093:
094: public SchemaType getElementParticleType(int fingerprint)
095: throws SchemaException, ValidationException;
096:
097: /**
098: * Find an element particle within this complex type definition having a given element name
099: * (identified by fingerprint), and return the cardinality associated with that element particle,
100: * that is, the number of times the element can occur within this complex type. The value is one of
101: * {@link net.sf.saxon.expr.StaticProperty#EXACTLY_ONE}, {@link net.sf.saxon.expr.StaticProperty#ALLOWS_ZERO_OR_ONE},
102: * {@link net.sf.saxon.expr.StaticProperty#ALLOWS_ZERO_OR_MORE}, {@link net.sf.saxon.expr.StaticProperty#ALLOWS_ONE_OR_MORE},
103: * If there is no such particle, return zero.
104: * @param fingerprint Identifies the name of the child element within this content model
105: */
106:
107: public int getElementParticleCardinality(int fingerprint)
108: throws SchemaException, ValidationException;
109:
110: /**
111: * Find an attribute use within this complex type definition having a given attribute name
112: * (identified by fingerprint), and return the schema type associated with that attribute.
113: * If there is no such attribute use, return null. If the fingerprint matches an attribute wildcard,
114: * return the type of the global attribute declaration with the given name if one exists, or AnySimpleType
115: * if none exists and lax validation is permitted by the wildcard.
116: * <p>
117: * If there are types derived from this type by extension, search those too.
118: * @param fingerprint Identifies the name of the child element within this content model
119: */
120:
121: public SchemaType getAttributeUseType(int fingerprint)
122: throws SchemaException, ValidationException;
123:
124: }
125:
126: //
127: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
128: // you may not use this file except in compliance with the License. You may obtain a copy of the
129: // License at http://www.mozilla.org/MPL/
130: //
131: // Software distributed under the License is distributed on an "AS IS" basis,
132: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
133: // See the License for the specific language governing rights and limitations under the License.
134: //
135: // The Original Code is: all this file.
136: //
137: // The Initial Developer of the Original Code is Saxonica Limited
138: //
139: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
140: //
141: // Contributor(s): none
142: //
|