Free Trial - Stylus Studio, The World's Best XML IDE!


com.saxonica.importer
Class ComponentReader

java.lang.Object
  |
  +--com.saxonica.importer.ComponentReader
Direct Known Subclasses:
AnnotationUnmarshaller, AttributeGroupUnmarshaller, AttributeUnmarshaller, ComplexContentRestrictionUnmarshaller, ComplexContentUnmarshaller, ComplexTypeUnmarshaller, CompositorUnmarshaller, ElementUnmarshaller, ExtensionUnmarshaller, FacetUnmarshaller, FieldOrSelectorUnmarshaller, GroupUnmarshaller, IdentityConstraintUnmarshaller, ImportUnmarshaller, IncludeUnmarshaller, ListUnmarshaller, RedefineUnmarshaller, SchemaUnmarshaller, SimpleContentRestrictionUnmarshaller, SimpleContentUnmarshaller, SimpleTypeRestrictionUnmarshaller, SimpleTypeUnmarshaller, UnionUnmarshaller, UnknownUnmarshaller, WildcardUnmarshaller

public abstract class ComponentReader
extends java.lang.Object

The base class for separate component unmarshallers for reading an XML Schema component.


Field Summary
static int REQUIRE_NULL_NS
          Option indicating "no namespace prefix is allowed; the name is in the null Namespace"
static int REQUIRE_TARGET_NS
          Option indicating "no namespace prefix is allowed; the name is in the targetNamespace"
protected  com.saxonica.importer.UnmarshallerState state
          Unmarshaller state.
static int USE_DEFAULT_NS
          Option indicating "use the default element namespace when unprefixed"
static int USE_NO_NAMESPACE
          Option indicating "use no namespace when unprefixed"
static int USE_TARGET_NS
          Option indicating "use the target namespace when unprefixed"
 
Constructor Summary
ComponentReader(com.saxonica.importer.UnmarshallerState state)
           
 
Method Summary
 void allowAttributes(org.xml.sax.Attributes atts, java.lang.String[] allowed)
          Check the attributes of an element against a list of allowed attributes.
 void characters(char[] chars, int start, int length)
          Signals to receive characters
 void duplicate(java.lang.String category, java.lang.String name)
          This method is called when two objects in the same symbol space within a schema have duplicate names
 void duplicateElement(java.lang.String name)
          This method is called when two occurrences of a child element are found and only one is allowed.
abstract  java.lang.String elementName()
          Returns the name of the element that this ComponentReader handles
 void endElement(java.lang.String name, java.lang.String namespace)
          Signals to end of the element with the given name.
 void error(java.lang.String err)
          This method is called for a general error.
 void finish()
          Called to signal an end of unmarshalling.
protected  int getFingerprint(Schema schema, java.lang.String name, int option)
          This method is called to check that a QName is valid and allocate a fingerprint for the name in the namePool.
 NamePool getNamePool()
          Get the NamePool
abstract  java.lang.Object getObject()
          Returns the Object created by this Unmarshaller
 void illegalElement(java.lang.String name)
          This method is called when an illegal Element is encountered.
 java.lang.String indefiniteArticle(java.lang.String word, java.lang.String start)
          Construct an indefinite article in English
 void invalidAttributeValue(java.lang.String name, java.lang.String value, java.lang.String message)
          This method is called when an invalid attribute value is found
 void missingAttribute(java.lang.String name)
          This method is called when a required attribute is not found
 void missingChildElement(java.lang.String name)
          This method is called when a required child element is not found
 void mustBeFirstElement(java.lang.String name)
          This method is called when a child element is required to be the first child, but is found elsewhere
 void mustBeLastElement(java.lang.String name)
          This method is called when a child element is required to be the first child, but is found elsewhere
 void mustPrecede(java.lang.String name1, java.lang.String name2)
          This method is called when two child elements are found in the wrong order.
 void mutuallyExclusive(java.lang.String name1, java.lang.String name2)
          This method is called when two child elements may not coexist
 void mutuallyExclusiveAttributes(java.lang.String name1, java.lang.String name2)
          This method is called when two attributes may not coexist
 void mutuallyExclusiveElementAndAttribute(java.lang.String elem, java.lang.String att)
          This method is called when an attribute and a child elements may not coexist
 int parseFinalOrBlock(java.lang.String attrName, java.lang.String finalValue, int allowed)
          Parse a list of blocked or final derivations.
 void requireAttribute(org.xml.sax.Attributes atts, java.lang.String required)
          Indicate that a particular attribute is required
 void setDocumentLocator(org.xml.sax.Locator locator)
           
 void setNamespaceContext(SchemaNamespaceContext nsContext)
          Set the namespace context.
 void startElement(java.lang.String name, java.lang.String namespace, org.xml.sax.Attributes atts, SchemaNamespaceContext nsDecls)
          Signals the start of an element with the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USE_DEFAULT_NS

