Class XmlParserStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Due to backwards compatibility reasons, RFC7952 metadata emitted by this parser may include key QNames with empty URI
(as exposed via LEGACY_ATTRIBUTE_NAMESPACE
) as their QNameModule. These indicate an unqualified XML
attribute and their value can be assumed to be a String. Furthermore, this extends to qualified attributes, which
uses the proper namespace, but will not bind to a proper module revision -- these need to be reconciled with a
particular SchemaContext and are expected to either be fully decoded, or contain a String value. Handling of such
annotations is at the discretion of the user encountering it: preferred way of handling is to either filter or
normalize them to proper QNames/values when encountered. This caveat will be removed in a future version.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final QNameModule
Deprecated.The use on this namespace is discouraged and users are strongly encouraged to proper RFC7952 metadata annotations. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static XmlParserStream
create
(NormalizedNodeStreamWriter writer, MountPointContext mountCtx) Utility method for use when cachingXmlCodecFactory
is not feasible.static XmlParserStream
create
(NormalizedNodeStreamWriter writer, MountPointContext mountCtx, YangInstanceIdentifier parentNode) static XmlParserStream
create
(NormalizedNodeStreamWriter writer, MountPointContext mountCtx, YangInstanceIdentifier parentNode, boolean strictParsing) static XmlParserStream
create
(NormalizedNodeStreamWriter writer, MountPointContext mountCtx, EffectiveStatementInference parentNode) Utility method for use when cachingXmlCodecFactory
is not feasible.static XmlParserStream
create
(NormalizedNodeStreamWriter writer, MountPointContext mountCtx, EffectiveStatementInference parentNode, boolean strictParsing) Utility method for use when cachingXmlCodecFactory
is not feasible.static XmlParserStream
create
(NormalizedNodeStreamWriter writer, MountPointContext mountCtx, SchemaNodeIdentifier.Absolute parentNode) static XmlParserStream
create
(NormalizedNodeStreamWriter writer, MountPointContext mountCtx, SchemaNodeIdentifier.Absolute parentNode, boolean strictParsing) static XmlParserStream
create
(NormalizedNodeStreamWriter writer, XmlCodecFactory codecs, EffectiveStatementInference parentNode) Construct a newXmlParserStream
with strict parsing mode switched on.static XmlParserStream
create
(NormalizedNodeStreamWriter writer, XmlCodecFactory codecs, EffectiveStatementInference parentNode, boolean strictParsing) Construct a newXmlParserStream
.static XmlParserStream
create
(NormalizedNodeStreamWriter writer, XmlCodecFactory codecs, SchemaNodeIdentifier.Absolute parentNode) static XmlParserStream
create
(NormalizedNodeStreamWriter writer, XmlCodecFactory codecs, SchemaNodeIdentifier.Absolute parentNode, boolean strictParsing) static XmlParserStream
create
(NormalizedNodeStreamWriter writer, EffectiveModelContext context) Utility method for use when cachingXmlCodecFactory
is not feasible.static XmlParserStream
create
(NormalizedNodeStreamWriter writer, EffectiveModelContext context, boolean strictParsing) Utility method for use when cachingXmlCodecFactory
is not feasible.static XmlParserStream
create
(NormalizedNodeStreamWriter writer, EffectiveStatementInference parentNode) Utility method for use when cachingXmlCodecFactory
is not feasible.static XmlParserStream
create
(NormalizedNodeStreamWriter writer, EffectiveStatementInference parentNode, boolean strictParsing) Utility method for use when cachingXmlCodecFactory
is not feasible.void
flush()
parse
(XMLStreamReader reader) This method parses the XML source and emits node events into a NormalizedNodeStreamWriter based on the YANG-modeled data contained in the XML source.This method traverses aDOMSource
and emits node events into a NormalizedNodeStreamWriter based on the YANG-modeled data contained in the source.
-
Field Details
-
LEGACY_ATTRIBUTE_NAMESPACE
Deprecated.The use on this namespace is discouraged and users are strongly encouraged to proper RFC7952 metadata annotations.QNameModule
for use with legacy XML attributes.
-
-
Method Details
-
create
public static XmlParserStream create(NormalizedNodeStreamWriter writer, XmlCodecFactory codecs, EffectiveStatementInference parentNode) Construct a newXmlParserStream
with strict parsing mode switched on.- Parameters:
writer
- Output writercodecs
- Shared codecsparentNode
- Parent root node- Returns:
- A new stream instance
-
create
public static XmlParserStream create(NormalizedNodeStreamWriter writer, XmlCodecFactory codecs, EffectiveStatementInference parentNode, boolean strictParsing) Construct a newXmlParserStream
.- Parameters:
writer
- Output writercodecs
- Shared codecsparentNode
- Parent root nodestrictParsing
- parsing mode if set to true, the parser will throw an exception if it encounters unknown child nodes (nodes, that are not defined in the provided SchemaContext) in containers and lists if set to false, the parser will skip unknown child nodes- Returns:
- A new stream instance
-
create
public static XmlParserStream create(NormalizedNodeStreamWriter writer, EffectiveModelContext context) Utility method for use when cachingXmlCodecFactory
is not feasible. Users with high performance requirements should usecreate(NormalizedNodeStreamWriter, XmlCodecFactory, EffectiveStatementInference)
instead and maintain aXmlCodecFactory
to match the currentEffectiveModelContext
. -
create
public static XmlParserStream create(NormalizedNodeStreamWriter writer, EffectiveModelContext context, boolean strictParsing) Utility method for use when cachingXmlCodecFactory
is not feasible. Users with high performance requirements should usecreate(NormalizedNodeStreamWriter, XmlCodecFactory, EffectiveStatementInference)
instead and maintain aXmlCodecFactory
to match the currentEffectiveModelContext
. -
create
public static XmlParserStream create(NormalizedNodeStreamWriter writer, EffectiveStatementInference parentNode) Utility method for use when cachingXmlCodecFactory
is not feasible. Users with high performance requirements should usecreate(NormalizedNodeStreamWriter, XmlCodecFactory, EffectiveStatementInference)
instead and maintain aXmlCodecFactory
to match the currentEffectiveModelContext
. -
create
public static XmlParserStream create(NormalizedNodeStreamWriter writer, EffectiveStatementInference parentNode, boolean strictParsing) Utility method for use when cachingXmlCodecFactory
is not feasible. Users with high performance requirements should usecreate(NormalizedNodeStreamWriter, XmlCodecFactory, EffectiveStatementInference)
instead and maintain aXmlCodecFactory
to match the currentEffectiveModelContext
. -
create
Utility method for use when cachingXmlCodecFactory
is not feasible. Users with high performance requirements should usecreate(NormalizedNodeStreamWriter, XmlCodecFactory, EffectiveStatementInference)
instead and maintain aXmlCodecFactory
to match the currentMountPointContext
. -
create
public static XmlParserStream create(NormalizedNodeStreamWriter writer, MountPointContext mountCtx, EffectiveStatementInference parentNode) Utility method for use when cachingXmlCodecFactory
is not feasible. Users with high performance requirements should usecreate(NormalizedNodeStreamWriter, XmlCodecFactory, EffectiveStatementInference)
instead and maintain aXmlCodecFactory
to match the currentMountPointContext
. -
create
@Beta public static XmlParserStream create(NormalizedNodeStreamWriter writer, MountPointContext mountCtx, SchemaNodeIdentifier.Absolute parentNode) -
create
@Beta public static XmlParserStream create(NormalizedNodeStreamWriter writer, MountPointContext mountCtx, SchemaNodeIdentifier.Absolute parentNode, boolean strictParsing) -
create
@Beta public static XmlParserStream create(NormalizedNodeStreamWriter writer, XmlCodecFactory codecs, SchemaNodeIdentifier.Absolute parentNode) -
create
@Beta public static XmlParserStream create(NormalizedNodeStreamWriter writer, XmlCodecFactory codecs, SchemaNodeIdentifier.Absolute parentNode, boolean strictParsing) -
create
@Beta public static XmlParserStream create(NormalizedNodeStreamWriter writer, MountPointContext mountCtx, YangInstanceIdentifier parentNode) -
create
@Beta public static XmlParserStream create(NormalizedNodeStreamWriter writer, MountPointContext mountCtx, YangInstanceIdentifier parentNode, boolean strictParsing) -
create
public static XmlParserStream create(NormalizedNodeStreamWriter writer, MountPointContext mountCtx, EffectiveStatementInference parentNode, boolean strictParsing) Utility method for use when cachingXmlCodecFactory
is not feasible. Users with high performance requirements should usecreate(NormalizedNodeStreamWriter, XmlCodecFactory, EffectiveStatementInference)
instead and maintain aXmlCodecFactory
to match the currentMountPointContext
. -
parse
This method parses the XML source and emits node events into a NormalizedNodeStreamWriter based on the YANG-modeled data contained in the XML source.- Parameters:
reader
- StAX reader which is to used to walk through the XML source- Returns:
- instance of XmlParserStream
- Throws:
XMLStreamException
- if a well-formedness error or an unexpected processing condition occurs while parsing the XMLIOException
- if an error occurs while parsing the value of an anyxml node
-
traverse
This method traverses aDOMSource
and emits node events into a NormalizedNodeStreamWriter based on the YANG-modeled data contained in the source.- Parameters:
src
-DOMSource
to be traversed- Returns:
- instance of XmlParserStream
- Throws:
XMLStreamException
- if a well-formedness error or an unexpected processing condition occurs while parsing the XMLIOException
- if an error occurs while parsing the value of an anyxml node
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Throws:
IOException
-