@Beta public final class XmlParserStream extends Object implements Closeable, Flushable
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.
Modifier and Type | Field and Description |
---|---|
static QNameModule |
LEGACY_ATTRIBUTE_NAMESPACE
Deprecated.
The use on this namespace is discouraged and users are strongly encouraged to proper RFC7952 metadata
annotations.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
static XmlParserStream |
create(NormalizedNodeStreamWriter writer,
MountPointContext mountCtx,
SchemaNode parentNode)
Utility method for use when caching
XmlCodecFactory is not feasible. |
static XmlParserStream |
create(NormalizedNodeStreamWriter writer,
MountPointContext mountCtx,
SchemaNode parentNode,
boolean strictParsing)
Utility method for use when caching
XmlCodecFactory is not feasible. |
static XmlParserStream |
create(NormalizedNodeStreamWriter writer,
SchemaContext schemaContext,
SchemaNode parentNode)
Utility method for use when caching
XmlCodecFactory is not feasible. |
static XmlParserStream |
create(NormalizedNodeStreamWriter writer,
SchemaContext schemaContext,
SchemaNode parentNode,
boolean strictParsing)
Utility method for use when caching
XmlCodecFactory is not feasible. |
static XmlParserStream |
create(NormalizedNodeStreamWriter writer,
XmlCodecFactory codecs,
SchemaNode parentNode)
Construct a new
XmlParserStream with strict parsing mode switched on. |
static XmlParserStream |
create(NormalizedNodeStreamWriter writer,
XmlCodecFactory codecs,
SchemaNode parentNode,
boolean strictParsing)
Construct a new
XmlParserStream . |
void |
flush() |
XmlParserStream |
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.
|
XmlParserStream |
traverse(DOMSource src)
This method traverses a
DOMSource and emits node events into a NormalizedNodeStreamWriter based on the
YANG-modeled data contained in the source. |
@Deprecated public static final QNameModule LEGACY_ATTRIBUTE_NAMESPACE
QNameModule
for use with legacy XML attributes.public static XmlParserStream create(NormalizedNodeStreamWriter writer, XmlCodecFactory codecs, SchemaNode parentNode)
XmlParserStream
with strict parsing mode switched on.writer
- Output writercodecs
- Shared codecsparentNode
- Parent root nodepublic static XmlParserStream create(NormalizedNodeStreamWriter writer, XmlCodecFactory codecs, SchemaNode parentNode, boolean strictParsing)
XmlParserStream
.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 nodespublic static XmlParserStream create(NormalizedNodeStreamWriter writer, SchemaContext schemaContext, SchemaNode parentNode)
XmlCodecFactory
is not feasible. Users with high performance
requirements should use create(NormalizedNodeStreamWriter, XmlCodecFactory, SchemaNode)
instead and
maintain a XmlCodecFactory
to match the current SchemaContext
.public static XmlParserStream create(NormalizedNodeStreamWriter writer, SchemaContext schemaContext, SchemaNode parentNode, boolean strictParsing)
XmlCodecFactory
is not feasible. Users with high performance
requirements should use create(NormalizedNodeStreamWriter, XmlCodecFactory, SchemaNode)
instead and
maintain a XmlCodecFactory
to match the current SchemaContext
.public static XmlParserStream create(NormalizedNodeStreamWriter writer, MountPointContext mountCtx, SchemaNode parentNode)
XmlCodecFactory
is not feasible. Users with high performance
requirements should use create(NormalizedNodeStreamWriter, XmlCodecFactory, SchemaNode)
instead and
maintain a XmlCodecFactory
to match the current MountPointContext
.public static XmlParserStream create(NormalizedNodeStreamWriter writer, MountPointContext mountCtx, SchemaNode parentNode, boolean strictParsing)
XmlCodecFactory
is not feasible. Users with high performance
requirements should use create(NormalizedNodeStreamWriter, XmlCodecFactory, SchemaNode)
instead and
maintain a XmlCodecFactory
to match the current MountPointContext
.public XmlParserStream parse(XMLStreamReader reader) throws XMLStreamException, URISyntaxException, IOException, SAXException
reader
- StAX reader which is to used to walk through the XML sourceXMLStreamException
- if a well-formedness error or an unexpected processing condition occurs while parsing the XMLURISyntaxException
- if the namespace URI of an XML element contains a syntax errorIOException
- if an error occurs while parsing the value of an anyxml nodeSAXException
- if an error occurs while parsing the value of an anyxml node@Beta public XmlParserStream traverse(DOMSource src) throws XMLStreamException, URISyntaxException, IOException, SAXException
DOMSource
and emits node events into a NormalizedNodeStreamWriter based on the
YANG-modeled data contained in the source.src
- DOMSource
to be traversedXMLStreamException
- if a well-formedness error or an unexpected processing condition occurs while parsing the XMLURISyntaxException
- if the namespace URI of an XML element contains a syntax errorIOException
- if an error occurs while parsing the value of an anyxml nodeSAXException
- if an error occurs while parsing the value of an anyxml nodepublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void flush() throws IOException
flush
in interface Flushable
IOException
Copyright © 2019 OpenDaylight. All rights reserved.