org.apache.xmlbeans.impl.validator
public class: ValidatingXMLStreamReader [javadoc |
source]
java.lang.Object
javax.xml.stream.util.StreamReaderDelegate
org.apache.xmlbeans.impl.validator.ValidatingXMLStreamReader
All Implemented Interfaces:
XMLStreamReader
Direct Known Subclasses:
ValidatingInfoXMLStreamReader
This class is a wrapper over a generic XMLStreamReader that provides validation.
There are 3 cases:
1) the XMLStreamReader represents a document, it contains only one element document
- in this case the user schema type should be null or it should be a document SchemaType
2) the XMLStreamReader represents an xml-fragment (content only) - must have at least one user type or xsi:type
a) it has an xsi:type - if user schema type is available it has to be a base type of xsi:type
b) it doesn't have xsi:type - user must provide a schema type
otherwise will error and will not do validation
3) the XMLStreamReader represents a global attribute - i.e. user schema type is null and only one attribute
- author:
Cezar - Andrei (cezar.andrei at bea.com)
Date: Feb 13, 2004
| Field Summary |
|---|
| protected Validator | _validator | |
| Methods from javax.xml.stream.util.StreamReaderDelegate: |
|---|
|
close, getAttributeCount, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getElementText, getEncoding, getEventType, getLocalName, getLocation, getName, getNamespaceContext, getNamespaceCount, getNamespacePrefix, getNamespaceURI, getNamespaceURI, getNamespaceURI, getPIData, getPITarget, getParent, getPrefix, getProperty, getText, getTextCharacters, getTextCharacters, getTextLength, getTextStart, getVersion, hasName, hasNext, hasText, isAttributeSpecified, isCharacters, isEndElement, isStandalone, isStartElement, isWhiteSpace, next, nextTag, require, setParent, standaloneSet |
| Method from org.apache.xmlbeans.impl.validator.ValidatingXMLStreamReader Detail: |
public Object getProperty(String s) throws IllegalArgumentException {
return super.getProperty(s);
}
|
public void init(XMLStreamReader xsr,
boolean startWithCurrentEvent,
SchemaType contentType,
SchemaTypeLoader stl,
XmlOptions options,
Collection errorListener) {
_packTextXmlStreamReader.init(xsr);
// setParent(xsr);
setParent(_packTextXmlStreamReader);
_contentType = contentType;
_stl = stl;
_options = options;
_errorListener = errorListener;
// _elemEvent.setXMLStreamReader(xsr);
// _attEvent.setXMLStreamReader(xsr);
// _simpleEvent.setXMLStreamReader(xsr);
_elemEvent.setXMLStreamReader(_packTextXmlStreamReader);
_attEvent.setXMLStreamReader(_packTextXmlStreamReader);
_simpleEvent.setXMLStreamReader(_packTextXmlStreamReader);
_validator = null;
_state = STATE_FIRSTEVENT;
if (_attNamesList!=null)
{
_attNamesList.clear();
_attValuesList.clear();
}
_xsiType = null;
_depth = 0;
if (startWithCurrentEvent)
{
int evType = getEventType();
validate_event(evType);
}
}
Used in case of reusing the same ValidatinXMLStreamReader object |
public boolean isValid() {
if ( _state==STATE_ERROR || _validator==null)
return false;
return _validator.isValid();
}
|
public int next() throws XMLStreamException {
int evType = super.next();
// debugEvent(evType);
validate_event(evType);
return evType;
}
|
protected void validate_attribute(int attIndex) {
ValidatorListener.Event event;
if (_attNamesList==null)
{
_attEvent.setAttributeIndex(attIndex);
QName qn = _attEvent.getName();
if (isSpecialAttribute(qn))
return;
event = _attEvent;
}
else
{
_simpleEvent._qname = (QName)_attNamesList.get(attIndex);
_simpleEvent._text = (String)_attValuesList.get(attIndex);
event = _simpleEvent;
}
_validator.nextEvent(Validator.ATTR, event);
}
|
protected void validate_attributes(int attCount) {
for(int i=0; i< attCount; i++)
{
validate_attribute(i);
}
}
|