Top Description Fields Constructors Methods
com.ctc.wstx.dtd

public final Class DTDElement

extends Object
Class Inheritance
Imports
java.util.*, javax.xml.stream.Location, .XMLStreamException, org.codehaus.stax2.validation.XMLValidator, com.ctc.wstx.api.ReaderConfig, com.ctc.wstx.cfg.ErrorConsts, com.ctc.wstx.sr.InputProblemReporter, com.ctc.wstx.util.ExceptionUtil, .PrefixedName, .WordResolver

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

Modifier and TypeField and Description
pack-priv int
pack-priv boolean
mAnyDefaults

Flag set to true if there are any attributes that have either basic default value, or #FIXED default value.

pack-priv boolean
pack-priv HashMap<PrefixedName, DTDAttribute>
pack-priv DTDAttribute
mIdAttr

Id attribute instance, if one already declared for this element; can only have up to one such attribute per element.

pack-priv final Location
mLocation

Location of the (real) definition of the element; may be null for placeholder elements created to hold ATTLIST definitions

pack-priv final PrefixedName
pack-priv DTDAttribute
mNotationAttr

Notation attribute instance, if one already declared for this element; can only have up to one such attribute per element.

pack-priv final boolean
mNsAware

True if the DTD was parsed (and is to be used) in namespace-aware mode.

pack-priv HashMap<String, DTDAttribute>
mNsDefaults

Set of namespace declarations with default values, if any (regular ns pseudo-attr declarations are just ignored)

pack-priv ArrayList<DTDAttribute>
mSpecAttrList

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.

pack-priv boolean
mValidateAttrs

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.

pack-priv StructValidator
mValidator

Base validator object for validating content model of this element; may be null for some simple content models (ANY, EMPTY).

pack-priv final boolean
mXml11

True if the DTD was parsed in xml1.1 compliant mode (referenced to from an xml 1.1 document).

Constructor Summary

AccessConstructor and Description
private
DTDElement(Location loc, PrefixedName name, StructValidator val, int allowedContent, boolean nsAware, boolean xml11)

Method Summary

Modifier and TypeMethod and Description
public DTDAttribute

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.
addAttribute
(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 element

public DTDAttribute

Returns:

Attribute that acts as the placeholder, if the declaration was added; null to indicate it was a dup (there was an earlier declaration)
addNsDefault
(InputProblemReporter
Reporter to use to report non-fatal problems
rep
,
PrefixedName attrName, int valueType, DefaultAttrValue defValue, boolean
Whether this is being invoked for actual DTD validation, or just the "typing non-validator"
fullyValidate
)

Method called to add a definition of a namespace-declaration pseudo-attribute with a default value.

public boolean

Returns:

True if at least one of the attributes has type other than CDATA; false if not
attrsNeedValidation
()

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.

public static DTDElement
createPlaceholder(ReaderConfig cfg, Location loc, PrefixedName name)

Method called to create a "placeholder" element definition, needed to contain attribute definitions.

public DTDElement
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).

public void
defineFrom(InputProblemReporter rep, DTDElement definedElem, boolean fullyValidate)

Method called to "upgrade" a placeholder using a defined element, including adding attributes.

private DTDAttribute

Returns:

Earlier declaration of the attribute, if any; null if this was a new attribute
doAddAttribute
(Map<PrefixedName, DTDAttribute> attrMap, InputProblemReporter rep, DTDAttribute attr, List<DTDAttribute> specList, boolean fullyValidate)

public int

Returns:

Constant that identifies what kind of nodes are in general allowed inside this element.
getAllowedContent
()

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).

public HashMap<PrefixedName, DTDAttribute>
public String
public DTDAttribute
public Location
public PrefixedName
public DTDAttribute
protected HashMap<String, DTDAttribute>
public List<DTDAttribute>
public int
private List<DTDAttribute>
public StructValidator
public boolean
public boolean
public boolean
public boolean
public void
mergeMissingAttributesFrom(InputProblemReporter rep, DTDElement other, boolean fullyValidate)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

mAllowedContentback to summary
pack-priv int mAllowedContent
mAnyDefaultsback to summary
pack-priv boolean mAnyDefaults

Flag set to true if there are any attributes that have either basic default value, or #FIXED default value.

mAnyFixedback to summary
pack-priv boolean mAnyFixed
mAttrMapback to summary
pack-priv HashMap<PrefixedName, DTDAttribute> mAttrMap
mIdAttrback to summary
pack-priv DTDAttribute mIdAttr

