Xerces-J API: Class XMLContentSpec

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.xerces.framework
Class XMLContentSpec

    java.lang.Object
      |
      +--org.apache.xerces.framework.XMLContentSpec

public class XMLContentSpec
extends java.lang.Object

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,v 1.14 2001/05/31 15:10:02 neilg Exp $

Inner Class Summary
`static interface` | `XMLContentSpec.Provider` Provides a means for walking the structure built out of content spec "nodes".

Field Summary
`static int` | `CONTENTSPECNODE_ALL` Represents
`static int` | `CONTENTSPECNODE_ANY` Represents any namespace specified namespace.
`static int` | `CONTENTSPECNODE_ANY_LAX` prcessContent is 'lax'
`static int` | `CONTENTSPECNODE_ANY_NS` Represents any namespace element (including "##local").
`static int` | `CONTENTSPECNODE_ANY_NS_LAX`
`static int` | `CONTENTSPECNODE_ANY_NS_SKIP`
`static int` | `CONTENTSPECNODE_ANY_OTHER` Represents any other namespace (XML Schema: ##other).
`static int` | `CONTENTSPECNODE_ANY_OTHER_LAX`
`static int` | `CONTENTSPECNODE_ANY_OTHER_SKIP`
`static int` | `CONTENTSPECNODE_ANY_SKIP` processContent is 'skip'
`static int` | `CONTENTSPECNODE_CHOICE` Represents choice, '|'.
`static int` | `CONTENTSPECNODE_LEAF` Name or #PCDATA.
`static int` | `CONTENTSPECNODE_ONE_OR_MORE` Represents a one or more occurence count, '+'.
`static int` | `CONTENTSPECNODE_SEQ` Represents sequence, ','.
`static int` | `CONTENTSPECNODE_ZERO_OR_MORE` Represents a zero or more occurence count, '*'.
`static int` | `CONTENTSPECNODE_ZERO_OR_ONE` Represents a zero or one occurence count, '?'.
`int` | `otherValue` The "right hand" value of the content spec node.
`int` | `type` The content spec node type.
`int` | `value` The "left hand" value of the content spec node.

Constructor Summary
`XMLContentSpec()` Default constructor.
`XMLContentSpec(int type, int value, int otherValue)` Constructs a content spec with the specified values.
`XMLContentSpec(XMLContentSpec.Provider provider, int contentSpecIndex)` Constructs a content spec from the values specified by the given content spec provider and identifier.
`XMLContentSpec(XMLContentSpec contentSpec)` Constructs a content spec from the values in the specified content spec.

Method Summary
`void` | `clear()` Clears the values.
`boolean` | `equals(java.lang.Object object)` Returns true if the two objects are equal.
`int` | `hashCode()` Returns a hash code for this node.
`void` | `setValues(int type, int value, int otherValue)` Sets the values.
`void` | `setValues(XMLContentSpec.Provider provider, int contentSpecIndex)` Sets the values from the values specified by the given content spec provider and identifier.
`void` | `setValues(XMLContentSpec contentSpec)` Sets the values of the specified content spec.
`static java.lang.String` | `toString(XMLContentSpec.Provider provider, StringPool stringPool, int contentSpecIndex)` Returns a string representation of the specified content spec identifier in the form of a DTD element content model.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CONTENTSPECNODE_LEAF

    public static final int CONTENTSPECNODE_LEAF

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

### CONTENTSPECNODE_ZERO_OR_ONE

    public static final int CONTENTSPECNODE_ZERO_OR_ONE

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

### CONTENTSPECNODE_ZERO_OR_MORE

    public static final int CONTENTSPECNODE_ZERO_OR_MORE

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

### CONTENTSPECNODE_ONE_OR_MORE

    public static final int CONTENTSPECNODE_ONE_OR_MORE

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

### CONTENTSPECNODE_CHOICE

    public static final int CONTENTSPECNODE_CHOICE

  Represents choice, '|'.

### CONTENTSPECNODE_SEQ

    public static final int CONTENTSPECNODE_SEQ

  Represents sequence, ','.

### CONTENTSPECNODE_ANY

    public static final int 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_OTHER

    public static final int 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_NS

    public static final int CONTENTSPECNODE_ANY_NS

  Represents any namespace element (including "##local").

### CONTENTSPECNODE_ALL

    public static final int CONTENTSPECNODE_ALL

  Represents

### CONTENTSPECNODE_ANY_LAX

    public static final int CONTENTSPECNODE_ANY_LAX

  prcessContent is 'lax'

### CONTENTSPECNODE_ANY_OTHER_LAX

    public static final int CONTENTSPECNODE_ANY_OTHER_LAX

### CONTENTSPECNODE_ANY_NS_LAX

    public static final int CONTENTSPECNODE_ANY_NS_LAX

### CONTENTSPECNODE_ANY_SKIP

    public static final int CONTENTSPECNODE_ANY_SKIP

  processContent is 'skip'

### CONTENTSPECNODE_ANY_OTHER_SKIP

    public static final int CONTENTSPECNODE_ANY_OTHER_SKIP

### CONTENTSPECNODE_ANY_NS_SKIP

    public static final int CONTENTSPECNODE_ANY_NS_SKIP

### type

    public int 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`, `CONTENTSPECNODE_ALL`

### value

    public int value

  The "left hand" value of the content spec node. // leaf index, single child for unary ops, left child for binary ops.

### otherValue

    public int otherValue

  The "right hand" value of the content spec node. // right child for binary ops

Constructor Detail

### XMLContentSpec

    public XMLContentSpec()

  Default constructor.

### XMLContentSpec

    public XMLContentSpec(int type,
                          int value,
                          int otherValue)

  Constructs a content spec with the specified values.

### XMLContentSpec

    public XMLContentSpec(XMLContentSpec contentSpec)

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

### XMLContentSpec

    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

### clear

    public void clear()

  Clears the values.

### setValues

    public void setValues(int type,
                          int value,
                          int otherValue)

  Sets the values.

### setValues

    public void setValues(XMLContentSpec contentSpec)

  Sets the values of the specified content spec.

### setValues

    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.

### toString

    public static java.lang.String toString(XMLContentSpec.Provider provider,
                                            StringPool stringPool,
                                            int contentSpecIndex)

  Returns a string representation of the specified content spec identifier in the form of a DTD element content model.

  Note: This method is not namespace aware.

### hashCode

    public int hashCode()

  Returns a hash code for this node.
  Overrides:
    hashCode in class java.lang.Object

### equals

    public boolean equals(java.lang.Object object)

  Returns true if the two objects are equal.
  Overrides:
    equals in class java.lang.Object

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999-2001 Apache XML Project. All Rights Reserved.