com.saxonica.schema
Class SchemaModelLoader

java.lang.Object
  extended by net.sf.saxon.event.SequenceReceiver
      extended by net.sf.saxon.event.Sink
          extended by com.saxonica.schema.SchemaModelLoader
All Implemented Interfaces:
Result, Receiver

public class SchemaModelLoader
extends Sink

This class allows a schema model that was serialized using the SchemaModelSerializer to be loaded into memory. At present the data is accepted without validation.


Nested Class Summary
 class SchemaModelLoader.AlternativeTypeHandler
          Handle an alternative type for an element declaration
 class SchemaModelLoader.IdentityConstraintHandler
          Handle an identity constraint (key, keyref, unique)
 class SchemaModelLoader.SelectorHandler
          Handle a selector or field within an identity constraint (key, keyref, unique)
 class SchemaModelLoader.SubstitutionGroupAffiliationHandler
          Handle a substitution group affiliation
 
Field Summary
 
Fields inherited from class net.sf.saxon.event.SequenceReceiver
pipelineConfiguration, previousAtomic, systemId
 
Fields inherited from interface javax.xml.transform.Result
PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING
 
Constructor Summary
SchemaModelLoader(Configuration config)
          Create a schema model loader
 
Method Summary
 void attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties)
          Notify an attribute.
 void characters(CharSequence chars, int locationId, int properties)
          Character data
 void endElement()
          End of element
 PreparedSchema load(Source source)
          Load a schema from a serialized component model
static void main(String[] args)
          Test rig
 int parseFinalOrBlock(String attrName, String finalValue, int allowed)
          Parse a list of blocked or final derivations.
 void startContent()
          Notify the start of the content, that is, the completion of all attributes and namespaces.
 void startElement(int nameCode, int typeCode, int locationId, int properties)
          Notify the start of an element
 
Methods inherited from class net.sf.saxon.event.Sink
append, close, comment, endDocument, namespace, open, processingInstruction, setUnparsedEntity, startDocument, usesTypeAnnotations
 
Methods inherited from class net.sf.saxon.event.SequenceReceiver
getConfiguration, getNamePool, getPipelineConfiguration, getSystemId, setPipelineConfiguration, setSystemId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaModelLoader

public SchemaModelLoader(Configuration config)
Create a schema model loader

Parameters:
config - the Saxon configuration. This must be a schema-aware configuration. This SchemaModelLoader creates a PreparedSchema but does not directly load it into the Configuration cache; that is the job of the caller.
Throws:
IllegalArgumentException - if the configuration is not schema-aware
Method Detail

load

public PreparedSchema load(Source source)
                    throws XPathException
Load a schema from a serialized component model

Parameters:
source - the XML source of the serialized component model
Returns:
the corresponding PreparedSchema containing the deserialized schema components
Throws:
XPathException - if an error occurs

startElement

public void startElement(int nameCode,
                         int typeCode,
                         int locationId,
                         int properties)
                  throws XPathException
Notify the start of an element

Specified by:
startElement in interface Receiver
Overrides:
startElement in class Sink
Parameters:
nameCode - integer code identifying the name of the element within the name pool.
typeCode - integer code identifying the element's type within the name pool.
properties - for future use. Should be set to zero.
locationId - an integer which can be interpreted using a LocationProvider to return information such as line number and system ID. If no location information is available, the value zero is supplied.
Throws:
XPathException

startContent

public void startContent()
                  throws XPathException
Notify the start of the content, that is, the completion of all attributes and namespaces. Note that the initial receiver of output from XSLT instructions will not receive this event, it has to detect it itself. Note that this event is reported for every element even if it has no attributes, no namespaces, and no content.

Specified by:
startContent in interface Receiver
Overrides:
startContent in class Sink
Throws:
XPathException

attribute

public void attribute(int nameCode,
                      int typeCode,
                      CharSequence value,
                      int locationId,
                      int properties)
               throws XPathException
Notify an attribute. Attributes are notified after the startElement event, and before any children. Namespaces and attributes may be intermingled.

Specified by:
attribute in interface Receiver
Overrides:
attribute in class Sink
Parameters:
nameCode - The name of the attribute, as held in the name pool
typeCode - The type of the attribute, as held in the name pool
properties - Bit significant value. The following bits are defined:
DISABLE_ESCAPING
Disable escaping for this attribute
NO_SPECIAL_CHARACTERS
Attribute value contains no special characters
value - the string value of the attribute
locationId - an integer which can be interpreted using a LocationProvider to return information such as line number and system ID. If no location information is available, the value zero is supplied.
Throws:
IllegalStateException: - attempt to output an attribute when there is no open element start tag
XPathException

characters

public void characters(CharSequence chars,
                       int locationId,
                       int properties)
                throws XPathException
Character data

Specified by:
characters in interface Receiver
Overrides:
characters in class Sink
Parameters:
chars - The characters
locationId - an integer which can be interpreted using a LocationProvider to return information such as line number and system ID. If no location information is available, the value zero is supplied.
properties - Bit significant value. The following bits are defined:
DISABLE_ESCAPING
Disable escaping for this text node
USE_CDATA
Output as a CDATA section
Throws:
XPathException

endElement

public void endElement()
                throws XPathException
End of element

Specified by:
endElement in interface Receiver
Overrides:
endElement in class Sink
Throws:
XPathException

parseFinalOrBlock

public int parseFinalOrBlock(String attrName,
                             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:
attrName - the attribute name (block or final)
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

main

public static void main(String[] args)
                 throws Exception
Test rig

Parameters:
args - (schema-model-source-file, instance-source-file)
Throws:
Exception


Copyright (c) Saxonica Limited. All rights reserved.