org.eclipse.xsd.util
Class XSDParser

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--org.eclipse.xsd.util.XSDParser
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler

public class XSDParser
extends org.xml.sax.helpers.DefaultHandler
implements org.xml.sax.ext.LexicalHandler

The SAX Parser for the model. This handles the conversion of SAX parse exceptions to XSDDiagnostics. It also computes line column information, which is stored in a map on each node's user data. This class is not intended for reuse outside of the model implementation and is subject to change.


Field Summary
protected  int column
           
protected static java.lang.String DEFAULT_PARSER_NAME
           
protected  org.w3c.dom.Document document
           
protected  org.w3c.dom.Element element
           
protected  java.lang.String encoding
           
protected  int line
           
protected  org.xml.sax.Locator locator
           
protected  javax.xml.parsers.SAXParser saxParser
           
protected  java.util.Stack stack
           
protected  java.util.List xsdDiagnostics
           
protected  XSDFactory xsdFactory
          The cached factory.
protected  XSDSchema xsdSchema
           
 
Constructor Summary
XSDParser()
           
 
Method Summary
 void characters(char[] characters, int start, int length)
           
 void comment(char[] characters, int start, int length)
           
 void endCDATA()
           
 void endDocument()
           
 void endDTD()
           
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
           
 void endEntity(java.lang.String name)
           
 void error(org.xml.sax.SAXParseException exception)
           
protected  void fatalError(java.io.IOException exception)
           
protected  void fatalError(javax.xml.parsers.ParserConfigurationException exception)
           
 void fatalError(org.xml.sax.SAXException exception)
           
 void fatalError(org.xml.sax.SAXParseException exception)
           
 java.util.Collection getDiagnostics()
           
 org.w3c.dom.Document getDocument()
           
 java.lang.String getEncoding()
           
static int getEndColumn(org.w3c.dom.Node node)
          Returns the column at which the given node ends.
static int getEndLine(org.w3c.dom.Node node)
          Returns the line at which the given node ends.
 XSDSchema getSchema()
           
static int getStartColumn(org.w3c.dom.Node node)
          Returns the column at which the given node starts.
static int getStartLine(org.w3c.dom.Node node)
          Returns the line at which the given node starts.
static java.util.Map getUserData(org.w3c.dom.Node node)
          Returns the user data associated with the node.
 void parse(org.xml.sax.InputSource inputSource)
           
 void parse(java.io.InputStream inputStream)
           
 void parse(java.lang.String uri)
           
 void parseString(java.lang.String input)
           
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
           
protected  void saveLocation()
           
 void setDocumentLocator(org.xml.sax.Locator locator)
           
 void setSchema(XSDSchema xsdSchema)
           
 void startCDATA()
           
 void startDocument()
           
 void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
           
 void startEntity(java.lang.String name)
           
 void warning(org.xml.sax.SAXParseException exception)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, skippedEntity, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PARSER_NAME

protected static final java.lang.String DEFAULT_PARSER_NAME

xsdFactory

protected XSDFactory xsdFactory
The cached factory.

xsdSchema

protected XSDSchema xsdSchema

xsdDiagnostics

protected java.util.List xsdDiagnostics

saxParser

protected javax.xml.parsers.SAXParser saxParser

document

protected org.w3c.dom.Document document

stack

protected java.util.Stack stack

element

protected org.w3c.dom.Element element

locator

protected org.xml.sax.Locator locator

line

protected int line

column

protected int column

encoding

protected java.lang.String encoding
Constructor Detail

XSDParser

public XSDParser()
Method Detail

getUserData

public static java.util.Map getUserData(org.w3c.dom.Node node)
Returns the user data associated with the node. If the node has no user data, a new empty map is created. A null will be returned only in the case that the node cannot have user data or already has some other type of user data.
Parameters:
to - the node to query.
Returns:
the user data associated with the node.

getStartLine

public static int getStartLine(org.w3c.dom.Node node)
Returns the line at which the given node starts.
Parameters:
to - the node to query.
Returns:
the line at which the given node starts.

getStartColumn

public static int getStartColumn(org.w3c.dom.Node node)
Returns the column at which the given node starts.
Parameters:
to - the node to query.
Returns:
the column at which the given node starts.

getEndLine

public static int getEndLine(org.w3c.dom.Node node)
Returns the line at which the given node ends.
Parameters:
to - the node to query.
Returns:
the line at which the given node ends.

getEndColumn

public static int getEndColumn(org.w3c.dom.Node node)
Returns the column at which the given node ends.
Parameters:
to - the node to query.
Returns:
the column at which the given node ends.

parse

public void parse(java.lang.String uri)

parseString

public void parseString(java.lang.String input)

parse

public void parse(org.xml.sax.InputSource inputSource)

parse

public void parse(java.io.InputStream inputStream)

getEncoding

public java.lang.String getEncoding()

getDocument

public org.w3c.dom.Document getDocument()

setSchema

public void setSchema(XSDSchema xsdSchema)

getSchema

public XSDSchema getSchema()

getDiagnostics

public java.util.Collection getDiagnostics()

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Overrides:
setDocumentLocator in class org.xml.sax.helpers.DefaultHandler

startDocument

public void startDocument()
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler

endDocument

public void endDocument()
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler

characters

public void characters(char[] characters,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler

comment

public void comment(char[] characters,
                    int start,
                    int length)
             throws org.xml.sax.SAXException
Specified by:
comment in interface org.xml.sax.ext.LexicalHandler

startCDATA

public void startCDATA()
Specified by:
startCDATA in interface org.xml.sax.ext.LexicalHandler

endCDATA

public void endCDATA()
Specified by:
endCDATA in interface org.xml.sax.ext.LexicalHandler

startDTD

public void startDTD(java.lang.String name,
                     java.lang.String publicId,
                     java.lang.String systemId)
Specified by:
startDTD in interface org.xml.sax.ext.LexicalHandler

endDTD

public void endDTD()
Specified by:
endDTD in interface org.xml.sax.ext.LexicalHandler

startEntity

public void startEntity(java.lang.String name)
Specified by:
startEntity in interface org.xml.sax.ext.LexicalHandler

endEntity

public void endEntity(java.lang.String name)
Specified by:
endEntity in interface org.xml.sax.ext.LexicalHandler

fatalError

protected void fatalError(java.io.IOException exception)

fatalError

protected void fatalError(javax.xml.parsers.ParserConfigurationException exception)

fatalError

public void fatalError(org.xml.sax.SAXException exception)

fatalError

public void fatalError(org.xml.sax.SAXParseException exception)
Overrides:
fatalError in class org.xml.sax.helpers.DefaultHandler

error

public void error(org.xml.sax.SAXParseException exception)
Overrides:
error in class org.xml.sax.helpers.DefaultHandler

warning

public void warning(org.xml.sax.SAXParseException exception)
Overrides:
warning in class org.xml.sax.helpers.DefaultHandler

saveLocation

protected void saveLocation()

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
                                      throws org.xml.sax.SAXException
Overrides:
resolveEntity in class org.xml.sax.helpers.DefaultHandler

Copyright 2001-2003 IBM Corporation and others.
All Rights Reserved.