|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Matcher
Represents the state of matching an XML document against a RELAX NG pattern.
The XML document is considered as a linear sequence of events of different
kinds. For each kind of event E in the sequence, a call must be made
to a corresponding method matchE
on the
Matcher object. The kinds of event are:
The method calls must occur in an order corresponding to a well-formed XML document. In a well-formed document the sequence of events matches the following grammar:
document ::= StartDocument element element ::= startTag child* EndTag startTag ::= StartTagOpen attribute* StartTagClose attribute ::= AttributeName AttributeValue child ::= element | Text
Text events must be maximal. Two consecutive Text events are not allowed.
Each method matchE
returns false if matching
the event against the document resulted in an error and true otherwise.
If it returned false, then the error message can be obtained using
getErrorMessage
. In either case, the state of the
Matcher
changes so the Matcher
is prepared
to match the next event.
The copy()
and equals()
methods allow
applications to perform incremental revalidation.
Method Summary | |
---|---|
Matcher |
copy()
Return a copy of the current Matcher . |
boolean |
equals(java.lang.Object obj)
Return true if obj is an equivalent Matcher . |
java.lang.String |
getErrorMessage()
Return the current error message. |
boolean |
isTextTyped()
Return true if text may be typed in the current state, false otherwise. |
boolean |
isValidSoFar()
Return true if the document is valid so far. |
boolean |
matchAttributeName(Name name)
|
boolean |
matchAttributeValue(java.lang.String value,
ValidationContext vc)
Match an attribute value. |
boolean |
matchEndTag(ValidationContext vc)
Match an end-tag. |
boolean |
matchStartDocument()
This can only generate an error if the schema was equivalent to notAllowed . |
boolean |
matchStartTagClose()
Match the close of a start-tag (the > character that ends the start-tag). |
boolean |
matchStartTagOpen(Name name)
|
boolean |
matchText(java.lang.String string,
ValidationContext vc,
boolean nextTagIsEndTag)
Match a text event. |
boolean |
matchUntypedText()
An optimization of matchText . |
java.util.Vector |
possibleAttributes(java.util.Vector knownNames)
Return a Vector of the names of attributes that are valid in the current state. |
java.util.Vector |
possibleStartTags(java.util.Vector knownNames)
Return a Vector of the names of elements whose start-tags are valid in the current state. |
Method Detail |
---|
Matcher copy()
Matcher
.
Future changes to the state of the copy will not affect this and vice-versa.
Matcher
that is a copy of thisboolean equals(java.lang.Object obj)
Matcher
.
equals
in class java.lang.Object
boolean matchStartDocument()
notAllowed
.
boolean matchStartTagOpen(Name name)
boolean matchAttributeName(Name name)
boolean matchAttributeValue(java.lang.String value, ValidationContext vc)
value
- the attribute value, normalized in accordance with XML 1.0vc
- a validation context
boolean matchStartTagClose()
>
character that ends the start-tag).
This may cause an error if there are required attributes that have not been matched.
boolean matchText(java.lang.String string, ValidationContext vc, boolean nextTagIsEndTag)
matchText
are not allowed unless separated
by a call to matchStartTagOpen
or matchEndTag
.
Calls to matchText
can sometimes be optimized into
calls to matchUntypedText
.
string
- the text to be matchedvc
- a validation contextnextTagIsEndTag
- true if the next event is an EndTag, false if it is
a StartTagOpen
boolean matchUntypedText()
matchText
.
Unlike matchText
, matchUntypedText
does not
need to examine the text.
If isTextTyped
returns false, then in this state
text that consists of whitespace may be ignored and text that contains
non-whitespace characters may be processed using matchUntypedText
.
Furthermore it is not necessary to collect up all the text between tags;
consecutive calls to matchUntypedText
are allowed.
matchUntypedText
must not be used unless isTextTyped
returns false.
boolean isTextTyped()
matchText
must not be optimized
to matchUntypedText
.
boolean matchEndTag(ValidationContext vc)
vc
- a validation context
java.lang.String getErrorMessage()
matchE
method
that returns false. Initially, the current error message is null.
boolean isValidSoFar()
java.util.Vector possibleStartTags(java.util.Vector knownNames)
matchStartTagOpen
would be allowed.
The members of the Vector have type com.thaiopensource.xml.util.Name
.
When an element pattern with a wildcard name-class is possible, then all
Names in knownNames that are contained in the wildcard name-class will be
included in the returned Vector. The returned list may contain duplicates.
Does not modify knownNames
.
knownNames
- a Vector of names to be considered for wildcards, or null
java.util.Vector possibleAttributes(java.util.Vector knownNames)
matchAttributeName
would be allowed.
The members of the Vector have type com.thaiopensource.xml.util.Name
.
When an attribute pattern with a wildcard name-class is possible, then all
Names in knownNames that are contained in the wildcard name-class will be
included in the returned Vector. The returned list may contain duplicates.
Does not modify knownNames
.
knownNames
- a Vector of names to be considered for wildcards, or null
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |