org.apache.ws.jaxme.xs.util

Class DTDParser


public class DTDParser
extends XSLogicalParser

A SAX parser converting a DTD into an instance of XML Schema.

Nested Class Summary

protected static class
DTDParser.ChildToken
class
DTDParser.DtdDeclHandler
Implementation of a DeclHandler for reading the element and attribute declarations.
class
DTDParser.DTDAttribute
This class is used to collect the attributes in the DTD temporarily.
class
DTDParser.DTDElement
This class is used to collect the elements in the DTD temporarily.
static class
DTDParser.StringBufferReader
This class is similar to a StringReader, except that it allows to extend the input dynamically.

Nested classes/interfaces inherited from class org.apache.ws.jaxme.xs.impl.XSLogicalParser

XSLogicalParser.AddedImport

Method Summary

protected void
addChildren(XsTTopLevelElement pElement, XsTExplicitGroup pGroup, DTDParser.ChildToken pToken, Locator pLocator)
Adds the childs to a group.
protected void
createAttribute(XsGAttrDecls pAttrDecls, DTDParser.DTDAttribute pAttribute)
Creates a new attribute.
protected XsTTopLevelElement
createElement(XsESchema pSchema, String pName, String pModel, DTDParser.DTDAttribute[] pAttributes, Locator pLocator)
Creates an element named pName with the content model pModel and the attribute list pAttrs in the schema pSchema.
XSContext
getData()
protected String
getDummyElementName()
Locator
getLocator()
Returns the document locator.
protected String
getMultiplicity(String pToken)
Returns a tokens multiplicity.
XsAnyURI
getTargetNamespace()
Returns the created schemas target namespace.
XSSchema
parse(InputSource pInputSource)
This is the logical parsers frontend for parsing the given InputSource.
protected void
parse(XsESchema pSchema, InputSource pSource)
Parses the given org.xml.sax.InputSource and converts it into an instance of XsESchema.
protected DTDParser.ChildToken
parseChildren(String pModel, Locator pLocator)
Converts a list of children into its tokens.
protected XsGAttrDecls
parseChildren(XsTTopLevelElement pElement, String pModel, Locator pLocator)
Parses a content model with children.
protected XsGAttrDecls
parseMixed(XsTTopLevelElement pElement, String pModel, Locator pLocator, boolean pHasAttributes)
Parses a mixed content model.
protected void
runXMLReader(InputSource pSource)
Parses the given DTD, filling the parsers temporary map of elements.
void
setLocator(Locator pLocator)
Sets the document locator.
protected void
setMultiplicity(XsAGOccurs pOccurs, String pMultiplicity)
Sets the objects multiplicity.
void
setTargetNamespace(XsAnyURI pTargetNamespace)
Sets the created schemas target namespace.

Methods inherited from class org.apache.ws.jaxme.xs.impl.XSLogicalParser

add, addImport, addImport, addSyntaxSchema, clearSyntaxSchemas, createSubstitutionGroups, getAddedImports, getCurrentSyntaxSchema, getData, getInputSource, getSchema, getSyntaxSchemas, getXSContentHandler, importSchema, importSchema, includeSchema, isValidating, parse, parse, parse, parseSyntax, parseSyntax, parseSyntax, redefine, redefineSchema, removeSyntaxSchema, setSchema, setValidating

Method Details

addChildren

protected void addChildren(XsTTopLevelElement pElement,
                           XsTExplicitGroup pGroup,
                           DTDParser.ChildToken pToken,
                           Locator pLocator)
            throws SAXException
Adds the childs to a group.

createAttribute

protected void createAttribute(XsGAttrDecls pAttrDecls,
                               DTDParser.DTDAttribute pAttribute)
            throws SAXException
Creates a new attribute.

createElement

protected XsTTopLevelElement createElement(XsESchema pSchema,
                                           String pName,
                                           String pModel,
                                           DTDParser.DTDAttribute[] pAttributes,
                                           Locator pLocator)
            throws SAXException
Creates an element named pName with the content model pModel and the attribute list pAttrs in the schema pSchema.

getData

public XSContext getData()
Overrides:
getData in interface XSLogicalParser

getDummyElementName

protected String getDummyElementName()

getLocator

public Locator getLocator()
Returns the document locator.

getMultiplicity

protected String getMultiplicity(String pToken)
Returns a tokens multiplicity.

getTargetNamespace

public XsAnyURI getTargetNamespace()
Returns the created schemas target namespace.

parse

public XSSchema parse(InputSource pInputSource)
            throws ParserConfigurationException,
                   IOException,
                   SAXException
This is the logical parsers frontend for parsing the given InputSource. If the parsed schema includes or imports other schemas, they are also parsed and added to the parsers object tree.
Overrides:
parse in interface XSLogicalParser
See Also:
getXSContentHandler()

parse

protected void parse(XsESchema pSchema,
                     InputSource pSource)
            throws ParserConfigurationException,
                   IOException,
                   SAXException
Parses the given org.xml.sax.InputSource and converts it into an instance of XsESchema.

parseChildren

protected DTDParser.ChildToken parseChildren(String pModel,
                                             Locator pLocator)
            throws SAXException
Converts a list of children into its tokens.

parseChildren

protected XsGAttrDecls parseChildren(XsTTopLevelElement pElement,
                                     String pModel,
                                     Locator pLocator)
            throws SAXException
Parses a content model with children. This content model is specified as follows:
   children ::= (choice | seq) ('?' | '*' | '+')?
   cp ::= (Name | choice | seq) ('?' | '*' | '+')?
   choice ::= '(' S? cp ( S? '|' S? cp )+ S? ')'
   seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'
 

parseMixed

protected XsGAttrDecls parseMixed(XsTTopLevelElement pElement,
                                  String pModel,
                                  Locator pLocator,
                                  boolean pHasAttributes)
            throws SAXException
Parses a mixed content model. The mixed content model is specified as follows:
   Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*'
       | '(' S? '#PCDATA' S? ')' 
 

runXMLReader

protected void runXMLReader(InputSource pSource)
            throws ParserConfigurationException,
                   IOException,
                   SAXException
Parses the given DTD, filling the parsers temporary map of elements.

setLocator

public void setLocator(Locator pLocator)
Sets the document locator.

setMultiplicity

protected void setMultiplicity(XsAGOccurs pOccurs,
                               String pMultiplicity)
Sets the objects multiplicity.

setTargetNamespace

public void setTargetNamespace(XsAnyURI pTargetNamespace)
Sets the created schemas target namespace.