Id attribute instance, if one already declared for this element; can only have up to one such attribute per element.

mLocationback to summary
pack-priv final Location mLocation

Location of the (real) definition of the element; may be null for placeholder elements created to hold ATTLIST definitions

mNameback to summary
pack-priv final PrefixedName mName
mNotationAttrback to summary
pack-priv DTDAttribute mNotationAttr

Notation attribute instance, if one already declared for this element; can only have up to one such attribute per element.

mNsAwareback to summary
pack-priv final boolean mNsAware

True if the DTD was parsed (and is to be used) in namespace-aware mode. Affects (name) validation amongst other things.

mNsDefaultsback to summary
pack-priv HashMap<String, DTDAttribute> mNsDefaults

Set of namespace declarations with default values, if any (regular ns pseudo-attr declarations are just ignored)

mSpecAttrListback to summary
pack-priv ArrayList<DTDAttribute> mSpecAttrList

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.

mValidateAttrsback to summary
pack-priv boolean mValidateAttrs

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.

mValidatorback to summary
pack-priv StructValidator mValidator

Base validator object for validating content model of this element; may be null for some simple content models (ANY, EMPTY).

mXml11back to summary
pack-priv final boolean mXml11

True if the DTD was parsed in xml1.1 compliant mode (referenced to from an xml 1.1 document). Affects (name) validation amongst other things.

Constructor Detail

DTDElementback to summary
private DTDElement(Location loc, PrefixedName name, StructValidator val, int allowedContent, boolean nsAware, boolean xml11)

Method Detail

addAttributeback to summary
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:DTDAttribute

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.

addNsDefaultback to summary
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:InputProblemReporter

Reporter to use to report non-fatal problems

fullyValidate:boolean

Whether this is being invoked for actual DTD validation, or just the "typing non-validator"

Returns:DTDAttribute

Attribute that acts as the placeholder, if the declaration was added; null to indicate it was a dup (there was an earlier declaration)

attrsNeedValidationback to summary
public boolean attrsNeedValidation()
Returns:boolean

True if at least one of the attributes has type other than CDATA; false if not

createDefinedback to summary
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.

createPlaceholderback to summary
public static DTDElement createPlaceholder(ReaderConfig cfg, Location loc, PrefixedName name)

Method called to create a "placeholder" element definition, needed to contain attribute definitions.

defineback to summary
public DTDElement 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).

defineFromback to summary
public void defineFrom(InputProblemReporter rep, DTDElement definedElem, boolean fullyValidate) throws XMLStreamException

Method called to "upgrade" a placeholder using a defined element, including adding attributes.

doAddAttributeback to summary
private DTDAttribute doAddAttribute(Map<PrefixedName, DTDAttribute> attrMap, InputProblemReporter rep, DTDAttribute attr, List<DTDAttribute> specList, boolean fullyValidate) throws XMLStreamException
Returns:DTDAttribute

Earlier declaration of the attribute, if any; null if this was a new attribute

getAllowedContentback to summary
public int getAllowedContent()
Returns:int

Constant that identifies what kind of nodes are in general allowed inside this element.

getAllowedContentIfSpaceback to summary
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.

getAttributesback to summary
public HashMap<PrefixedName, DTDAttribute> getAttributes()
getDisplayNameback to summary
public String getDisplayName()
getIdAttributeback to summary
public DTDAttribute getIdAttribute()
getLocationback to summary
public Location getLocation()
getNameback to summary
public PrefixedName getName()
getNotationAttributeback to summary
public DTDAttribute getNotationAttribute()
getNsDefaultsback to summary
protected HashMap<String, DTDAttribute> getNsDefaults()
getSpecialAttrsback to summary
public List<DTDAttribute> getSpecialAttrs()
getSpecialCountback to summary
public int getSpecialCount()
getSpecialListback to summary
private List<DTDAttribute> getSpecialList()
getValidatorback to summary
public StructValidator getValidator()
hasAttrDefaultValuesback to summary
public boolean hasAttrDefaultValues()
hasFixedAttrsback to summary
public boolean hasFixedAttrs()
hasNsDefaultsback to summary
public boolean hasNsDefaults()
isDefinedback to summary
public boolean isDefined()
mergeMissingAttributesFromback to summary
public void mergeMissingAttributesFrom(InputProblemReporter rep, DTDElement other, boolean fullyValidate) throws XMLStreamException
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
verifyUndefinedback to summary
private void verifyUndefined()