public class XmlValidationModeDetector
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
DOCTYPE
The token in a XML document that declares the DTD to use for validation
and thus that DTD validation is being used.
|
private static java.lang.String |
END_COMMENT
The token that indicates the end of an XML comment.
|
private boolean |
inComment
Indicates whether or not the current parse position is inside an XML comment.
|
private static java.lang.String |
START_COMMENT
The token that indicates the start of an XML comment.
|
static int |
VALIDATION_AUTO
Indicates that the validation mode should be auto-guessed, since we cannot find
a clear indication (probably choked on some special characters, or the like).
|
static int |
VALIDATION_DTD
Indicates that DTD validation should be used (we found a "DOCTYPE" declaration).
|
static int |
VALIDATION_NONE
Indicates that the validation should be disabled.
|
static int |
VALIDATION_XSD
Indicates that XSD validation should be used (found no "DOCTYPE" declaration).
|
Constructor and Description |
---|
XmlValidationModeDetector() |
Modifier and Type | Method and Description |
---|---|
private int |
commentToken(java.lang.String line,
java.lang.String token,
boolean inCommentIfPresent)
Try to consume the supplied token against the supplied content and update the
in comment parse state to the supplied value.
|
private java.lang.String |
consume(java.lang.String line)
Consume the next comment token, update the "inComment" flag
and return the remaining content.
|
private java.lang.String |
consumeCommentTokens(java.lang.String line)
Consumes all the leading comment data in the given String and returns the remaining content, which
may be empty since the supplied content might be all comment data.
|
int |
detectValidationMode(java.io.InputStream inputStream)
Detect the validation mode for the XML document in the supplied
InputStream . |
private int |
endComment(java.lang.String line) |
private boolean |
hasDoctype(java.lang.String content)
Does the content contain the DTD DOCTYPE declaration?
|
private boolean |
hasOpeningTag(java.lang.String content)
Does the supplied content contain an XML opening tag.
|
private int |
startComment(java.lang.String line)
Try to consume the
START_COMMENT token. |
public static final int VALIDATION_NONE
public static final int VALIDATION_AUTO
public static final int VALIDATION_DTD
public static final int VALIDATION_XSD
private static final java.lang.String DOCTYPE
private static final java.lang.String START_COMMENT
private static final java.lang.String END_COMMENT
private boolean inComment
public int detectValidationMode(java.io.InputStream inputStream) throws java.io.IOException
InputStream
.
Note that the supplied InputStream
is closed by this method before returning.inputStream
- the InputStream to parsejava.io.IOException
- in case of I/O failureVALIDATION_DTD
,
VALIDATION_XSD
private boolean hasDoctype(java.lang.String content)
private boolean hasOpeningTag(java.lang.String content)
private java.lang.String consumeCommentTokens(java.lang.String line)
private java.lang.String consume(java.lang.String line)
private int startComment(java.lang.String line)
START_COMMENT
token.commentToken(String, String, boolean)
private int endComment(java.lang.String line)
private int commentToken(java.lang.String line, java.lang.String token, boolean inCommentIfPresent)