org.apache.ws.jaxme.xs.util
Class DTDParser

java.lang.Object
  extended by org.apache.ws.jaxme.xs.impl.XSLogicalParser
      extended by org.apache.ws.jaxme.xs.util.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.DTDAttribute
          This class is used to collect the attributes in the DTD temporarily.
 class DTDParser.DtdDeclHandler
          Implementation of a DeclHandler for reading the element and attribute declarations.
 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
 
Constructor Summary
DTDParser()
           
 
Method Summary
protected  void addChildren(XsTTopLevelElement pElement, XsTExplicitGroup pGroup, DTDParser.ChildToken pToken, org.xml.sax.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, java.lang.String pName, java.lang.String pModel, DTDParser.DTDAttribute[] pAttributes, org.xml.sax.Locator pLocator)
          Creates an element named pName with the content model pModel and the attribute list pAttrs in the schema pSchema.
 XSContext getData()
           
protected  java.lang.String getDummyElementName()
           
 org.xml.sax.Locator getLocator()
          Returns the document locator.
protected  java.lang.String getMultiplicity(java.lang.String pToken)
          Returns a tokens multiplicity.
 XsAnyURI getTargetNamespace()
          Returns the created schemas target namespace.
 XSSchema parse(org.xml.sax.InputSource pInputSource)
          This is the logical parsers frontend for parsing the given InputSource.
protected  void parse(XsESchema pSchema, org.xml.sax.InputSource pSource)
          Parses the given InputSource and converts it into an instance of XsESchema.
protected  DTDParser.ChildToken parseChildren(java.lang.String pModel, org.xml.sax.Locator pLocator)
          Converts a list of children into its tokens.
protected  XsGAttrDecls parseChildren(XsTTopLevelElement pElement, java.lang.String pModel, org.xml.sax.Locator pLocator)
          Parses a content model with children.
protected  XsGAttrDecls parseMixed(XsTTopLevelElement pElement, java.lang.String pModel, org.xml.sax.Locator pLocator, boolean pHasAttributes)
          Parses a mixed content model.
protected  void runXMLReader(org.xml.sax.InputSource pSource)
          Parses the given DTD, filling the parsers temporary map of elements.
 void setLocator(org.xml.sax.Locator pLocator)
          Sets the document locator.
protected  void setMultiplicity(XsAGOccurs pOccurs, java.lang.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, getInputSource, getSchema, getSyntaxSchemas, getXSContentHandler, importSchema, importSchema, includeSchema, isValidating, parse, parse, parseSyntax, parseSyntax, parseSyntax, redefine, redefineSchema, removeSyntaxSchema, setSchema, setValidating
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DTDParser

public DTDParser()
Method Detail

getData

public XSContext getData()
Overrides:
getData in class XSLogicalParser

getLocator

public org.xml.sax.Locator getLocator()
Returns the document locator.


setLocator

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


getDummyElementName

protected java.lang.String getDummyElementName()

runXMLReader

protected void runXMLReader(org.xml.sax.InputSource pSource)
                     throws javax.xml.parsers.ParserConfigurationException,
                            java.io.IOException,
                            org.xml.sax.SAXException
Parses the given DTD, filling the parsers temporary map of elements.

Throws:
javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException

getMultiplicity

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


parseChildren

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

Throws:
org.xml.sax.SAXException

setMultiplicity

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


addChildren

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

Throws:
org.xml.sax.SAXException

parseChildren

protected XsGAttrDecls parseChildren(XsTTopLevelElement pElement,
                                     java.lang.String pModel,
                                     org.xml.sax.Locator pLocator)
                              throws org.xml.sax.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? ')'
 

Throws:
org.xml.sax.SAXException

parseMixed

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

Throws:
org.xml.sax.SAXException

createAttribute

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

Throws:
org.xml.sax.SAXException

createElement

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

Throws:
org.xml.sax.SAXException

parse

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

Throws:
javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException

parse

public XSSchema parse(org.xml.sax.InputSource pInputSource)
               throws javax.xml.parsers.ParserConfigurationException,
                      java.io.IOException,
                      org.xml.sax.SAXException
Description copied from class: XSLogicalParser

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 class XSLogicalParser
Throws:
javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException
See Also:
#getXSContentHandler()

setTargetNamespace

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


getTargetNamespace

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