java.io.Serializable
, Cloneable
public static class ParseConfiguration.PrologParseConfiguration
extends Object
implements java.io.Serializable, Cloneable
Class encapsulating the configuration parameters used for parsing and validating the "prolog" section of a markup document. The prolog is the section of an XML/HTML document containing the XML declaration and the DOCTYPE clause (if these exist).
If validateProlog is set to false, all other parameters should be ignored.
If validateProlog is true, then the rest of the parameters will be considered.
Not all combinations of values of the getPrologPresence()
,
getXmlDeclarationPresence()
and getDoctypePresence()
are considered valid. See validateConfiguration()
for details.
Modifier | Constructor | Description |
---|---|---|
protected |
PrologParseConfiguration() |
Creates a
ParseConfiguration.PrologParseConfiguration instance with
a default configuration. |
Modifier and Type | Method | Description |
---|---|---|
ParseConfiguration.PrologParseConfiguration |
clone() |
|
ParseConfiguration.PrologPresence |
getDoctypePresence() |
This flag indicates the level of presence desired for the DOCTYPE clause
(a part of the prolog) in the document, in case
isValidateProlog()
has been set to true. |
ParseConfiguration.PrologPresence |
getPrologPresence() |
This flag indicates the level of presence desired for the prolog
in the document, in case
isValidateProlog() has been set
to true. |
ParseConfiguration.PrologPresence |
getXmlDeclarationPresence() |
This flag indicates the level of presence desired for the XML Declaration
(a part of the prolog) in the document, in case
isValidateProlog()
has been set to true. |
boolean |
isRequireDoctypeKeywordsUpperCase() |
This configuration parameter allows to check that all keywords in
a DOCTYPE clause ('DOCTYPE', 'SYSTEM', 'PUBLIC') are in upper-case as
required by the XML specification (and not by the HTML5 one, for example).
|
boolean |
isValidateProlog() |
This flag indicates whether the document's prolog should be validated
at all or not.
|
void |
setDoctypePresence(ParseConfiguration.PrologPresence doctypePresence) |
|
void |
setPrologPresence(ParseConfiguration.PrologPresence prologPresence) |
|
void |
setRequireDoctypeKeywordsUpperCase(boolean requireDoctypeKeywordsUpperCase) |
|
void |
setValidateProlog(boolean validateProlog) |
|
void |
setXmlDeclarationPresence(ParseConfiguration.PrologPresence xmlDeclarationPresence) |
|
void |
validateConfiguration() |
Checks that the combination of values in the
getPrologPresence() ,
getXmlDeclarationPresence() and getDoctypePresence()
parameters makes sense. |
protected PrologParseConfiguration()
Creates a ParseConfiguration.PrologParseConfiguration
instance with
a default configuration.
Default values are:
public boolean isValidateProlog()
This flag indicates whether the document's prolog should be validated at all or not.
If not validated, prolog-specific structures (XML Declaration and DOCTYPE) will be allowed to appear anywhere in the document. All other configuration paramters in this object will be ignored.
If validated, prolog-specific structures will only be allowed to
appear (under the conditions established in this object) at the
beginning of the document, before the element root. Or if
getPrologPresence()
is set to ParseConfiguration.PrologPresence.FORBIDDEN
,
it will be validated that such structures do not appear at all.
Also, if validated and a DOCTYPE is present, it will be checked that there is only one root element in the document and its name matches the root element name in the DOCTYPE clause.
Default value is false.
public void setValidateProlog(boolean validateProlog)
public ParseConfiguration.PrologPresence getPrologPresence()
This flag indicates the level of presence desired for the prolog
in the document, in case isValidateProlog()
has been set
to true.
public void setPrologPresence(ParseConfiguration.PrologPresence prologPresence)
public ParseConfiguration.PrologPresence getXmlDeclarationPresence()
This flag indicates the level of presence desired for the XML Declaration
(a part of the prolog) in the document, in case isValidateProlog()
has been set to true.
public void setXmlDeclarationPresence(ParseConfiguration.PrologPresence xmlDeclarationPresence)
public ParseConfiguration.PrologPresence getDoctypePresence()
This flag indicates the level of presence desired for the DOCTYPE clause
(a part of the prolog) in the document, in case isValidateProlog()
has been set to true.
public void setDoctypePresence(ParseConfiguration.PrologPresence doctypePresence)
public boolean isRequireDoctypeKeywordsUpperCase()
This configuration parameter allows to check that all keywords in a DOCTYPE clause ('DOCTYPE', 'SYSTEM', 'PUBLIC') are in upper-case as required by the XML specification (and not by the HTML5 one, for example).
Default value is true, but it will apply only if
isValidateProlog()
is true.
public void setRequireDoctypeKeywordsUpperCase(boolean requireDoctypeKeywordsUpperCase)
public void validateConfiguration()
Checks that the combination of values in the getPrologPresence()
,
getXmlDeclarationPresence()
and getDoctypePresence()
parameters makes sense.
getPrologPresence()
is ParseConfiguration.PrologPresence.FORBIDDEN
, then
getXmlDeclarationPresence()
and getDoctypePresence()
must
be ParseConfiguration.PrologPresence.FORBIDDEN
too.getXmlDeclarationPresence()
or
getDoctypePresence()
is ParseConfiguration.PrologPresence.REQUIRED
, the
configuration is considered valid.getPrologPresence()
is ParseConfiguration.PrologPresence.ALLOWED
,
the configuration is considered valid as long as not both
getXmlDeclarationPresence()
and getDoctypePresence()
are ParseConfiguration.PrologPresence.FORBIDDEN
.IllegalArgumentException
- if the combination of values is not correct.public ParseConfiguration.PrologParseConfiguration clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
Copyright © 2018 The ATTOPARSER team. All rights reserved.