public class RegularSequenceChecker extends ProxyReceiver
Receiver require the sequence of events to
be regular according to this definition.
A sequence of Receiver events is regular if the following conditions
are satisfied:
startElement(NodeName, SchemaType, Location, int), endElement(),
startDocument(int), and endDocument() are properly paired and nested.| State | Events | Next State |
|---|---|---|
| initial | open() | open |
| open | open() | open |
| open | append(Item, Location, int), SequenceReceiver.append(Item),
attribute(NodeName, SimpleType, CharSequence, Location, int), namespace(NamespaceBindingSet, int),
characters(CharSequence, Location, int), comment(CharSequence, Location, int),
processingInstruction(String, CharSequence, Location, int) | open |
| open | startDocument(int) | content |
| open | startElement(NodeName, SchemaType, Location, int) | startTag |
| startTag | attribute(NodeName, SimpleType, CharSequence, Location, int), namespace(NamespaceBindingSet, int) | startTag |
| startTag | startContent() | content |
| content | characters(CharSequence, Location, int), comment(CharSequence, Location, int),
processingInstruction(String, CharSequence, Location, int) | content |
| content | startElement(NodeName, SchemaType, Location, int) | startTag |
| content | endDocument(), endElement() | if the stack is empty, then content, otherwise open |
| (any) | close | final |
| final | close | final |
This class is not normally used in production within Saxon, but is available for diagnostics when needed.
Some implementations of Receiver accept sequences of events that are not regular; indeed, some
implementations are explicitly designed to produce a regular sequence from an irregular sequence.
Examples of such irregularities are append or startDocument events appearing within
element content, or attribute events being followed by text events with no intervening
startContent.
The rules for a regular sequence imply that the top level events (any events not surrounded
by startElement-endElement or startDocument-endDocument) can represent any sequence of items, including
for example multiple document nodes, free-standing attribute and namespace nodes, maps, arrays, and functions;
but within a startElement-endElement or startDocument-endDocument pair, the events represent content
that has been normalized and validated according to the XSLT rules for constructing complex content, or
the XQuery equivalent: for example, attributes and namespaces must appear before child nodes, a
startContent() event must occur after the attributes and namespaces, adjacent text nodes should
have been merged, zero-length text nodes should have been eliminated, all namespaces should be explicitly
declared, document nodes should be replaced by their children.
Element nodes in "composed form" (that is, existing as a tree in memory) may be passed through
the SequenceReceiver.append(Item) method at the top level, but within a startElement-endElement or
startDocument-endDocument pair, elements must be represented in "decomposed form" as a sequence
of events.
A call to close() is permitted in any state, but it should only be called in Open
state except on an error path; on error paths calling close() is recommended to ensure that
resources are released.
| Modifier and Type | Class and Description |
|---|---|
static class |
RegularSequenceChecker.State |
nextReceiverpipelineConfiguration, previousAtomic, systemId| Constructor and Description |
|---|
RegularSequenceChecker(Receiver nextReceiver)
Create a RegularSequenceChecker and allocate a unique Id.
|
| Modifier and Type | Method and Description |
|---|---|
void |
append(Item item,
Location locationId,
int copyNamespaces)
Append an arbitrary item (node or atomic value) to the output.
|
void |
attribute(NodeName nameCode,
SimpleType typeCode,
java.lang.CharSequence value,
Location locationId,
int properties)
Notify an attribute.
|
void |
characters(java.lang.CharSequence chars,
Location locationId,
int properties)
Character data (corresponding to a text node).
|
void |
close()
End of sequence
|
void |
comment(java.lang.CharSequence chars,
Location locationId,
int properties)
Output a comment
|
void |
endDocument()
Notify the end of a document node
|
void |
endElement()
End of element
|
void |
namespace(NamespaceBindingSet namespaceBindings,
int properties)
Notify a namespace.
|
void |
open()
Start of event stream
|
void |
processingInstruction(java.lang.String target,
java.lang.CharSequence data,
Location locationId,
int properties)
Processing Instruction
|
void |
startContent()
Notify the start of the content, that is, the completion of all attributes and namespaces.
|
void |
startDocument(int properties)
Start of a document node.
|
void |
startElement(NodeName nameCode,
SchemaType typeCode,
Location location,
int properties)
Notify the start of an element
|
getNamePool, getNextReceiver, setPipelineConfiguration, setSystemId, setUnderlyingReceiver, setUnparsedEntity, usesTypeAnnotationsappend, decompose, flatten, getConfiguration, getErrorCodeForDecomposingFunctionItems, getPipelineConfiguration, getSystemId, handlesAppendpublic RegularSequenceChecker(Receiver nextReceiver)
nextReceiver - the underlying receiver to which the events will be sent (without change)public void append(Item item, Location locationId, int copyNamespaces) throws XPathException
append in interface Receiverappend in class ProxyReceiveritem - the item to be appendedlocationId - the location of the calling instruction, for diagnosticscopyNamespaces - if the item is an element node, this indicates whether its namespaces
need to be copied. Values are ReceiverOptions.ALL_NAMESPACES,
ReceiverOptions.LOCAL_NAMESPACES; the default (0) means
no namespacesXPathExceptionpublic void attribute(NodeName nameCode, SimpleType typeCode, java.lang.CharSequence value, Location locationId, int properties) throws XPathException
All attributes must satisfy the following constraints:
For a parented attribute, the following additional constraints apply to the set of attributes between a startElement event and the next startContent event:
namespace(NamespaceBindingSet, int) event applicable to this
element or to some parent element, that has not been cancelled by a namespace undeclaration on
an inner element. If the namespace event appears on the same element as the attribute event then they
may arrive in either order.These constraints are not currently enforced by this class.
attribute in interface Receiverattribute in class ProxyReceivernameCode - The name of the attributetypeCode - The type of the attributelocationId - The location of the attributeproperties - Bit significant value. The following bits are defined:
value - the string value of the attributeIllegalStateException: - attempt to output an attribute when there is no open element
start tagXPathException - if an error occurspublic void characters(java.lang.CharSequence chars,
Location locationId,
int properties)
throws XPathException
characters in interface Receivercharacters in class ProxyReceiverchars - The characterslocationId - provides information such as line number and system ID.properties - Bit significant value. The following bits are defined:
XPathException - if an error occurspublic void close()
throws XPathException
close in interface Receiverclose in class ProxyReceiverXPathException - if an error occurspublic void comment(java.lang.CharSequence chars,
Location locationId,
int properties)
throws XPathException
comment in interface Receivercomment in class ProxyReceiverchars - The content of the commentlocationId - provides information such as line number and system ID.properties - Additional information about the comment.XPathException - if an error occurspublic void endDocument()
throws XPathException
endDocument in interface ReceiverendDocument in class ProxyReceiverXPathException - if an error occurspublic void endElement()
throws XPathException
endElement in interface ReceiverendElement in class ProxyReceiverXPathException - if an error occurspublic void namespace(NamespaceBindingSet namespaceBindings, int properties) throws XPathException
namespace in interface Receivernamespace in class ProxyReceivernamespaceBindings - the namespace (prefix, uri) pair to be notifiedproperties - any special properties to be passed on this callIllegalStateException: - attempt to output a namespace when there is no open element
start tagXPathException - if an error occurspublic void open()
throws XPathException
open in interface Receiveropen in class ProxyReceiverXPathException - if an error occurspublic void processingInstruction(java.lang.String target,
java.lang.CharSequence data,
Location locationId,
int properties)
throws XPathException
processingInstruction in interface ReceiverprocessingInstruction in class ProxyReceivertarget - The PI name. This must be a legal name (it will not be checked).data - The data portion of the processing instructionlocationId - provides information such as line number and system ID.properties - Additional information about the PI.XPathException - if an error occurspublic void startContent()
throws XPathException
startContent in interface ReceiverstartContent in class ProxyReceiverXPathException - if an error occurspublic void startDocument(int properties)
throws XPathException
startDocument in interface ReceiverstartDocument in class ProxyReceiverproperties - bit-significant integer indicating properties of the document node.
The definitions of the bits are in class ReceiverOptionsXPathException - if an error occurspublic void startElement(NodeName nameCode, SchemaType typeCode, Location location, int properties) throws XPathException
startElement in interface ReceiverstartElement in class ProxyReceivernameCode - integer code identifying the name of the element within the name pool.typeCode - integer code identifying the element's type within the name pool.location - provides information such as line number and system ID.properties - properties of the element nodeXPathException - if an error occursCopyright (c) 2004-2020 Saxonica Limited. All rights reserved.