oracle.xml.parser.schema
Class XSDValidator

oracle.xml.parser.schema.XSDValidator

public class XSDValidator

XSDValidator validates an instance XML document against an XMLSchema. When registered an XSDValidator object is inserted as a pipe-line node between XMLParser and XMLDocument events handler (SAXHandler or DOMBuilder). It works with three events: startElement, characters and endElement. If defined, default element and default attribute values are added to the events contents (as XMLSchema additions to infoset) and are propagated up. As far as XSDValidator is concerned the XMLSchema object is a set/group of element declaratioms whith following structure: [element(name)] -> [shode(min/maxOccurs)] -> [type(group/simpleType)] XSDValidator is implemented as stack based state machine. Each state represents element type - group or simpleType. XMLSchema object(as a group) is loaded as a first state. Current element(event startElement) is matched against current state group elements. If matched the element type element name and snode info are loaded as new state. In a case of group a vector of counters(int) is allocated in a parallel stack. This vector is used to count element occurances. State status could be: - NEW_STATE: just loaded and not tryed. - ACCEPTED: minOccurs satisfied. Could still accept element occurances. - DONE: maxOccurs satisfied. Doesn't accept element occurances. Text element contents(event characters) is matched against simpleType (method validateValue). End element (event endElement) is matched against last named state. XMLSchema attributes are represented as a group (attrName -> attrType) forming the contents of special element: <_attrTag> attrType ... SMLParser converts attributes (event startElement) accordingly. (see method startElement) XSDAny objects are used as Namespace frame descriptors (see XMLSchema definition of 'any' element). Fake states are loaded in a case of error or when wildcard('any') contents is skipped.


Constructor Summary
XSDValidator()
          XSDValidator constructor.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Propagate notification of character data inside an element.
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
          Receive notification of the end of an element.
protected  boolean pushState(XSDNode nd, java.lang.String tag, java.lang.String xsiType)
          pushState *********************
 void reset()
          Reset the validator, prepare for next validation
protected  java.lang.String resolve(java.lang.String prefix)
           
 void setDocumentLocator(Locator locator)
          Propagates Locator object for document events.
 void setError(XMLError he)
          Sets an XMLError object as current err.
 void setXMLProperties(oracle.xml.util.XMLProperties xmlProp)
          Set XML Properties for runtime proerties
 java.lang.Object setXMLProperty(java.lang.String name, java.lang.Object value)
          Set a property.
 void setXMLSchema(XMLSchema s)
          Deprecated.  
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, Attributes atts)
          Receive notification of the beginning of an element.
 

Constructor Detail

XSDValidator

public XSDValidator()
             throws XSDException
XSDValidator constructor.
Method Detail

reset

public void reset()
Reset the validator, prepare for next validation

setError

public void setError(XMLError he)
              throws SAXException
Sets an XMLError object as current err.
Parameters:
he - XMLError object
Throws:
SAXException - A SAXException could be thrown.

setXMLProperties

public void setXMLProperties(oracle.xml.util.XMLProperties xmlProp)
Set XML Properties for runtime proerties
Parameters:
xmlProp - XMLProperties

setXMLSchema

public void setXMLSchema(XMLSchema s)
                  throws SAXException
Deprecated.  

Sets an XMLSchema object as current schema.
Parameters:
s - XMLSchema object
Throws:
SAXException - A SAXException could be thrown.

setXMLProperty

public java.lang.Object setXMLProperty(java.lang.String name,
                                       java.lang.Object value)
Set a property. The value of the property set is returned if successfully set, a null is returned if the property is read-only and cannot be set or is not supported.
Parameters:
name - - name of the property
value - - value of the property
Returns:
Object - the set property

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         Attributes atts)
                  throws SAXException
Receive notification of the beginning of an element.
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
localName - The local name(without prefix), or the empty string if Namespace processing is not being performed.
qName - The qualified name (with prefix), or the empty string if qualified names are not available.
atts - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
endElement(java.lang.String, java.lang.String, java.lang.String), Attributes

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qName)
                throws SAXException
Receive notification of the end of an element.
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
qName - The qualified XML 1.0 name (with prefix), or the empty string if qualified names are not available.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Propagate notification of character data inside an element.
Parameters:
ch - The characters.
start - The start position in the character array.
length - The number of characters to use from the character array.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
DocumentHandler.characters(char[], int, int)

setDocumentLocator

public void setDocumentLocator(Locator locator)
Propagates Locator object for document events.
Parameters:
locator - A locator for all SAX document events.
See Also:
DocumentHandler.setDocumentLocator(org.xml.sax.Locator), Locator

pushState

protected boolean pushState(XSDNode nd,
                            java.lang.String tag,
                            java.lang.String xsiType)
pushState *********************

resolve

protected java.lang.String resolve(java.lang.String prefix)


 

Copyright © 1997, 2004, Oracle. All rights reserved.