matlab.io.xml.dom.ParserConfiguration Class
Namespace: matlab.io.xml.dom
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
Namespaces
— Whether to require a declared namespace for element name prefix
true
(default) | false
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 an undeclared prefix.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
LoadExternalDTD
— Whether to load an external DTD
true
(default) | false
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 |
DisableEntityResolution
— Whether to disable resolution of entity references
false
(default) | 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 |
AllowDoctype
— Document type definition (DTD) permissions
false
(default) | true
Document type definition (DTD) permissions, specified as true
or
false
, determines whether the XML file can contain a DTD. If the
specified file contains a DTD, a value of false
will result in an
error. Enable this option only for trusted sources.
Entities
— Whether to expand entity references in markup
true
(default) | false
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 §
with the content of sect.xml
in
the parsed document. Otherwise, the reference remains in the parsed document and is
serialized as §
.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
StandardURIConformant
— Whether to enforce URI conformity
false
(default) | 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 |
Validate
— Whether to validate input markup
false
(default) | 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 |
SkipDTDValidation
— Whether to skip DTD validation of input
false
(default) | 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 |
Comments
— Whether to include input comments in the parser output
true
(default) | false
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 |
DoXInclude
— Whether to process XInclude declarations
false
(default) | 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 |
ExternalSchemaLocation
— URI of external schema for validation of XML with namespaces
[]
(default) | character vector | string scalar
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 |
ExternalNoNamespaceSchemaLocation
— URI of external schema for validation of XML without namespaces
[]
(default) | character vector | string scalar
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 |
LoadSchema
— Whether to load a schema
true
(default) | false
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 |
Schema
— Whether to use schema-based markup validation
false
(default) | 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 |
ValidateIfSchema
— Whether validation requires a schema
false
(default) | 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 |
SchemaFullChecking
— Whether to enable full schema constraint checking
false
(default) | 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 |
DatatypeNormalization
— Whether to normalize white space in XML input
false
(default) | 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 |
IgnoreAnnotations
— Whether to ignore annotations in schema markup
false
(default) | 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 |
ValidateAnnotations
— Whether to validate annotations
false
(default) | 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 |
GenerateSyntheticAnnotations
— Whether to generate synthetic annotations
false
(default) | 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 |
CacheGrammarFromParse
— Whether to cache parsed schema
false
(default) | 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 |
UseCachedGrammarInParse
— Whether to use a cached grammar
false
(default) | 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 |
HandleMultipleImports
— Whether to allow multiple schemas
false
(default) | 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 |
HasPSVI
— Whether to save post-schema-validation information
false
(default) | 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 |
IdentityConstraintChecking
— Whether to check identity constraints
false
(default) | 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 |
EntityResolver
— Object that resolves entity references
[]
(default) | object of subclass of matlab.io.xml.dom.EntityResolver
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 |
ErrorHandler
— Object that handles parse errors
[]
(default) | object of subclass of matlab.io.xml.dom.ErrorHandler
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
Specify Parser Options
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)