Package com.ctc.wstx.dtd
Class DTDElement
java.lang.Object
com.ctc.wstx.dtd.DTDElement
Class that contains element definitions from DTD.
Notes about thread-safety: this class is not thread-safe, since it does not have to be, in general case. That is, the only instances that can be shared are external subset instances, and those are used in read-only manner (with the exception of temporary arrays constructed on-demand).
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int
(package private) boolean
Flag set to true if there are any attributes that have either basic default value, or #FIXED default value.(package private) boolean
(package private) HashMap
<PrefixedName, DTDAttribute> (package private) DTDAttribute
Id attribute instance, if one already declared for this element; can only have up to one such attribute per element.(package private) final Location
Location of the (real) definition of the element; may be null for placeholder elements created to hold ATTLIST definitions(package private) final PrefixedName
(package private) DTDAttribute
Notation attribute instance, if one already declared for this element; can only have up to one such attribute per element.(package private) final boolean
True if the DTD was parsed (and is to be used) in namespace-aware mode.(package private) HashMap
<String, DTDAttribute> Set of namespace declarations with default values, if any (regular ns pseudo-attr declarations are just ignored)(package private) ArrayList
<DTDAttribute> Ordered list of attributes that have 'special' properties (attribute is required, has a default value [regular or fixed]); these attributes have to be specifically checked after actual values have been resolved.(package private) boolean
Flag that is set to true if there is at least one attribute that has type that requires normalization and/or validation; that is, is of some other type than CDATA.(package private) StructValidator
Base validator object for validating content model of this element; may be null for some simple content models (ANY, EMPTY).(package private) final boolean
True if the DTD was parsed in xml1.1 compliant mode (referenced to from an xml 1.1 document). -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
DTDElement
(Location loc, PrefixedName name, StructValidator val, int allowedContent, boolean nsAware, boolean xml11) -
Method Summary
Modifier and TypeMethodDescriptionaddAttribute
(InputProblemReporter rep, PrefixedName attrName, int valueType, DefaultAttrValue defValue, WordResolver enumValues, boolean fullyValidate) Method called by DTD parser when it has read information about an attribute that belong to this elementaddNsDefault
(InputProblemReporter rep, PrefixedName attrName, int valueType, DefaultAttrValue defValue, boolean fullyValidate) Method called to add a definition of a namespace-declaration pseudo-attribute with a default value.boolean
static DTDElement
createDefined
(ReaderConfig cfg, Location loc, PrefixedName name, StructValidator val, int allowedContent) Method called to create an actual element definition, matching an ELEMENT directive in a DTD subset.static DTDElement
createPlaceholder
(ReaderConfig cfg, Location loc, PrefixedName name) Method called to create a "placeholder" element definition, needed to contain attribute definitions.define
(Location loc, StructValidator val, int allowedContent) Method called on placeholder element, to create a real instance that has all attribute definitions placeholder had (it'll always have at least one -- otherwise no placeholder was needed).void
defineFrom
(InputProblemReporter rep, DTDElement definedElem, boolean fullyValidate) Method called to "upgrade" a placeholder using a defined element, including adding attributes.private DTDAttribute
doAddAttribute
(Map<PrefixedName, DTDAttribute> attrMap, InputProblemReporter rep, DTDAttribute attr, List<DTDAttribute> specList, boolean fullyValidate) int
int
Specialized accessor used by non-validating but typing 'validator': essentially, used to figure out whether #PCDATA is allowed or not; and based on that, return one of 2 allowable text values (only space, or anything).getName()
protected HashMap
<String, DTDAttribute> int
private List
<DTDAttribute> boolean
boolean
boolean
boolean
void
mergeMissingAttributesFrom
(InputProblemReporter rep, DTDElement other, boolean fullyValidate) toString()
private void
-
Field Details
-
mName
-
mLocation
Location of the (real) definition of the element; may be null for placeholder elements created to hold ATTLIST definitions -
mValidator
StructValidator mValidatorBase validator object for validating content model of this element; may be null for some simple content models (ANY, EMPTY). -
mAllowedContent
int mAllowedContent -
mNsAware
final boolean mNsAwareTrue if the DTD was parsed (and is to be used) in namespace-aware mode. Affects (name) validation amongst other things. -
mXml11
final boolean mXml11True if the DTD was parsed in xml1.1 compliant mode (referenced to from an xml 1.1 document). Affects (name) validation amongst other things. -
mAttrMap
HashMap<PrefixedName,DTDAttribute> mAttrMap -
mSpecAttrList
ArrayList<DTDAttribute> mSpecAttrListOrdered list of attributes that have 'special' properties (attribute is required, has a default value [regular or fixed]); these attributes have to be specifically checked after actual values have been resolved. -
mAnyFixed
boolean mAnyFixed -
mAnyDefaults
boolean mAnyDefaultsFlag set to true if there are any attributes that have either basic default value, or #FIXED default value. -
mValidateAttrs
boolean mValidateAttrsFlag that is set to true if there is at least one attribute that has type that requires normalization and/or validation; that is, is of some other type than CDATA. -
mIdAttr
DTDAttribute mIdAttrId attribute instance, if one already declared for this element; can only have up to one such attribute per element. -
mNotationAttr
DTDAttribute mNotationAttrNotation attribute instance, if one already declared for this element; can only have up to one such attribute per element. -
mNsDefaults
HashMap<String,DTDAttribute> mNsDefaultsSet of namespace declarations with default values, if any (regular ns pseudo-attr declarations are just ignored)
-
-
Constructor Details
-
DTDElement
private DTDElement(Location loc, PrefixedName name, StructValidator val, int allowedContent, boolean nsAware, boolean xml11)
-
-
Method Details
-
createDefined
public static DTDElement createDefined(ReaderConfig cfg, Location loc, PrefixedName name, StructValidator val, int allowedContent) Method called to create an actual element definition, matching an ELEMENT directive in a DTD subset. -
createPlaceholder
Method called to create a "placeholder" element definition, needed to contain attribute definitions. -
define
Method called on placeholder element, to create a real instance that has all attribute definitions placeholder had (it'll always have at least one -- otherwise no placeholder was needed). -
defineFrom
public void defineFrom(InputProblemReporter rep, DTDElement definedElem, boolean fullyValidate) throws XMLStreamException Method called to "upgrade" a placeholder using a defined element, including adding attributes.- Throws:
XMLStreamException
-
verifyUndefined
private void verifyUndefined() -
addAttribute
public DTDAttribute addAttribute(InputProblemReporter rep, PrefixedName attrName, int valueType, DefaultAttrValue defValue, WordResolver enumValues, boolean fullyValidate) throws XMLStreamException Method called by DTD parser when it has read information about an attribute that belong to this element- Returns:
- Newly created attribute Object if the attribute definition was added (hadn't been declared yet); null if it's a duplicate, in which case original definition sticks.
- Throws:
XMLStreamException
-
addNsDefault
public DTDAttribute addNsDefault(InputProblemReporter rep, PrefixedName attrName, int valueType, DefaultAttrValue defValue, boolean fullyValidate) throws XMLStreamException Method called to add a definition of a namespace-declaration pseudo-attribute with a default value.- Parameters:
rep
- Reporter to use to report non-fatal problemsfullyValidate
- Whether this is being invoked for actual DTD validation, or just the "typing non-validator"- Returns:
- Attribute that acts as the placeholder, if the declaration was added; null to indicate it was a dup (there was an earlier declaration)
- Throws:
XMLStreamException
-
mergeMissingAttributesFrom
public void mergeMissingAttributesFrom(InputProblemReporter rep, DTDElement other, boolean fullyValidate) throws XMLStreamException - Throws:
XMLStreamException
-
doAddAttribute
private DTDAttribute doAddAttribute(Map<PrefixedName, DTDAttribute> attrMap, InputProblemReporter rep, DTDAttribute attr, List<DTDAttribute> specList, boolean fullyValidate) throws XMLStreamException- Returns:
- Earlier declaration of the attribute, if any; null if this was a new attribute
- Throws:
XMLStreamException
-
getName
-
toString
-
getDisplayName
-
getLocation
-
isDefined
public boolean isDefined() -
getAllowedContent
public int getAllowedContent()- Returns:
- Constant that identifies what kind of nodes are in general allowed inside this element.
-
getAllowedContentIfSpace
public int getAllowedContentIfSpace()Specialized accessor used by non-validating but typing 'validator': essentially, used to figure out whether #PCDATA is allowed or not; and based on that, return one of 2 allowable text values (only space, or anything). This is the relevant subset in non-validating modes, needed to properly type resulting character events. -
getAttributes
-
getSpecialCount
public int getSpecialCount() -
getSpecialAttrs
-
attrsNeedValidation
public boolean attrsNeedValidation()- Returns:
- True if at least one of the attributes has type other than CDATA; false if not
-
hasFixedAttrs
public boolean hasFixedAttrs() -
hasAttrDefaultValues
public boolean hasAttrDefaultValues() -
getIdAttribute
-
getNotationAttribute
-
hasNsDefaults
public boolean hasNsDefaults() -
getValidator
-
getNsDefaults
-
getSpecialList
-