public interface ValidationContext
The functionality included is close to the minimal subset of functionality needed to support 3 main streamable schema languages (DTD, W3C Schema, Relax NG).
Modifier and Type | Method and Description |
---|---|
int |
addDefaultAttribute(String localName,
String uri,
String prefix,
String value)
An optional method that can be used to add a new attribute value for
an attribute
that was not yet contained by the container, as part of using attribute
default value mechanism.
|
int |
findAttributeIndex(String nsURI,
String localName) |
int |
getAttributeCount()
This method returns number of attributes accessible from within
currently active start element.
|
String |
getAttributeLocalName(int index) |
String |
getAttributeNamespace(int index) |
String |
getAttributePrefix(int index) |
String |
getAttributeType(int index) |
String |
getAttributeValue(int index) |
String |
getAttributeValue(String nsURI,
String localName) |
String |
getBaseUri() |
QName |
getCurrentElementName()
Method that can be used to access name information of the
innermost (top) element in the element stack.
|
String |
getNamespaceURI(String prefix)
Method that can be called by the validator to resolve a namespace
prefix of the currently active top-level element.
|
Location |
getValidationLocation()
Method that will return the location that best represents current
location within document to be validated, if such information
is available.
|
String |
getXmlVersion()
Method that validator can call to figure out which xml version
document being validated declared (if none, "1.0" is assumed as
per xml specifications 1.0 and 1.1).
|
boolean |
isNotationDeclared(String name) |
boolean |
isUnparsedEntityDeclared(String name) |
void |
reportProblem(XMLValidationProblem problem)
Method called by the validator, upon encountering a validation
problem.
|
String getXmlVersion()
QName getCurrentElementName()
String getNamespaceURI(String prefix)
int getAttributeCount()
Note: this method is only guaranteed to be callable during execution
of XMLValidator
methods
XMLValidator.validateElementStart(java.lang.String, java.lang.String, java.lang.String)
,
XMLValidator.validateAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
and
XMLValidator.validateElementAndAttributes()
. At other times
implementations may choose to allow it to be called (for example,
with information regarding last start element processed), to throw
a IllegalArgumentException
, or to return 0 to indicate no
attribute information is available.
Also note that whether defaulted attributes (attributes for which values are only available via attribute defaulting) are accessible depends on exact time when this method is called, and in general can not be assumed to function reliably.
String getAttributeLocalName(int index)
String getAttributeNamespace(int index)
String getAttributePrefix(int index)
String getAttributeValue(int index)
String getAttributeType(int index)
int findAttributeIndex(String nsURI, String localName)
boolean isNotationDeclared(String name)
boolean isUnparsedEntityDeclared(String name)
String getBaseUri()
Location getValidationLocation()
Note: it is likely that even when a location is known, it may not be very accurate; for example, when attributes are validated, it is possible that they all would point to a single location that may point to the start of the element that contains attributes.
void reportProblem(XMLValidationProblem problem) throws XMLStreamException
ValidationProblemHandler
be set by the application,
to define handling.
Note: Stax2 version 2 only allowed throwing instances
of XMLValidationProblem
; version 3 allows generic
base class to be thrown, to support other interfaces such
as basic Stax interface XMLReporter
.
XMLStreamException
int addDefaultAttribute(String localName, String uri, String prefix, String value) throws XMLStreamException
Note: caller has to ensure that the addition would not introduce a duplicate; attribute container implementation is not required to do any validation on attribute name (local name, prefix, uri) or value.
XMLStreamException
Copyright © 2015 fasterxml.com. All Rights Reserved.