com.ctc.wstx.sr
public final class InputElementStack extends java.lang.Object implements AttributeInfo, javax.xml.namespace.NamespaceContext, ValidationContext
This class also implements NamespaceContext
, since it has all
the information necessary, so parser can just return element stack
instance as necesary.
Modifier and Type | Field and Description |
---|---|
protected AttributeCollector |
mAttrCollector |
protected ReaderConfig |
mConfig |
protected com.ctc.wstx.sr.Element |
mCurrElement
Currently open element, if any; null outside root element.
|
protected int |
mDepth |
protected com.ctc.wstx.sr.Element |
mFreeElement |
protected int |
mIdAttrIndex
Index of the attribute with type of ID, if known (most likely
due to Xml:id support); -1 if not available, or no ID attribute
for current element.
|
protected java.lang.String |
mLastLocalName |
protected javax.xml.namespace.QName |
mLastName |
protected BaseNsContext |
mLastNsContext
Last potentially shareable NamespaceContext created by
this stack.
|
protected java.lang.String |
mLastNsURI |
protected java.lang.String |
mLastPrefix |
protected boolean |
mMayHaveNsDefaults |
protected StringVector |
mNamespaces
Vector that contains all currently active namespaces; one String for
prefix, another for matching URI.
|
protected boolean |
mNsAware |
protected NsDefaultProvider |
mNsDefaultProvider
Object that will need to be consulted about namespace bindings,
since it has some knowledge about default namespace declarations
(has default attribute value expansion).
|
protected InputProblemReporter |
mReporter |
protected long |
mTotalElements |
protected XMLValidator |
mValidator
Optional validator object that will get called if set,
and that can validate xml content.
|
Modifier | Constructor and Description |
---|---|
protected |
InputElementStack(ReaderConfig cfg,
boolean nsAware) |
Modifier and Type | Method and Description |
---|---|
int |
addDefaultAttribute(java.lang.String localName,
java.lang.String uri,
java.lang.String prefix,
java.lang.String value)
Method called by actual validator instances when attributes with
default values have no explicit values for the element; if so,
default value needs to be added as if it was parsed from the
element.
|
void |
addNsBinding(java.lang.String prefix,
java.lang.String uri)
Callback method called by the namespace default provider.
|
protected XMLValidator |
addValidator(XMLValidator vld) |
protected void |
connectReporter(InputProblemReporter rep) |
BaseNsContext |
createNonTransientNsContext(javax.xml.stream.Location loc)
Method called to construct a non-transient NamespaceContext instance;
generally needed when creating events to return from event-based
iterators.
|
int |
findAttributeIndex(java.lang.String nsURI,
java.lang.String localName) |
AttributeCollector |
getAttrCollector()
Method called by
BasicStreamReader , to retrieve the
attribute collector it needs for some direct access. |
int |
getAttributeCount()
This method returns number of attributes accessible from within
currently active start element.
|
java.lang.String |
getAttributeLocalName(int index) |
java.lang.String |
getAttributeNamespace(int index) |
java.lang.String |
getAttributePrefix(int index) |
java.lang.String |
getAttributeType(int index) |
java.lang.String |
getAttributeValue(int index) |
java.lang.String |
getAttributeValue(java.lang.String nsURI,
java.lang.String localName) |
java.lang.String |
getBaseUri() |
javax.xml.namespace.QName |
getCurrentElementName()
Method that can be used to access name information of the
innermost (top) element in the element stack.
|
int |
getCurrentNsCount() |
java.lang.String |
getDefaultNsURI() |
int |
getDepth() |
int |
getIdAttributeIndex()
Default implementation just indicates it does not know of such
attributes; this because that requires DTD information that only
some implementations have.
|
java.lang.String |
getLocalName() |
java.lang.String |
getLocalNsPrefix(int index) |
java.lang.String |
getLocalNsURI(int index) |
java.lang.String |
getNamespaceURI(java.lang.String prefix)
Method that can be called by the validator to resolve a namespace
prefix of the currently active top-level element.
|
int |
getNotationAttributeIndex()
Default implementation just indicates it does not know of such
attributes; this because that requires DTD information that only
some implementations have.
|
java.lang.String |
getNsURI() |
java.lang.String |
getPrefix() |
java.lang.String |
getPrefix(java.lang.String nsURI) |
java.util.Iterator |
getPrefixes(java.lang.String nsURI) |
java.lang.String |
getTopElementDesc() |
int |
getTotalNsCount() |
javax.xml.stream.Location |
getValidationLocation()
Method that will return the location that best represents current
location within document to be validated, if such information
is available.
|
java.lang.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 |
isEmpty() |
boolean |
isNamespaceAware() |
boolean |
isNotationDeclared(java.lang.String name) |
boolean |
isPrefixLocallyDeclared(java.lang.String internedPrefix) |
boolean |
isUnparsedEntityDeclared(java.lang.String name) |
boolean |
matches(java.lang.String prefix,
java.lang.String localName) |
boolean |
pop()
Method called by the stream reader to remove the topmost (start)
element from the stack;
called when an end element is encountered during parsing.
|
void |
push(java.lang.String prefix,
java.lang.String localName)
Method called by the stream reader to add new (start) element
into the stack in namespace-aware mode; called when a start element
is encountered during parsing, but only in ns-aware mode.
|
protected boolean |
reallyValidating()
This is a method called by the reader to ensure that we have at
least one 'real' validator.
|
void |
reportProblem(XMLValidationProblem problem)
Method called by the validator, upon encountering a validation
problem.
|
int |
resolveAndValidateElement()
Method called to resolve element and attribute namespaces (in
namespace-aware mode), and do optional validation using pluggable
validator object.
|
protected void |
setAutomaticDTDValidator(XMLValidator validator,
NsDefaultProvider nsDefs)
Method called to connect the automatically handled DTD validator
(one detected from DOCTYPE, loaded and completely handled by
the stream reader without application calling validation methods).
|
XMLValidator |
stopValidatingAgainst(XMLValidationSchema schema) |
XMLValidator |
stopValidatingAgainst(XMLValidator validator) |
XMLValidator |
validateAgainst(XMLValidationSchema schema) |
int |
validateEndElement()
Method called after parsing (but before returning) end element,
to allow for pluggable validators to verify correctness of
the content model for the closing element.
|
void |
validateText(java.lang.String contents,
boolean lastTextSegment) |
void |
validateText(TextBuffer tb,
boolean lastTextSegment) |
protected final boolean mNsAware
protected final AttributeCollector mAttrCollector
protected final ReaderConfig mConfig
protected InputProblemReporter mReporter
protected NsDefaultProvider mNsDefaultProvider
protected int mDepth
protected long mTotalElements
protected final StringVector mNamespaces
protected com.ctc.wstx.sr.Element mCurrElement
protected boolean mMayHaveNsDefaults
protected XMLValidator mValidator
protected int mIdAttrIndex
protected java.lang.String mLastLocalName
protected java.lang.String mLastPrefix
protected java.lang.String mLastNsURI
protected javax.xml.namespace.QName mLastName
protected BaseNsContext mLastNsContext
protected com.ctc.wstx.sr.Element mFreeElement
protected InputElementStack(ReaderConfig cfg, boolean nsAware)
protected void connectReporter(InputProblemReporter rep)
protected XMLValidator addValidator(XMLValidator vld)
protected void setAutomaticDTDValidator(XMLValidator validator, NsDefaultProvider nsDefs)
public XMLValidator validateAgainst(XMLValidationSchema schema) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public XMLValidator stopValidatingAgainst(XMLValidationSchema schema) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public XMLValidator stopValidatingAgainst(XMLValidator validator) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected boolean reallyValidating()
DTDValidatorBase
or returns true for
reallyValidating
.
!!! TODO: remove need for this method (and method itself) with Woodstox 4.0, by adding necessary support in Stax2 XMLValidator interface.
public final AttributeCollector getAttrCollector()
BasicStreamReader
, to retrieve the
attribute collector it needs for some direct access.public BaseNsContext createNonTransientNsContext(javax.xml.stream.Location loc)
public final void push(java.lang.String prefix, java.lang.String localName) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public final boolean pop() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public int resolveAndValidateElement() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public int validateEndElement() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public final int getAttributeCount()
ValidationContext
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.
getAttributeCount
in interface AttributeInfo
getAttributeCount
in interface ValidationContext
public final int findAttributeIndex(java.lang.String nsURI, java.lang.String localName)
findAttributeIndex
in interface AttributeInfo
findAttributeIndex
in interface ValidationContext
public final int getIdAttributeIndex()
getIdAttributeIndex
in interface AttributeInfo
public final int getNotationAttributeIndex()
getNotationAttributeIndex
in interface AttributeInfo
public final java.lang.String getNamespaceURI(java.lang.String prefix)
ValidationContext
getNamespaceURI
in interface javax.xml.namespace.NamespaceContext
getNamespaceURI
in interface ValidationContext
public final java.lang.String getPrefix(java.lang.String nsURI)
getPrefix
in interface javax.xml.namespace.NamespaceContext
public final java.util.Iterator getPrefixes(java.lang.String nsURI)
getPrefixes
in interface javax.xml.namespace.NamespaceContext
public final java.lang.String getXmlVersion()
ValidationContext
getXmlVersion
in interface ValidationContext
public java.lang.String getAttributeLocalName(int index)
getAttributeLocalName
in interface ValidationContext
public java.lang.String getAttributeNamespace(int index)
getAttributeNamespace
in interface ValidationContext
public java.lang.String getAttributePrefix(int index)
getAttributePrefix
in interface ValidationContext
public java.lang.String getAttributeValue(int index)
getAttributeValue
in interface ValidationContext
public java.lang.String getAttributeValue(java.lang.String nsURI, java.lang.String localName)
getAttributeValue
in interface ValidationContext
public boolean isNotationDeclared(java.lang.String name)
isNotationDeclared
in interface ValidationContext
public boolean isUnparsedEntityDeclared(java.lang.String name)
isUnparsedEntityDeclared
in interface ValidationContext
public java.lang.String getBaseUri()
getBaseUri
in interface ValidationContext
public final javax.xml.namespace.QName getCurrentElementName()
ValidationContext
getCurrentElementName
in interface ValidationContext
public javax.xml.stream.Location getValidationLocation()
ValidationContext
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.
getValidationLocation
in interface ValidationContext
public void reportProblem(XMLValidationProblem problem) throws javax.xml.stream.XMLStreamException
ValidationContext
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
.
reportProblem
in interface ValidationContext
javax.xml.stream.XMLStreamException
public int addDefaultAttribute(java.lang.String localName, java.lang.String uri, java.lang.String prefix, java.lang.String value) throws javax.xml.stream.XMLStreamException
addDefaultAttribute
in interface ValidationContext
javax.xml.stream.XMLStreamException
public boolean isPrefixLocallyDeclared(java.lang.String internedPrefix)
public void addNsBinding(java.lang.String prefix, java.lang.String uri)
public final void validateText(TextBuffer tb, boolean lastTextSegment) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public final void validateText(java.lang.String contents, boolean lastTextSegment) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public final boolean isNamespaceAware()
public final boolean isEmpty()
public final int getDepth()
public final java.lang.String getDefaultNsURI()
public final java.lang.String getNsURI()
public final java.lang.String getPrefix()
public final java.lang.String getLocalName()
public final boolean matches(java.lang.String prefix, java.lang.String localName)
public final java.lang.String getTopElementDesc()
public final int getTotalNsCount()
public final int getCurrentNsCount()
public final java.lang.String getLocalNsPrefix(int index)
public final java.lang.String getLocalNsURI(int index)
public final java.lang.String getAttributeType(int index)
getAttributeType
in interface ValidationContext