matlab.io.xml.dom.ParserConfiguration Class
Namespace: matlab.io.xml.dom
XML parser options
Description
Use an object of the matlab.io.xml.dom.ParserConfiguration class to specify options for an XML parser. Creating a
matlab.io.xml.dom.Parser object creates a
ParserConfiguration 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
Whether to require a declared namespace for an element name prefix, specified as a logical 1
(true) or 0 (false). When you
specify:
1(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
0(false) — The parser also includes element that have an undeclared prefix.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to load an external document type definition (DTD), specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parser loads the external DTD specified by the input markup.0(false) — The parser ignores the external DTD.
Note
If the Validate property is true, the
parser ignores the LoadExternalDTD property and loads the
DTD.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to disable resolution of entity references, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parser does not resolve entity references.0(false) — The parser attempts to resolve entity references.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether the XML file can contain a document type definition (DTD), specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The XML file can contain a DTD. Enable this option only for trusted sources.0(false) — The XML file cannot contain a DTD. If the specified file contains a DTD, setting this property to a value offalseresults in an error.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to retain entity and entity reference nodes, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parsed document represents parsed entities asEntitynodes and entity references asEntityReferencenodes.0(false) — The parser replaces entity reference nodes with the children of that node.
For example, suppose the DTD of the document defines an external entity as
<!ENTITY sect SYSTEM "./sect.xml">, where
sect.xml contains XML content to be included in the document. If
the Entities property is false, the parser parses
sect.xml and replaces occurrences of §
with the parsed content of sect.xml. If the
Entities property is true, the parser replaces occurrences of
§ with EntityReference nodes that
contain the parsed content of sect.xml. In this case, if the parsed
document is serialized, he parser replaces the EntityReference nodes
with §.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to enforce uniform resource identifier (URI) conformity, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parser enforces standard URI conformance. If the parser encounters a malformed URI, it generates an error.0(false) — The parser does not enforce standard URI conformance.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to validate the input markup, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The document specifies a grammar and the parser reports markup errors based on it. The grammar can be a DTD or schema.0(false) — If the document specifies a grammar, the parser parses it, but does not validate the input against it.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to use a document type definition (DTD) to validate inputs, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parser uses the specified DTD only to resolve entity references but does not validate inputs.0(false) — The parser uses the specified DTD to resolve entity references. If theValidateproperty value istrue, the parser also uses the DTD to validate inputs.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to include input comments in the parser output, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parser includes input comments in the output document.0(false) — The parser does not include input comments in the output document.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to process XInclude declarations in the input XML, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parser includes nodes specified by XInclude declarations in the output document tree.0(false) — The parser does not include nodes specified by XInclude declarations in the output document tree
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
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.
Specify both the path and namespace of the schema. For example, to validate a
document located in https://www.location.com with a namespace of
Namespace.xsd,
enter:
schemaFile = "https://www.location.com Namespace.xsd";
parser.Configuration.ExternalSchemaLocation=schemaFile;
The parser generates an error if the URI specifies a remote location.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
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 generates an error if the URI specifies a remote location.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Whether to load a schema, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — If theSchemaproperty value is alsotrue, the parser loads the schema specified by the input XML markup.0(false) — The parser does not load the schema specified by the input XML markup.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to use schema-based markup validation, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — If theNamespaceproperty is alsotrue, the parser validates the XML markup based on a schema.0(false) — The parser does not use a schema to validate the XML markup.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether validation requires a schema, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — If theValidateproperty is alsotrue, validation occurs only if the input XML specifies a schema.0(false) — If theValidateproperty is alsotrue, validation occurs if the input XML specifies either a DTD or a schema.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to enable full schema constraint checking, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parser checks the schema for particle-unique attribution constraint errors and particle derivation restriction constraint errors.Note
Checking for these errors is time-consuming and memory-intensive.
0(false) — The parser does not run a full schema constraint check.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to normalize white space in the XML input, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — If validation is enabled and the input XML specifies a schema, the parser normalizes white space in element and attribute values by using the white space normalization options defined in the schema for each attribute and element data type.0(false) — The schema normalizes only the attribute values defined in the XML 1.0 standard.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to ignore annotations in the schema markup, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parser ignores the annotations when parsing a schema.0(false) — The parser converts annotation declarations to annotation nodes in the schema output.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to validate annotations, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parser validates annotations. The parser validates each annotating independently.0(false) — The parser does not validate annotations.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to generate synthetic annotations, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parser generates synthetic annotations when a schema component has non-schema attributes but no child annotation.0(false) — The parser does not generate synthetic annotations.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to cache parsed schema, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parser caches the schema grammar for reuse in subsequent parses. The parser uses the cached grammar regardless of the value of theUseCachedGrammarInParseproperty.0(false) — The parser loads and caches the schema grammar every parse.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to use a cached grammar, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parser uses a cached schema grammar, if it exists.0(false) — The parser parses the schema.
Note
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 |
Data Types: logical
Whether to allow multiple schemas, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parser can import multiple schemas with the same namespace during schema validation.0(false) — The parser generates an error if a namespace has multiple schemas.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to save post-schema-validation information (PSVI), specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parser saves PSVI.0(false) — The parser does not save PSVI.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Whether to check identity constraints, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The parser checks the identity constraints specified by the schema associated with a document.0(false) — The parser does not check the identity constraints.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
Object that resolves entities referenced by a document, specified as an object of a
subclass of the matlab.io.xml.dom.EntityResolver class. 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, then the parser uses a default error
handler. The default error handler terminates parsing at the first parse error and
returns a MATLAB error. If you want the parser to continue parsing after encountering a
markup error when feasible, 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
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);
Version History
Introduced in R2021a
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)