|
SASAX API - 1.5 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jp.ne.dti.lares.foozy.sasax.AbstractElement | +--jp.ne.dti.lares.foozy.sasax.DormantElement
Pseudo element to make another dormant till occurrence of acceptable event.
This class focuses on parsing part of document under the one defined in XML Schema like as below.
<xsd:any namespace="##any" minOccurs="1" maxOccurs="1"/>
For example, you are interested in the (sub)document as shown below:
<some> <structured> <document/> </structured> </some>
But parse target document may be one of belows, and you can not know it beforehand.
(1) <parent> <some> <structured> <document/> </structured> </some> </parent> (2) <parent> <upper> <some> <structured> <document/> </structured> </some> </upper> </parent> (3) <parent> <upper> <some> <structured> <document/> </structured> </some> <some> <structured> <document/> </structured> </some> </upper> </parent> (4) <parent> <upper> <middle> <some> <structured> <document/> </structured> </some> </middle> </upper> </parent> (5) <parent> <upper> <some> <structured> <document/> </structured> </some> <middle> <some> <structured> <document/> </structured> </some> </middle> </upper> </parent> .... and so on ....
In this case,
you can catch all document fragments, in which you are interested,
in the parse target document by this class with
factory
of "some
" element.
You can get caught "fragments" by getDetermineds(boolean)
after parsing.
ATTENTION:
For example, second "some
" element shown below
is not handled.
<parent>
<some>
<structured>
<document/>
</structured>
</some>
<some>
<structured>
<document/>
</structured>
</some>
</parent>
XML Schema shown below (again) tells you why:
<xsd:any namespace="##any" minOccurs="1" maxOccurs="1"/>
Please combine this and ElementRepetition
in this situation.
Constructor Summary | |
DormantElement(Element parent,
ElementFactory factory)
|
Method Summary | |
boolean |
accepts(ParseContext context,
java.lang.String uri,
java.lang.String lName)
Examine whether specified name is acceptable or not. |
Element |
characters(ParseContext context,
char[] chars,
int offset,
int length)
Receive notification of character data. |
Element |
endElement(ParseContext context,
java.lang.String uri,
java.lang.String lName)
Receive notification of the end of an element. |
java.util.Iterator |
getDetermineds(boolean ensure)
Get determined elements. |
Element |
processingInstruction(ParseContext context,
java.lang.String target,
java.lang.String data)
Receive notification of ignorable whitespace in element content. |
Element |
skippedEntity(ParseContext context,
java.lang.String name)
Receive notification of a processing instruction. |
Element |
startElement(ParseContext context,
java.lang.String uri,
java.lang.String lName,
org.xml.sax.Attributes attrs)
Receive notification of the beginning of an element. |
Methods inherited from class jp.ne.dti.lares.foozy.sasax.AbstractElement |
addCleanup, addNotification, clear, ensureDetermined, fireElementStarted, getAttribute, getParent, hasNotification, hasXSINil, ignorableWhitespace, isDetermined, notifyDetermined, notifyDetermined, removeNotification, setDetermined, unwatchAttribute, watchAttribute |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DormantElement(Element parent, ElementFactory factory)
Method Detail |
public final java.util.Iterator getDetermineds(boolean ensure)
Successful invocation of this method does not ensure that
all elements gotten from the returned iterator
are already determined.
This only ensured that
control is returned (by "endElement
", may be) to this
as same times as this encouters "startElement
"
which is acceptable for the factory.
But they should be determined
because nobody wants to use the Element
implementation
which does not determine itself
at the last "endElement
" event for it.
ensure
- whether determination should be ensured or not.elements
created by factory specified to constructor.AbstractElement.ensureDetermined()
public boolean accepts(ParseContext context, java.lang.String uri, java.lang.String lName)
This always returns "true",
because this element consumes(= ignores) events
till it encounters the event
which is acceptable for the factory specified
at construction time
.
accepts
in class AbstractElement
jp.ne.dti.lares.foozy.sasax.AbstractElement
context
- of SAX document parsing.uri
- given by "startElement" SAX event.lName
- given by "startElement" SAX event.Element.accepts(ParseContext, String, String)
public Element startElement(ParseContext context, java.lang.String uri, java.lang.String lName, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
This returns the element(result of appling
startElement
on it, in fact)
created by the factory
specified at construction time
,
if start-ed element is acceptable one for the factory.
Otherwise, this returns itself.
startElement
in class AbstractElement
jp.ne.dti.lares.foozy.sasax.AbstractElement
context
- of SAX document parsing.uri
- given by "startElement" SAX event.lName
- given by "startElement" SAX event.attrs
- given by "startElement" SAX event.org.xml.sax.SAXException
- if parsing should not be continued.Element.startElement(ParseContext, String, String, Attributes)
public Element endElement(ParseContext context, java.lang.String uri, java.lang.String lName) throws org.xml.sax.SAXException
This returns itself, while this encounters end-ed elements less than this does start-ed ones.
Otherwise, this returns parent
.
endElement
in class AbstractElement
jp.ne.dti.lares.foozy.sasax.AbstractElement
context
- of SAX document parsing.uri
- given by "endElement" SAX event.lName
- given by "endElement" SAX event.org.xml.sax.SAXException
- if parsing should not be continued.Element.endElement(ParseContext, String, String)
public Element characters(ParseContext context, char[] chars, int offset, int length) throws org.xml.sax.SAXException
This always returns itself(= ignores this event),
while this is not determied
.
characters
in class AbstractElement
org.xml.sax.SAXException
- if this is already determinedpublic Element processingInstruction(ParseContext context, java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
This always returns itself(= ignores this event),
while this is not determied
.
processingInstruction
in class AbstractElement
org.xml.sax.SAXException
- if this is already determinedpublic Element skippedEntity(ParseContext context, java.lang.String name) throws org.xml.sax.SAXException
This always returns itself(= ignores this event),
while this is not determied
.
skippedEntity
in class AbstractElement
org.xml.sax.SAXException
- if this is already determined
|
SASAX API - 1.5 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |