http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Installation
Build

API Docs
Samples
Programming
Migration
FAQs

Releases
Feedback
Bug-Todo

Download
CVS Repository
Mail Archive

API Docs for SAX and DOM
 

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

XMLElementDecl Class Reference

This class defines the core information of an element declaration. More...

#include <XMLElementDecl.hpp>

Collaboration diagram for XMLElementDecl:

Collaboration graph
[legend]
List of all members.

Public Types

enum  CreateReasons {
  NoReason, Declared, AttList, InContentModel,
  AsRootElem, JustFaultIn
}
enum  LookupOpts { AddIfNotFound, FailIfNotFound }
enum  CharDataOpts { NoCharData, SpacesOk, AllCharData }

Public Methods

Destructor
virtual ~XMLElementDecl ()
Virual ElementDecl interface
virtual XMLAttDeffindAttr ( const XMLCh* const qName , const unsigned int uriId , const XMLCh* const baseName , const LookupOpts options , bool& wasAdded ) const = 0
 Find an attribute by name or optionally fault it in. More...

virtual XMLAttDefListgetAttDefList () const = 0
 Get a list of attributes defined for this element. More...

virtual const XMLCh* getBaseName () const = 0
 Get the base name of this element type. More...

virtual CharDataOpts getCharDataOpts () const = 0
 The character data options for this element type. More...

virtual const XMLCh* getFullName () const = 0
 Get the full name of this element type. More...

virtual bool hasAttDefs () const = 0
 Indicate whether this element type defined any attributes. More...

virtual bool resetDefs () = 0
 Reset the flags on the attribute definitions. More...

Getter methods
const XMLContentModelgetContentModel () const
 Get a pointer to the abstract content model. More...

XMLContentModelgetContentModel ()
 Get a pointer to the abstract content model. More...

CreateReasons getCreateReason () const
 Get the create reason for this element type. More...

unsigned int getId () const
 Get the element decl pool id for this element type. More...

bool isDeclared () const
 Indicate whether this element type has been declared yet. More...

bool isExternal () const
 Indicate whether this element type has been declared externally. More...

Setter methods
void setContentModel (XMLContentModel* const newModelToAdopt)
 Set the content model object for this element type. More...

void setCreateReason (const CreateReasons newReason)
 Update the create reason for this element type. More...

void setId (const unsigned int newId)
 Set the element decl pool id for this element type. More...

void setExternalElemDeclaration ()
 Set the element decl to indicate external declaration.

Miscellenous methods
const XMLCh* getFormattedContentModel ( const XMLValidator& validator ) const
 Geta formatted string of the content model. More...

const XMLCh* getKey () const
 Support keyed collections. More...


Static Public Attributes

const unsigned int fgInvalidElemId
const unsigned int fgPCDataElemId
const XMLCh fgPCDataElemName []

Protected Methods

 XMLElementDecl ()
virtual XMLContentModelmakeContentModel () const = 0
virtual XMLCh* formatContentModel ( const XMLValidator& validator ) const = 0

Detailed Description

This class defines the core information of an element declaration.

Each validator (DTD, Schema, etc...) will have its own information that it associations with the declaration of an element, but they must all share at least this core information, i.e. they must all derive from this class. The set of info enforced at this level is driven by the needs of XML 1.0 spec validation and well formedness checks.

This class supports keyed collection semantics by providing the getKey() method, which extracts the key field. getKey() just calls getFullName() which is virtual so that each type of validator can have its own version of what a full name is. For the DTD validator, its element decl derivatives will return QNames in form pre:name. A Schema validator would return expanded names in the form {uri}name.

This class defines some special element id values for invalid elements and PCDATA elements, as well as a string for the special PCDATA element name. All validators must honor these special values in order to allow content models to work generically (i.e. to let code know when its dealing with invalid or PCDATA element ids without having to know what type of validator its messing with.)


Member Enumeration Documentation

