Main Content

matlab.io.xml.dom.ParserConfiguration class

Package: matlab.io.xml.dom

XML parser options

Description

Use properties of a matlab.io.xml.dom.ParserConfiguration object to specify options for an XML parser represented as a matlab.io.xml.dom.Parser object. A ParserConfiguration object is created when you create a Parser object. Use the Configuration property of the Parser object to access the ParserConfiguration object.

The matlab.io.xml.dom.ParserConfiguration class is a handle class.

Class Attributes

HandleCompatible
true
ConstructOnLoad
true

For information on class attributes, see Class Attributes.

Properties

expand all

Whether to require a declared namespace for an element name prefix, specified as true or false. If the value is true, the parser includes these elements in the output document:

  • Elements with names that do not have a prefix

  • Elements with names that have a declared prefix

If the value is false, the parser also includes element that have a undeclared prefix.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to load an external document type definition (DTD), specified as true or false. If the value is true, the parser loads the external DTD specified by the input markup. If this option is false, the parser ignores the external DTD.

If the Validate property is set to true, the parser ignores the LoadExternalDTD property and loads the DTD.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to disable resolution of entity references, specified as true or false. If the value is true, the parser does not attempt to resolve entity references. If the value is false, the parser attempts to resolve entity references.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to disallow XML markup that includes a document type, specified as true or false. If the value is true, the parser does not parse XML markup that includes a doctype declaration and the parser ends with the error message doctype-not-allowed. If the value is false, the parser parses input XML markup that includes a doctype declaration.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to expand entity references in markup, specified as true or false. If the value is true, the parsed document retains external entity references. If the value is false, the parser replaces external entity references with the parsed content. For example, suppose the DTD of the document to be parsed defines an external entity as <!ENTITY sect SYSTEM "./sect.xml">, where sect.xml contains XML content to include in the document. Then, if this property is false, the parser replaces entity references of the form &sect; with the content of sect.xml in the parsed document. Otherwise, the reference remains in the parsed document and is serialized as &sect;.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to enforce uniform resource identifier (URI) conformity, specified as true or false. If the value is true, the parser enforces standard URI conformance. The parser ends with an error when it encounters a malformed URI.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to validate the input markup, specified as true or false. If the value is true, the document must specify a grammar (DTD or schema) and the parser reports markup errors based on it. If the value is false and the document specifies a grammar, the parser may parse the grammar, but does not validate the input against it.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to skip the validation of the input markup using a document type definition (DTD), specified as true or false. If the value is true, the parser uses the DTD specified by the input only to resolve entity references. If the value is false and the Validate property value is true, the parser uses the DTD to validate input.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to include input comments in the parser output, specified as true or false. If the value is true, the parser includes input comments in the output document. If the value is false, the parser ignores the comments.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to process XInclude declarations in the input XML, specified as true or false. If the value is true, the parser includes nodes that are specified by XInclude declarations in the output document tree. If the value is false, the parser ignores the XInclude declarations.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Uniform resource identifier (URI) of the external schema to use for validation of XML that uses namespaces, specified as a character vector or string scalar. The specified schema overrides the schema specified by the input XML markup.

The parser throws an error if the URI specifies a remote location.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Uniform resource identifier (URI) of the external schema to use for validation of XML that does not use namespaces, specified as a character vector or string scalar. The specified schema overrides the schema specified by the input XML markup.

The parser throws an error if the URI specifies a remote location.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to load a schema, specified as true or false. If the value is true and the Schema property value is true, the parser loads the schema specified by the input XML markup.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to use schema-based markup validation, specified as true or false. If the values of this property and the Namespace property are true, the parser validates the XML markup based on a schema.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether validation requires a schema, specified as true or false. If the values of this property and the Validate property are true, validation occurs only if the input XML specifies a schema. If the value of this property is false and the value of the Validate property is true, validation occurs if the input XML specifies either a DTD or a schema.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to enable full schema constraint checking, specified as true or false. A true value enables checking of the schema for particle-unique attribution constraint errors and particle derivation restriction constraint errors. Checking for these errors is time-consuming and memory-intensive.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to normalize white space in the XML input, specified as true or false. If the value of this property is true, validation is enabled, and the input XML specifies a schema, then the parser normalizes white space in element and attributes values using the white space normalization options defined in the schema for each attribute and element data type. If the value of this property is false, the schema normalizes only attribute values as defined in the XML 1.0 standard.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to ignore annotations in the schema markup, specified as true or false. If the value of this property is true, the parser ignores the annotations when parsing a schema. If the value of this property is false), the parser converts annotation declarations to annotation nodes in the schema output.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to validate annotations, specified as true or false. If the value of this property is true, the parser validates annotations. Each annotation is validated independently.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to generate synthetic annotations, specified as true or false. A true value enables generation of synthetic annotations. The parser generates a synthetic annotation when a schema component has nonschema attributes but no child annotation.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to cache parsed schema, specified as true or false. If the value is true, the schema grammar is cached for reuse in subsequent parses. The parser uses the cached grammar regardless of the value of the UseCachedGrammarInParse property.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to use a cached grammar, specified as true or false. If the value is true, the parser uses a cached schema grammar, if it exists. If the value is false, the parser parses the schema.

If the value of the CacheGrammarFromParse property is true, the parser uses the cached grammar regardless of the setting of UseCachedGrammarInParse.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to allow multiple schemas, specified as true or false. If the value is true, multiple schemas with the same namespace can be imported during schema validation. If the value is false, multiple schemas with the same namespace are not allowed.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to save post-schema-validation information, specified true or false. if the value is true, the parser saves post-schema-validation information.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to check identity constraints, specified as true or false. A true value enables checking of identity constraints specified by the schema associated with a document.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Object that resolves entities referenced by a document, specified as an object of a subclass of the matlab.io.xml.dom.EntityResolver class. To enable a parser to resolve entities referenced by a document, create a subclass of matlab.io.xml.dom.EntityResolver and set this property to an instance of the subclass.

If the value of this property is empty, the parser does not resolve entities referenced by a document.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Object that handles parse errors, specified as an object of a subclass of the matlab.io.xml.dom.ErrorHandler class. The error handler determines how to handle errors that the parser encounters while parsing XML markup in a file or string.

If the value of this property is empty (the default), then the parser uses a default error handler. The default error handler terminates parsing at the first parse error and throws a MATLAB error. If you want the parser to continue parsing after encountering a markup error when feasible, then specify a custom error handler. You can specify a custom error handler by creating a subclass of matlab.io.xml.dom.ErrorHandler and setting this property to an instance of the subclass.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Examples

collapse all

To specify parser options, modify the property values of the matlab.io.xml.dom.ParserConfiguration object assigned to the Configuration property of the matlab.io.xml.dom.Parser object. This example configures the parser to omit comments in the input XML from the parser output.

import matlab.io.xml.dom.*

parser = Parser();
parser.Configuration.Comments = false;
xmlFile = "days.xml";
doc = parseFile(parser,xmlFile);
Introduced in R2021a