public static final int USE_DEFAULT_NS
Option indicating "use the default element namespace when unprefixed"

See Also:
Constant Field Values

USE_TARGET_NS

public static final int USE_TARGET_NS
Option indicating "use the target namespace when unprefixed"

See Also:
Constant Field Values

USE_NO_NAMESPACE

public static final int USE_NO_NAMESPACE
Option indicating "use no namespace when unprefixed"

See Also:
Constant Field Values

REQUIRE_TARGET_NS

public static final int REQUIRE_TARGET_NS
Option indicating "no namespace prefix is allowed; the name is in the targetNamespace"

See Also:
Constant Field Values

REQUIRE_NULL_NS

public static final int REQUIRE_NULL_NS
Option indicating "no namespace prefix is allowed; the name is in the null Namespace"

See Also:
Constant Field Values

state

protected com.saxonica.importer.UnmarshallerState state
Unmarshaller state. This contains information that is shared by all the unmarshallers in the pipeline, including the location information in the source schema, for diagnostics.

Constructor Detail

ComponentReader

public ComponentReader(com.saxonica.importer.UnmarshallerState state)
Method Detail

elementName

public abstract java.lang.String elementName()
Returns the name of the element that this ComponentReader handles

Returns:
the name of the element that this ComponentReader handles

getObject

public abstract java.lang.Object getObject()
Returns the Object created by this Unmarshaller

Returns:
the Object created by this Unmarshaller

finish

public void finish()
            throws SchemaException
Called to signal an end of unmarshalling. This method should be overridden to perform any necessary clean up by an unmarshaller

SchemaException

allowAttributes

public void allowAttributes(org.xml.sax.Attributes atts,
                            java.lang.String[] allowed)
                     throws SchemaException
Check the attributes of an element against a list of allowed attributes. Report an error if any extraneous attribute is present

Parameters:
atts - the attributes actually present
allowed - the attributes that are allowed for this element. Note that this list must be in alphabetical order.
SchemaException

requireAttribute

public void requireAttribute(org.xml.sax.Attributes atts,
                             java.lang.String required)
                      throws SchemaException
Indicate that a particular attribute is required

SchemaException

error

public void error(java.lang.String err)
           throws SchemaException
This method is called for a general error.

Parameters:
err - the error message to report
SchemaException

getNamePool

public NamePool getNamePool()
Get the NamePool


getFingerprint

protected int getFingerprint(Schema schema,
                             java.lang.String name,
                             int option)
                      throws SchemaException
This method is called to check that a QName is valid and allocate a fingerprint for the name in the namePool. If the QName isn't valid, the method throws an exception: it is the caller's responsibility to call the error handler and recover from the error. The method makes use of the namespace context information held in the unmarshaller state object.

Parameters:
schema - The Schema (used only to get the name pool)
name - The QName
option - The option for handling unprefixed names. Options are to use the default namespace, the target namespace, or the null namespace Note that this method assumes the name, if unprefixed, is in the default namespace: NOT the targetNamespace of the schema.
Returns:
a fingerprint
Throws:
SchemaException - if the QName is invalid.

illegalElement

public void illegalElement(java.lang.String name)
                    throws SchemaException
This method is called when an illegal Element is encountered.

Parameters:
name - the name of the illegal element
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

duplicateElement

public void duplicateElement(java.lang.String name)
                      throws SchemaException
This method is called when two occurrences of a child element are found and only one is allowed.

Parameters:
name - the name of the illegal element
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

duplicate

public void duplicate(java.lang.String category,
                      java.lang.String name)
               throws SchemaException
This method is called when two objects in the same symbol space within a schema have duplicate names

Parameters:
category - the name of the first attribute
name - the name of the second attribute
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

mutuallyExclusive

public void mutuallyExclusive(java.lang.String name1,
                              java.lang.String name2)
                       throws SchemaException
This method is called when two child elements may not coexist

Parameters:
name1 - the name of the first element
name2 - the name of the second element
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

mutuallyExclusiveElementAndAttribute

public void mutuallyExclusiveElementAndAttribute(java.lang.String elem,
                                                 java.lang.String att)
                                          throws SchemaException
This method is called when an attribute and a child elements may not coexist

Parameters:
elem - the name of the element
att - the name of the attribute
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

mutuallyExclusiveAttributes

public void mutuallyExclusiveAttributes(java.lang.String name1,
                                        java.lang.String name2)
                                 throws SchemaException
This method is called when two attributes may not coexist

Parameters:
name1 - the name of the first attribute
name2 - the name of the second attribute
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

mustPrecede

public void mustPrecede(java.lang.String name1,
                        java.lang.String name2)
                 throws SchemaException
This method is called when two child elements are found in the wrong order.

Parameters:
name1 - the name of the element that should be first
name2 - the name of the element that should be second
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

mustBeFirstElement

public void mustBeFirstElement(java.lang.String name)
                        throws SchemaException
This method is called when a child element is required to be the first child, but is found elsewhere

Parameters:
name - the name of the illegal element
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

indefiniteArticle

public java.lang.String indefiniteArticle(java.lang.String word,
                                          java.lang.String start)
Construct an indefinite article in English


mustBeLastElement

public void mustBeLastElement(java.lang.String name)
                       throws SchemaException
This method is called when a child element is required to be the first child, but is found elsewhere

Parameters:
name - the name of the illegal element
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

invalidAttributeValue

public void invalidAttributeValue(java.lang.String name,
                                  java.lang.String value,
                                  java.lang.String message)
                           throws SchemaException
This method is called when an invalid attribute value is found

Parameters:
name - the name of the attribute
value - the supplied value of the attribute
message - additional explanation of why it's wrong. May be null.
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

missingAttribute

public void missingAttribute(java.lang.String name)
                      throws SchemaException
This method is called when a required attribute is not found

Parameters:
name - the name of the attribute
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

missingChildElement

public void missingChildElement(java.lang.String name)
                         throws SchemaException
This method is called when a required child element is not found

Parameters:
name - the name of the required child element
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

setDocumentLocator

public final void setDocumentLocator(org.xml.sax.Locator locator)

setNamespaceContext

public final void setNamespaceContext(SchemaNamespaceContext nsContext)
Set the namespace context. This is called immediately before the startElement call. (Added by MHK)


characters

public void characters(char[] chars,
                       int start,
                       int length)
                throws SchemaException
Signals to receive characters

Parameters:
chars - the character array containing the characters
start - the starting index into the character array
length - the number of characters to recieve
SchemaException

endElement

public void endElement(java.lang.String name,
                       java.lang.String namespace)
                throws SchemaException
Signals to end of the element with the given name.

Parameters:
name - the NCName of the element. It is an error if the name is a QName (ie. contains a prefix).
namespace - the namespace of the element.
SchemaException

startElement

public void startElement(java.lang.String name,
                         java.lang.String namespace,
                         org.xml.sax.Attributes atts,
                         SchemaNamespaceContext nsDecls)
                  throws SchemaException
Signals the start of an element with the given name.

Parameters:
name - the NCName of the element. It is an error if the name is a QName (ie. contains a prefix).
namespace - the namespace of the element. This may be null. Note: A null namespace is not the same as the default namespace unless the default namespace is also null.
atts - the AttributeSet containing the attributes associated with the element.
nsDecls - the namespace declarations being declared for this element. This may be null.
SchemaException

parseFinalOrBlock

public int parseFinalOrBlock(java.lang.String attrName,
                             java.lang.String finalValue,
                             int allowed)
                      throws SchemaException
Parse a list of blocked or final derivations. Used to process the block, final, blockDefault, and finalDefault attributes.

Parameters:
finalValue - A list of values to be parsed, as a string, for example "extension restriction"
allowed - The permitted values, as a bit-significant integer. For example the value (DERIVE_BY_EXTENSION | DERIVE_BY_RESTRICTION) allows the values "extension" and "restriction" to appear.
Returns:
The final/blocked values, as a bit-significant integer
Throws:
SchemaException