|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.openxml.parser.BaseParser | +--org.openxml.parser.ContentParser | +--org.openxml.parser.XMLParser
Implements a parser for XML documents, document fragments, nodes and external
entities. The XML document is created with DOMFactory
, but a specific
class type may be requested with parseDocument(DTDDocument,Class)
.
Stuff to do:
ContentParser
,
SAXException
Fields inherited from class org.openxml.parser.ContentParser |
_currentNode,
_docType |
Fields inherited from class org.openxml.parser.BaseParser |
_curChar,
_document,
_tokenText,
CR,
EOF,
LF,
SPACE,
TOKEN_CDATA,
TOKEN_CLOSE_TAG,
TOKEN_COMMENT,
TOKEN_DTD,
TOKEN_ENTITY_REF,
TOKEN_EOF,
TOKEN_OPEN_TAG,
TOKEN_PE_REF,
TOKEN_PI,
TOKEN_SECTION,
TOKEN_SECTION_END,
TOKEN_TEXT |
Constructor Summary | |
XMLParser(BaseParser owner,
java.io.Reader reader,
java.lang.String sourceURI)
Constructor for entity parser. |
|
XMLParser(java.io.Reader reader,
java.lang.String sourceURI)
Parser constructor. |
|
XMLParser(java.io.Reader reader,
java.lang.String sourceURI,
short mode,
short stopAtSeverity)
Parser constructor. |
Method Summary | |
protected boolean |
closingTag(java.lang.String name,
boolean keepQuite)
Called to process the closing tag. |
Document |
parseDocument()
|
Document |
parseDocument(DTDDocument dtd)
Parses and returns a new XML document. |
Document |
parseDocument(DTDDocument dtd,
java.lang.Class docClass)
Parses and returns a new XML document. |
protected void |
parseDTDSubset(boolean standalone)
Parser the internal and external DTD subsets. |
Entity |
parseEntity(org.openxml.dom.EntityImpl entity,
boolean internal)
Parses the external/internal entity and places its contents underneath the entity node. |
protected boolean |
parseNextNode(int token)
Parses the next node based on the supplied token. |
Node |
parseNode(Node node)
|
Methods inherited from class org.openxml.parser.ContentParser |
getEntityContents,
parseAttrEntity,
parseAttributes,
parseContentEntity,
readTokenContent |
Methods inherited from class org.openxml.parser.BaseParser |
advanceLineNumber,
canReadName,
close,
error,
fatalError,
getColumnNumber,
getErrorHandler,
getErrorReport,
getLastException,
getLineNumber,
getLocator,
getMode,
getPublicId,
getReader,
getSourcePosition,
getSourceURI,
getSystemId,
isClosed,
isMode,
isNamePart,
isSpace,
isTokenAllSpace,
parseDocumentDecl,
parseGeneralEntity,
pushBack,
pushBack,
readChar,
readTokenEntity,
readTokenMarkup,
readTokenName,
readTokenPERef,
readTokenQuoted,
setEncoding,
setErrorHandler,
setErrorSink,
slicePITokenText,
warning |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public XMLParser(java.io.Reader reader, java.lang.String sourceURI, short mode, short stopAtSeverity)
Reader
object and as an identifier. The parsing mode consists of a
combination of MODE_.. flags. The constructor specifies the error
severity level at which to stop parsing, either Parser.STOP_SEVERITY_FATAL
,
Parser.STOP_SEVERITY_VALIDITY
or Parser.STOP_SEVERITY_WELL_FORMED
.reader
- Any Reader
from which entity text can be readsourceURI
- URI of entity sourcemode
- The parsing mode in effectstopAtSeverity
- Severity level at which to stop parsingpublic XMLParser(BaseParser owner, java.io.Reader reader, java.lang.String sourceURI)
Parser.MODE_PARSE_ENTITY
is in effect). The severity level is set to
Parser.STOP_SEVERITY_FATAL
.owner
- The parser which invoked this parserreader
- Any Reader
from which entity text can be readsourceURI
- URI of entity sourcepublic XMLParser(java.io.Reader reader, java.lang.String sourceURI)
Parser.MODE_XML_PARSER
with Parser.STOP_SEVERITY_FATAL
.reader
- Any Reader
from which entity text can be readsourceURI
- URI of entity sourceMethod Detail |
public Document parseDocument() throws SAXException
public Document parseDocument(DTDDocument dtd) throws SAXException
Depending on the parsing modes, some parsing errors might cause an exception
to occur, others will be stored and later accessible with the BaseParser.getLastException()
method. I/O exceptions and runtime exceptions will
terminate parsing immediately by throwing a FatalSAXException
.
dtd
- The default DTD to use, if one not specified in the document,
or nulldtd
- The default DTD to use, if one not specified in the documentDTDDocument
public Document parseDocument(DTDDocument dtd, java.lang.Class docClass) throws SAXException
Depending on the parsing modes, some parsing errors might cause an exception
to occur, others will be stored and later accessible with the BaseParser.getLastException()
method. I/O exceptions and runtime exceptions will
terminate parsing immediately by throwing a FatalSAXException
.
If not null, docClass specifies the class for the created XML
document. That class must extend XMLDocument
.
dtd
- The default DTD to use, if one not specified in the document,
or nullxmlClass
- The class for the document object, or nullDTDDocument
,
XMLDocument
public final Node parseNode(Node node) throws SAXException
public final Entity parseEntity(org.openxml.dom.EntityImpl entity, boolean internal) throws SAXException
Depending on the parsing modes, some parsing errors might cause an exception
to occur, others will be stored and later accessible with the BaseParser.getLastException()
method. I/O exceptions and runtime exceptions will
terminate parsing immediately by throwing a FatalSAXException
.
entity
- The entity to parseinternal
- True if an internal entityprotected final boolean parseNextNode(int token) throws SAXException, java.io.IOException
ContentParser._currentNode
.
If plain text is read, it is accumulated and later on converted into a
Text
. If the node is an element, the element
is created and it's full contents read (recursively).
The return value indicates if the current element (in ContentParser._currentNode
)
has been closed with a closing tag (false), or should parsing continue at
the same level (true). False is also returned if the end of file has been
reached.
The following rules govern how tokens are translated into nodes:
CDATASection
if in
mode Parser.MODE_STORE_CDATA
, converted to plain text otherwise
Comment
if in mode Parser.MODE_STORE_COMMENT
, ignored otherwise
ProcessingInstruction
if in mode Parser.MODE_STORE_PI
,
ignored otherwise
Parser.MODE_PARSE_ENTITY
,
otherwise they are stored as EntityReference
nodes
ContentParser.parseAttributes(org.w3c.dom.Element, boolean)
Parser.MODE_PRESERVE_WS
or requested in the "xml:space"
attribute, whitespaces are converted to space (0x20) and trailing/leading
whitespaces are lost in element content
_currentNode = ...; token = readTokenContent(); while ( parseNextNode( token ) ) token = readTokenContent();
token
- The last token read with ContentParser.readTokenContent()
ContentParser.parseAttributes(org.w3c.dom.Element, boolean)
,
ContentParser.readTokenContent()
,
ContentParser._currentNode
,
#_orphanClosingTag
protected final boolean closingTag(java.lang.String name, boolean keepQuite) throws SAXException
parseNextNode(int)
and called on two occassions: when the closing tag is met,
and when an orphan closing tag has been identified. In the first instance,
it is called with keepQuite false, issuing an error if an orphan
closing tag is met. In the second instance, the orphan closing tag is
processed and so keepQuite is true.name
- The tag namekeepQuite
- True if orphan closing tag should not issue an errorContentParser._currentNode
protected final void parseDTDSubset(boolean standalone) throws SAXException, java.io.IOException
DTDDocument
is created, the internal subset is parsed into it, followed by the
external subset. Errors produced when parsing the DTD are directed to
this parser. If there is no internal subset, the external subset is
optinally cached in memory. Public identifiers may be converted to URIs,
as per the installed HolderFinder
.
This method is called after '<!DOCTYPE' has been consumed and returns after the terminating '>' has been read. The standalone flag is passed from the '<xml' PI processing.
standalone
- The standalone flag
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |