Top Description Inners Fields Constructors Methods
org.apache.xerces.impl.dtd

public Class XMLContentSpec

extends Object
Class Inheritance

ContentSpec really exists to aid the parser classes in implementing access to the grammar.

This class is used by the DTD scanner and the validator classes, allowing them to be used separately or together. This "struct" class is used to build content models for validation, where it is more efficient to fetch all of the information for each of these content model "fragments" than to fetch each field one at a time. Since configurations are allowed to have validators without a DTD scanner (i.e. a schema validator) and a DTD scanner without a validator (non-validating processor), this class can be used by each without requiring the presence of the other.

When processing element declarations, the DTD scanner will build up a representation of the content model using the node types that are defined here. Since a non-validating processor only needs to remember the type of content model declared (i.e. ANY, EMPTY, MIXED, or CHILDREN), it is free to discard the specific details of the MIXED and CHILDREN content models described using this class.

In the typical case of a validating processor reading the grammar of the document from a DTD, the information about the content model declared will be preserved and later "compiled" into an efficient form for use during element validation. Each content spec node that is saved is assigned a unique index that is used as a handle for the "value" or "otherValue" fields of other content spec nodes. A leaf node has a "value" that is either an index in the string pool of the element type of that leaf, or a value of -1 to indicate the special "#PCDATA" leaf type used in a mixed content model.

For a mixed content model, the content spec will be made up of leaf and choice content spec nodes, with an optional "zero or more" node. For example, the mixed content declaration "(#PCDATA)" would contain a single leaf node with a node value of -1. A mixed content declaration of "(#PCDATA|foo)*" would have a content spec consisting of two leaf nodes, for the "#PCDATA" and "foo" choices, a choice node with the "value" set to the index of the "#PCDATA" leaf node and the "otherValue" set to the index of the "foo" leaf node, and a "zero or more" node with the "value" set to the index of the choice node. If the content model has more choices, for example "(#PCDATA|a|b)*", then there will be more corresponding choice and leaf nodes, the choice nodes will be chained together through the "value" field with each leaf node referenced by the "otherValue" field.

For element content models, there are sequence nodes and also "zero or one" and "one or more" nodes. The leaf nodes would always have a valid string pool index, as the "#PCDATA" leaf is not used in the declarations for element content models.

Version
$Id: XMLContentSpec.java 446755 2006-09-15 21:56:27Z mrglavas $

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
XMLContentSpec.Provider

Provides a means for walking the structure built out of content spec "nodes".

Field Summary

Modifier and TypeField and Description
public static final short
CONTENTSPECNODE_ANY

Represents any namespace specified namespace.

public static final short
CONTENTSPECNODE_ANY_LAX

prcessContent is 'lax'

public static final short
CONTENTSPECNODE_ANY_LOCAL