enum XMLElementDecl::CharDataOpts
 

Enumeration values:
NoCharData  
SpacesOk  
AllCharData  

enum XMLElementDecl::CreateReasons
 

Enumeration values:
NoReason  
Declared  
AttList  
InContentModel  
AsRootElem  
JustFaultIn  

enum XMLElementDecl::LookupOpts
 

Enumeration values:
AddIfNotFound  
FailIfNotFound  


Constructor & Destructor Documentation

XMLElementDecl::~XMLElementDecl ( ) [virtual]
 

XMLElementDecl::XMLElementDecl ( ) [protected]
 


Member Function Documentation

XMLAttDef * XMLElementDecl::findAttr ( const XMLCh *const qName,
const unsigned int uriId,
const XMLCh *const baseName,
const LookupOpts options,
bool & wasAdded ) const [pure virtual]
 

Find an attribute by name or optionally fault it in.

The derived class should look up the passed attribute in the list of of attributes for this element. If namespaces are enabled, then it should use the uriId/baseName pair, else it should use the qName. The options allow the caller to indicate whether the attribute should be defaulted in if not found. If it is defaulted in, then wasAdded should be set, else it should be cleared. If its not found and the caller does not want defaulting, then return a null pointer.

Parameters:
qName   This is the qName of the attribute, i.e. the actual lexical name found.
uriId   This is the id of the URI of the namespace to which this attribute mapped. Only valid if namespaces are enabled.
baseName   This is the base part of the name, i.e. after any prefix.
options   Indicates the lookup options.
wasAdded   Should be set if the attribute is faulted in, else cleared.

virtual XMLCh* XMLElementDecl::formatContentModel ( const XMLValidator & validator ) const [protected, pure virtual]
 

XMLAttDefList & XMLElementDecl::getAttDefList ( ) const [pure virtual]
 

Get a list of attributes defined for this element.

The derived class should return a reference to some member object which implements the XMLAttDefList interface. This object gives the scanner the ability to look through the attributes defined for this element.

It is done this way for efficiency, though of course this is not thread safe. The scanner guarantees that it won't ever call this method in any nested way, but the outside world must be careful about when it calls this method, and optimally never would.

const XMLCh * XMLElementDecl::getBaseName ( ) const [pure virtual]
 

Get the base name of this element type.

The derived class should return the base name part of the element's name. This is the same regardless of whether namespaces are enabled or not.

Returns:
A const pointer to the base name of the element decl.

CharDataOpts XMLElementDecl::getCharDataOpts ( ) const [pure virtual]
 

The character data options for this element type.

The derived class should return an appropriate character data opts value which correctly represents its tolerance towards whitespace or character data inside of its instances. This allows the scanner to do all of the validation of character data.

XMLContentModel * XMLElementDecl::getContentModel ( )
 

Get a pointer to the abstract content model.

This method is identical to the previous one, except that it is non const.

const XMLContentModel * XMLElementDecl::getContentModel ( ) const
 

Get a pointer to the abstract content model.

This method will return a const pointer to the content model object of this element. This class is a simple abstraction that allows an element to define and use multiple, specialized content model types internally but still allow the outside world to do simple stuff with them.

Returns:
A const pointer to the element's content model, via the basic abstract content model type.

XMLElementDecl::CreateReasons XMLElementDecl::getCreateReason ( ) const
 

Get the create reason for this element type.

This method returns an enumeration which indicates why this element declaration exists. Elements can be used before they are actually declared, so they will often be faulted into the pool and marked as to why they are there.

Returns:
An enumerated value that indicates the reason why this element was added to the element decl pool.

const XMLCh * XMLElementDecl::getFormattedContentModel ( const XMLValidator & validator ) const
 

Geta formatted string of the content model.

This method is a convenience method which will create a formatted representation of the content model of the element. It will not always exactly recreate the original model, since some normalization or or reformatting may occur. But, it will be a technically accurate representation of the original content model.

