Class RegularSequenceChecker
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:
- Calls to
startElement(NodeName, SchemaType, Location, int),endElement(),startDocument(int), andendDocument()are properly paired and nested. - Events must only occur in a state where they are permitted; the states and transitions between states are defined by the table below. The initial state is initial, and the final state must be final.
| 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.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class net.sf.saxon.event.ProxyReceiver
nextReceiverFields inherited from class net.sf.saxon.event.SequenceReceiver
pipelineConfiguration, previousAtomic, systemIdFields inherited from interface javax.xml.transform.Result
PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING -
Constructor Summary
ConstructorsConstructorDescriptionRegularSequenceChecker(Receiver nextReceiver) Create a RegularSequenceChecker and allocate a unique Id. -
Method Summary
Modifier and TypeMethodDescriptionvoidAppend an arbitrary item (node or atomic value) to the output.voidattribute(NodeName nameCode, SimpleType typeCode, CharSequence value, Location locationId, int properties) Notify an attribute.voidcharacters(CharSequence chars, Location locationId, int properties) Character data (corresponding to a text node).voidclose()End of sequencevoidcomment(CharSequence chars, Location locationId, int properties) Output a comment(package private) static voidedge(RegularSequenceChecker.State from, String event, RegularSequenceChecker.State to) voidNotify the end of a document nodevoidEnd of elementvoidnamespace(NamespaceBindingSet namespaceBindings, int properties) Notify a namespace.voidopen()Start of event streamvoidprocessingInstruction(String target, CharSequence data, Location locationId, int properties) Processing InstructionvoidNotify the start of the content, that is, the completion of all attributes and namespaces.voidstartDocument(int properties) Start of a document node.voidstartElement(NodeName nameCode, SchemaType typeCode, Location location, int properties) Notify the start of an elementMethods inherited from class net.sf.saxon.event.ProxyReceiver
getNamePool, getNextReceiver, setPipelineConfiguration, setSystemId, setUnderlyingReceiver, setUnparsedEntity, usesTypeAnnotationsMethods inherited from class net.sf.saxon.event.SequenceReceiver
append, decompose, flatten, getConfiguration, getErrorCodeForDecomposingFunctionItems, getPipelineConfiguration, getSystemId, handlesAppend
-
Constructor Details
-
RegularSequenceChecker
Create a RegularSequenceChecker and allocate a unique Id.- Parameters:
nextReceiver- the underlying receiver to which the events will be sent (without change)
-
-
Method Details
-
edge
-
append
Append an arbitrary item (node or atomic value) to the output. In a regular sequence, append events occur only at the top level, that is, when the document / element stack is empty.- Specified by:
appendin interfaceReceiver- Overrides:
appendin classProxyReceiver- Parameters:
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 areReceiverOptions.ALL_NAMESPACES,ReceiverOptions.LOCAL_NAMESPACES; the default (0) means no namespaces- Throws:
XPathException
-
attribute
public void attribute(NodeName nameCode, SimpleType typeCode, CharSequence value, Location locationId, int properties) throws XPathException Notify an attribute. An attribute is either free-standing attribute, or a parented attribute. A free-standing attribute is one that occurs when the startElement / startDocument stack is empty; a parented attribute occurs between a startElement event and a startContent event.All attributes must satisfy the following constraints:
- The namespace prefix and URI must either both be present (non-zero-length) or both absent
- The prefix "xml" and the URI "http://www.w3.org/XML/1998/namespace" are allowed only in combination.
- The namespace URI "http://www.w3.org/2000/xmlns/" is not allowed.
- The namespace prefix "xmlns" is not allowed.
- The local name "xmlns" is not allowed in the absence of a namespace prefix and URI.
For a parented attribute, the following additional constraints apply to the set of attributes between a startElement event and the next startContent event:
- No two attributes may have the same (local-name, namespace URI) combination.
- No namespace prefix may be used in conjunction with more than one namespace URI.
- Every (namespace prefix, namespace URI) combination must correspond to an in-scope namespace:
that is, unless the (prefix, URI) pair is ("", "") or ("xml", "http://www.w3.org/XML/1998/namespace"),
it must be the subject of a
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.
- Specified by:
attributein interfaceReceiver- Overrides:
attributein classProxyReceiver- Parameters:
nameCode- The name of the attributetypeCode- The type of the attributelocationId- The location of the attributeproperties- Bit significant value. The following bits are defined:- DISABLE_ESCAPING
- Disable escaping for this attribute
- NO_SPECIAL_CHARACTERS
- Attribute value contains no special characters
value- the string value of the attribute- Throws:
XPathException- if an error occurs
-
characters
public void characters(CharSequence chars, Location locationId, int properties) throws XPathException Character data (corresponding to a text node). For character data within content (that is, events occurring when the startDocument / startElement stack is non-empty), character data events will never be consecutive and will never be zero-length.- Specified by:
charactersin interfaceReceiver- Overrides:
charactersin classProxyReceiver- Parameters:
chars- The characterslocationId- provides information such as line number and system ID.properties- Bit significant value. The following bits are defined:- DISABLE_ESCAPING
- Disable escaping for this text node
- USE_CDATA
- Output as a CDATA section
- Throws:
XPathException- if an error occurs
-
close
End of sequence- Specified by:
closein interfaceReceiver- Overrides:
closein classProxyReceiver- Throws:
XPathException- if an error occurs
-
comment
Output a comment- Specified by:
commentin interfaceReceiver- Overrides:
commentin classProxyReceiver- Parameters:
chars- The content of the commentlocationId- provides information such as line number and system ID.properties- Additional information about the comment.- Throws:
XPathException- if an error occurs
-
endDocument
Notify the end of a document node- Specified by:
endDocumentin interfaceReceiver- Overrides:
endDocumentin classProxyReceiver- Throws:
XPathException- if an error occurs
-
endElement
End of element- Specified by:
endElementin interfaceReceiver- Overrides:
endElementin classProxyReceiver- Throws:
XPathException- if an error occurs
-
namespace
Notify a namespace. Namespaces are notified after the startElement event, and before any children for the element. The namespaces that are reported are only required to include those that are different from the parent element; however, duplicates may be reported. A namespace must not conflict with any namespaces already used for element or attribute names.- Specified by:
namespacein interfaceReceiver- Overrides:
namespacein classProxyReceiver- Parameters:
namespaceBindings- the namespace (prefix, uri) pair to be notifiedproperties- any special properties to be passed on this call- Throws:
XPathException- if an error occurs
-
open
Start of event stream- Specified by:
openin interfaceReceiver- Overrides:
openin classProxyReceiver- Throws:
XPathException- if an error occurs
-
processingInstruction
public void processingInstruction(String target, CharSequence data, Location locationId, int properties) throws XPathException Processing Instruction- Specified by:
processingInstructionin interfaceReceiver- Overrides:
processingInstructionin classProxyReceiver- Parameters:
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.- Throws:
XPathException- if an error occurs
-
startContent
Notify the start of the content, that is, the completion of all attributes and namespaces. Note that the initial receiver of output from XSLT instructions will not receive this event, it has to detect it itself. Note that this event is reported for every element even if it has no attributes, no namespaces, and no content.- Specified by:
startContentin interfaceReceiver- Overrides:
startContentin classProxyReceiver- Throws:
XPathException- if an error occurs
-
startDocument
Start of a document node.- Specified by:
startDocumentin interfaceReceiver- Overrides:
startDocumentin classProxyReceiver- Parameters:
properties- bit-significant integer indicating properties of the document node. The definitions of the bits are in classReceiverOptions- Throws:
XPathException- if an error occurs
-
startElement
public void startElement(NodeName nameCode, SchemaType typeCode, Location location, int properties) throws XPathException Notify the start of an element- Specified by:
startElementin interfaceReceiver- Overrides:
startElementin classProxyReceiver- Parameters:
nameCode- 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 node- Throws:
XPathException- if an error occurs
-