Represents any local element (XML Schema: ##local).

public static final short
public static final short
public static final short
CONTENTSPECNODE_ANY_OTHER

Represents any other namespace (XML Schema: ##other).

public static final short
public static final short
public static final short
CONTENTSPECNODE_ANY_SKIP

processContent is 'skip'

public static final short
CONTENTSPECNODE_CHOICE

Represents choice, '|'.

public static final short
CONTENTSPECNODE_LEAF

Name or #PCDATA.

public static final short
CONTENTSPECNODE_ONE_OR_MORE

Represents a one or more occurence count, '+'.

public static final short
CONTENTSPECNODE_SEQ

Represents sequence, ','.

public static final short
CONTENTSPECNODE_ZERO_OR_MORE

Represents a zero or more occurence count, '*'.

public static final short
CONTENTSPECNODE_ZERO_OR_ONE

Represents a zero or one occurence count, '?'.

public Object
otherValue

The "right hand" value of the content spec node.

public short
type

The content spec node type.

public Object
value

The "left hand" value object of the content spec node.

Constructor Summary

AccessConstructor and Description
public
XMLContentSpec()

Default constructor.

public
XMLContentSpec(short type, Object value, Object otherValue)

Constructs a content spec with the specified values.

public
XMLContentSpec(XMLContentSpec contentSpec)

Constructs a content spec from the values in the specified content spec.

public
XMLContentSpec(XMLContentSpec.Provider provider, int contentSpecIndex)

Constructs a content spec from the values specified by the given content spec provider and identifier.

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Clears the values.

public boolean
equals(Object
the reference object with which to compare.
object
)

Overrides java.lang.Object.equals.

Returns true if the two objects are equal.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code for this node.
public void
setValues(short type, Object value, Object otherValue)

Sets the values.

public void
setValues(XMLContentSpec contentSpec)

Sets the values of the specified content spec.

public void
setValues(XMLContentSpec.Provider provider, int contentSpecIndex)

Sets the values from the values specified by the given content spec provider and identifier.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

CONTENTSPECNODE_ANYback to summary
public static final short CONTENTSPECNODE_ANY

Represents any namespace specified namespace. When the element found in the document must belong to a specific namespace, otherValue will contain the name of the namespace. If otherValue is -1 then the element can be from any namespace.

Lists of valid namespaces are created from choice content spec nodes that have any content spec nodes as children.

CONTENTSPECNODE_ANY_LAXback to summary
public static final short CONTENTSPECNODE_ANY_LAX

prcessContent is 'lax'

CONTENTSPECNODE_ANY_LOCALback to summary
public static final short CONTENTSPECNODE_ANY_LOCAL

Represents any local element (XML Schema: ##local).

CONTENTSPECNODE_ANY_LOCAL_LAXback to summary
public static final short CONTENTSPECNODE_ANY_LOCAL_LAX
CONTENTSPECNODE_ANY_LOCAL_SKIPback to summary
public static final short CONTENTSPECNODE_ANY_LOCAL_SKIP
CONTENTSPECNODE_ANY_OTHERback to summary
public static final short CONTENTSPECNODE_ANY_OTHER

Represents any other namespace (XML Schema: ##other).

When the content spec node type is set to CONTENTSPECNODE_ANY_OTHER, value will contain the namespace that cannot occur.

CONTENTSPECNODE_ANY_OTHER_LAXback to summary
public static final short CONTENTSPECNODE_ANY_OTHER_LAX
CONTENTSPECNODE_ANY_OTHER_SKIPback to summary
public static final short CONTENTSPECNODE_ANY_OTHER_SKIP
CONTENTSPECNODE_ANY_SKIPback to summary
public static final short CONTENTSPECNODE_ANY_SKIP

processContent is 'skip'

CONTENTSPECNODE_CHOICEback to summary
public static final short CONTENTSPECNODE_CHOICE

Represents choice, '|'.

CONTENTSPECNODE_LEAFback to summary
public static final short CONTENTSPECNODE_LEAF

Name or #PCDATA. Leaf nodes that represent parsed character data (#PCDATA) have values of -1.

CONTENTSPECNODE_ONE_OR_MOREback to summary
public static final short CONTENTSPECNODE_ONE_OR_MORE

Represents a one or more occurence count, '+'.

CONTENTSPECNODE_SEQback to summary
public static final short CONTENTSPECNODE_SEQ

Represents sequence, ','.

CONTENTSPECNODE_ZERO_OR_MOREback to summary
public static final short CONTENTSPECNODE_ZERO_OR_MORE

Represents a zero or more occurence count, '*'.

CONTENTSPECNODE_ZERO_OR_ONEback to summary
public static final short CONTENTSPECNODE_ZERO_OR_ONE

Represents a zero or one occurence count, '?'.

otherValueback to summary
public Object otherValue

The "right hand" value of the content spec node. leaf name.uri, right child for binary ops

typeback to summary
public short type

The content spec node type.

See Also
CONTENTSPECNODE_LEAF, CONTENTSPECNODE_ZERO_OR_ONE, CONTENTSPECNODE_ZERO_OR_MORE, CONTENTSPECNODE_ONE_OR_MORE, CONTENTSPECNODE_CHOICE, CONTENTSPECNODE_SEQ
valueback to summary
public Object value

The "left hand" value object of the content spec node. leaf name.localpart, single child for unary ops, left child for binary ops.

Constructor Detail

XMLContentSpecback to summary
public XMLContentSpec()

Default constructor.

XMLContentSpecback to summary
public XMLContentSpec(short type, Object value, Object otherValue)

Constructs a content spec with the specified values.

XMLContentSpecback to summary
public XMLContentSpec(XMLContentSpec contentSpec)

Constructs a content spec from the values in the specified content spec.

XMLContentSpecback to summary
public XMLContentSpec(XMLContentSpec.Provider provider, int contentSpecIndex)

Constructs a content spec from the values specified by the given content spec provider and identifier.

Method Detail

clearback to summary
public void clear()

Clears the values.

equalsback to summary
public boolean equals(Object object)

Overrides java.lang.Object.equals.

Returns true if the two objects are equal.

Parameters
object:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code for this node.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object.

setValuesback to summary
public void setValues(short type, Object value, Object otherValue)

Sets the values.

setValuesback to summary
public void setValues(XMLContentSpec contentSpec)

Sets the values of the specified content spec.

setValuesback to summary
public void setValues(XMLContentSpec.Provider provider, int contentSpecIndex)

Sets the values from the values specified by the given content spec provider and identifier. If the specified content spec cannot be provided, the values of this content spec are cleared.

org.apache.xerces.impl.dtd back to summary

public Interface XMLContentSpec.Provider


Provides a means for walking the structure built out of content spec "nodes". The user of this provider interface is responsible for knowing what the content spec node values "mean". If those values refer to content spec identifiers, then the user can call back into the provider to get the next content spec node in the structure.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

Returns true if the contentSpecIndex was found.
getContentSpec
(int
The content spec identifier. All content spec "nodes" have a unique identifier.
contentSpecIndex
,
XMLContentSpec
The content spec struct to fill in with the information.
contentSpec
)

Fills in the provided content spec structure with content spec information for a unique identifier.

Method Detail

getContentSpecback to summary
public boolean getContentSpec(int contentSpecIndex, XMLContentSpec contentSpec)

Fills in the provided content spec structure with content spec information for a unique identifier.

Parameters
contentSpecIndex:int

The content spec identifier. All content spec "nodes" have a unique identifier.

contentSpec:XMLContentSpec

The content spec struct to fill in with the information.

Returns:boolean

Returns true if the contentSpecIndex was found.