The format depends upon the validator, since content models are expressed differently in different structural description languages.

Parameters:
validator   The validator which owns this object, and which therefore has the information required to format the content model.

Returns:
A pointer to an internal buffer which contains the formatted content model. The caller does not own this buffer and should copy it if it needs to be kept around.

const XMLCh * XMLElementDecl::getFullName ( ) const [pure virtual]
 

Get the full name of this element type.

The derived class should reutrn the full name of the element. If namespaces are not enabled, then this is the qName. Else it is the {uri}baseName form. For those validators that always require namespace processing, it will always be in the latter form because namespace processing will always be on.

unsigned int XMLElementDecl::getId ( ) const
 

Get the element decl pool id for this element type.

This method will return the element decl pool id of this element declaration. This uniquely identifies this element type within the parse event that it is declared within. This value is assigned by the validator whose decl pool this object belongs to.

Returns:
The element decl id of this element declaration.

const XMLCh * XMLElementDecl::getKey ( ) const
 

Support keyed collections.

This method allows objects of this type be placed into one of the standard keyed collections. This method will return the full name of the element, which will vary depending upon the type of the validator.

Returns:
A const pointer to teh full name of this element type.

bool XMLElementDecl::hasAttDefs ( ) const [pure virtual]
 

Indicate whether this element type defined any attributes.

The derived class should return a boolean that indicates whether this element has any attributes defined for it or not. This is an optimization that allows the scanner to skip some work if no attributes exist.

bool XMLElementDecl::isDeclared ( ) const
 

Indicate whether this element type has been declared yet.

This method returns a boolean that indicates whether this element has been declared yet. There are a number of reasons why an element declaration can be faulted in, but eventually it must be declared or its an error. See the CreateReasons enumeration.

Returns:
true if this element has been declared, else false.

bool XMLElementDecl::isExternal ( ) const
 

Indicate whether this element type has been declared externally.

This method returns a boolean that indicates whether this element has been declared externally.

Returns:
true if this element has been declared externally, else false.

virtual XMLContentModel* XMLElementDecl::makeContentModel ( ) const [protected, pure virtual]
 

bool XMLElementDecl::resetDefs ( ) [pure virtual]
 

Reset the flags on the attribute definitions.

This method is called by the scanner at the beginning of each scan of a start tag, asking this element decl to reset the 'declared' flag of each of its attribute defs. This allows the scanner to mark each one as declared yet or not.

void XMLElementDecl::setContentModel ( XMLContentModel *const newModelToAdopt )
 

Set the content model object for this element type.

This method will adopt the based content model object. This is called by the actual validator which is parsing its DTD or Schema or whatever a creating an element decl. It will build what it feels is the correct content model type object and store it on the element decl object via this method.

Parameters:
newModelToAdopt   This method will adop the passed content model object. Any previous object is destroyed.

void XMLElementDecl::setCreateReason ( const CreateReasons newReason )
 

Update the create reason for this element type.

This method will update the 'create reason' field for this element decl object. As the validator parses its DTD, Schema, etc... it will encounter various references to an element declaration, which will cause the element declaration to either be declared or to be faulted into the pool in preperation for some future declaration. As it does so,it will update this field to indicate the current satus of the decl object.

void XMLElementDecl::setExternalElemDeclaration ( )
 

Set the element decl to indicate external declaration.

void XMLElementDecl::setId ( const unsigned int newId )
 

Set the element decl pool id for this element type.

This method will set the pool id of this element decl. This is called by the validator which created this object, and will provide this decl object with a unique id within the parse event that created it.


Member Data Documentation

const unsigned int XMLElementDecl::fgInvalidElemId [static]
 

const unsigned int XMLElementDecl::fgPCDataElemId [static]
 

const XMLCh XMLElementDecl::fgPCDataElemName[] [static]
 


The documentation for this class was generated from the following file:


Copyright © 2000 The Apache Software Foundation. All Rights Reserved.