public class RegularSequenceChecker extends ProxyReceiver
Outputter
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:
Outputter.startElement(NodeName, SchemaType, Location, int)
, endElement()
,
Outputter.startDocument(int)
, and endDocument()
are properly paired and nested.State | Events | Next State |
initial | open() | open |
open | open() | open |
open | Outputter.append(Item, Location, int) , SequenceReceiver.append(Item) ,
Outputter.characters(CharSequence, Location, int) , Outputter.comment(CharSequence, Location, int) ,
Outputter.processingInstruction(String, CharSequence, Location, int) | open |
open | Outputter.startDocument(int) | content |
open | Outputter.startElement(NodeName, SchemaType, Location, int) | content |
content | Outputter.characters(CharSequence, Location, int) , Outputter.comment(CharSequence, Location, int) ,
Outputter.processingInstruction(String, CharSequence, Location, int) | content |
content | Outputter.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, 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 |
nextReceiver
pipelineConfiguration, previousAtomic, systemId
Constructor and Description |
---|
RegularSequenceChecker(Receiver nextReceiver,
boolean fullChecking)
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 |
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 |
open()
Start of event stream
|
void |
processingInstruction(java.lang.String target,
java.lang.CharSequence data,
Location locationId,
int properties)
Processing Instruction
|
void |
startDocument(int properties)
Start of a document node.
|
void |
startElement(NodeName elemName,
SchemaType type,
AttributeMap attributes,
NamespaceMap namespaces,
Location location,
int properties)
Notify the start of an element.
|
getNamePool, getNextReceiver, setPipelineConfiguration, setSystemId, setUnderlyingReceiver, setUnparsedEntity, usesTypeAnnotations
append, decompose, flatten, getConfiguration, getErrorCodeForDecomposingFunctionItems, getPipelineConfiguration, getSystemId, handlesAppend
public RegularSequenceChecker(Receiver nextReceiver, boolean fullChecking)
nextReceiver
- the underlying receiver to which the events will be sent (without change)fullChecking
- requests full validation of the content passed across the interface. If false,
the only checking is that the sequence of events is correct. If true, more thorough
validation is carried out (though this does not necessarily mean that every violation
is detected).public void append(Item item, Location locationId, int copyNamespaces) throws XPathException
append
in interface Receiver
append
in class ProxyReceiver
item
- 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 ReceiverOption.ALL_NAMESPACES
; the default (0) meansXPathException
- if an error occurspublic void characters(java.lang.CharSequence chars, Location locationId, int properties) throws XPathException
characters
in interface Receiver
characters
in class ProxyReceiver
chars
- 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 Receiver
close
in class ProxyReceiver
XPathException
- if an error occurspublic void comment(java.lang.CharSequence chars, Location locationId, int properties) throws XPathException
comment
in interface Receiver
comment
in class ProxyReceiver
chars
- 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 Receiver
endDocument
in class ProxyReceiver
XPathException
- if an error occurspublic void endElement() throws XPathException
endElement
in interface Receiver
endElement
in class ProxyReceiver
XPathException
- if an error occurspublic void open() throws XPathException
open
in interface Receiver
open
in class ProxyReceiver
XPathException
- if an error occurspublic void processingInstruction(java.lang.String target, java.lang.CharSequence data, Location locationId, int properties) throws XPathException
processingInstruction
in interface Receiver
processingInstruction
in class ProxyReceiver
target
- 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 startDocument(int properties) throws XPathException
startDocument
in interface Receiver
startDocument
in class ProxyReceiver
properties
- properties of the document node.XPathException
- if an error occurspublic void startElement(NodeName elemName, SchemaType type, AttributeMap attributes, NamespaceMap namespaces, Location location, int properties) throws XPathException
All attributes must satisfy the following constraints:
The following additional constraints apply to the set of attributes as a whole:
These constraints are not all enforced by this class.
startElement
in interface Receiver
startElement
in class ProxyReceiver
elemName
- the name of the element. If the name is in a namespace (non-empty namespace URI)
then the Outputter.namespace(String, String, int)
event must include
a binding for the relevant prefix (or absence of a prefix) to the relevant URI.type
- the type annotation of the element.attributes
- the attributes of the elementnamespaces
- the in-scope namespaces of the elementlocation
- provides information such as line number and system ID.properties
- properties of the element nodeXPathException
- if an error occursCopyright (c) 2004-2022 Saxonica Limited. All rights reserved.