net.sf.saxon.event

Class ParseOptions

public class ParseOptions extends Object implements Serializable

This class defines options for parsing a source document
Constructor Summary
ParseOptions()
Create a ParseOptions object with default options set
ParseOptions(ParseOptions p)
Create a ParseOptions object as a copy of another ParseOptions
Method Summary
voidaddFilter(ProxyReceiver filter)
Add a filter to the list of filters to be applied to the raw input
voidapplyDefaults(Configuration config)
Merge settings from the Configuration object into these parseOptions
static voidclose(Source source)
Close any resources held by a given Source.
intgetDTDValidationMode()
Get whether or not DTD validation of this source is required
EntityResolvergetEntityResolver()
Get the EntityResolver that will be used when parsing
ErrorListenergetErrorListener()
Get the ErrorListener that will be used when parsing
ListgetFilters()
Get the list of filters to be applied to the input.
TreeModelgetModel()
Get the tree model that will be used.
intgetSchemaValidationMode()
Get whether or not schema validation of this source is required
intgetStripSpace()
Get the space-stripping action to be applied to the source document
StructuredQNamegetTopLevelElement()
Get the name of the top-level element for validation.
SchemaTypegetTopLevelType()
Get the type of the document element for validation.
intgetTreeModel()
Get the tree model that will be used.
BooleangetWrapDocument()
Assuming that the contained Source is a node in a tree, determine whether a tree will be created as a view of this supplied tree, or as a copy.
XMLReadergetXMLReader()
Get the SAX parser (XMLReader) to be used
booleanisContinueAfterValidationErrors()
Ask whether processing should continue after a validation error (true when the output is a final output)
booleanisExpandAttributeDefaults()
Ask whether to expand default attributes defined in a DTD or schema.
booleanisLineNumbering()
Get whether line numbers are to be maintained in the constructed document
booleanisLineNumberingSet()
Determine whether setLineNumbering() has been called
booleanisPleaseCloseAfterUse()
Determine whether or not the user of this Source is encouraged to close it as soon as reading is finished.
booleanisUseXsiSchemaLocation()
Ask whether or not to use the xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes in an instance document to locate a schema for validation.
booleanisXIncludeAware()

Get state of XInclude processing.

booleanisXIncludeAwareSet()

Determine whether setXIncludeAware() has been called.

voidmerge(ParseOptions options)
Merge another set of parseOptions into these parseOptions
voidsetContinueAfterValidationErrors(boolean keepGoing)
Say that processing should continue after a validation error (true when the output is a final output)
voidsetDTDValidationMode(int option)
Set whether or not DTD validation of this source is required
voidsetEntityResolver(EntityResolver resolver)
Set an EntityResolver to be used when parsing.
voidsetErrorListener(ErrorListener listener)
Set an ErrorListener to be used when parsing
voidsetExpandAttributeDefaults(boolean expand)
Set whether to expand default attributes defined in a DTD or schema.
voidsetLineNumbering(boolean lineNumbering)
Set whether line numbers are to be maintained in the constructed document
voidsetModel(TreeModel model)
Set the tree model to use.
voidsetPleaseCloseAfterUse(boolean close)
Set whether or not the user of this Source is encouraged to close it as soon as reading is finished.
voidsetSchemaValidationMode(int option)
Set whether or not schema validation of this source is required
voidsetStripSpace(int stripAction)
Set the space-stripping action to be applied to the source document
voidsetTopLevelElement(StructuredQName elementName)
Set the name of the top-level element for validation.
voidsetTopLevelType(SchemaType type)
Set the type of the top-level element for validation.
voidsetTreeModel(int model)
Set the tree model to use.
voidsetUseXsiSchemaLocation(boolean use)
Set whether or not to use the xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes in an instance document to locate a schema for validation.
voidsetWrapDocument(Boolean wrap)
Assuming that the contained Source is a node in a tree, indicate whether a tree should be created as a view of this supplied tree, or as a copy.
voidsetXIncludeAware(boolean state)

Set state of XInclude processing.

If XInclude markup is found in the document instance, should it be processed as specified in XML Inclusions (XInclude) Version 1.0.

XInclude processing defaults to false.

voidsetXMLReader(XMLReader parser)
Set the SAX parser (XMLReader) to be used

Constructor Detail

ParseOptions

public ParseOptions()
Create a ParseOptions object with default options set

ParseOptions

public ParseOptions(ParseOptions p)
Create a ParseOptions object as a copy of another ParseOptions

Method Detail

addFilter

public void addFilter(ProxyReceiver filter)
Add a filter to the list of filters to be applied to the raw input

Parameters: filter the filter to be added

applyDefaults

public void applyDefaults(Configuration config)
Merge settings from the Configuration object into these parseOptions

Parameters: config the Configuration. Settings from the Configuration are used only where no setting is present in this ParseOptions object

close

public static void close(Source source)
Close any resources held by a given Source. This only works if the underlying Source is one that is recognized as holding closable resources.

Parameters: source the source to be closed

Since: 9.2

getDTDValidationMode

public int getDTDValidationMode()
Get whether or not DTD validation of this source is required

Returns: the validation mode requested, or DEFAULT to use the default validation mode from the Configuration.

getEntityResolver

public EntityResolver getEntityResolver()
Get the EntityResolver that will be used when parsing

Returns: the EntityResolver, if one has been set using ParseOptions, otherwise null.

getErrorListener

public ErrorListener getErrorListener()
Get the ErrorListener that will be used when parsing

Returns: the ErrorListener, if one has been set using ParseOptions, otherwise null.

getFilters

public List getFilters()
Get the list of filters to be applied to the input. Returns null if there are no filters.

Returns: the list of filters, if there are any

getModel

public TreeModel getModel()
Get the tree model that will be used.

Returns: typically one of the constants TINY_TREE, TINY_TREE_CONDENSED, or LINKED_TREE. However, in principle a user-defined tree model can be used.

getSchemaValidationMode

public int getSchemaValidationMode()
Get whether or not schema validation of this source is required

Returns: the validation mode requested, or DEFAULT to use the default validation mode from the Configuration.

getStripSpace

public int getStripSpace()
Get the space-stripping action to be applied to the source document

Returns: one of IGNORABLE, ALL, or NONE

getTopLevelElement

public StructuredQName getTopLevelElement()
Get the name of the top-level element for validation. If a top-level element is set then the document being validated must have this as its outermost element

Returns: the QName of the required top-level element, or null if no value is set

Since: 9.0

getTopLevelType

public SchemaType getTopLevelType()
Get the type of the document element for validation. If this is set then the document element of the document being validated must have this type

Returns: the type of the required top-level element, or null if no value is set

getTreeModel

public int getTreeModel()
Get the tree model that will be used.

Returns: one of TINY_TREE, LINKED_TREE, or TINY_TREE_CONDENSED, or {link Builder#UNSPECIFIED_TREE_MODEL} if no call on setTreeModel() has been made

getWrapDocument

public Boolean getWrapDocument()
Assuming that the contained Source is a node in a tree, determine whether a tree will be created as a view of this supplied tree, or as a copy.

Returns: if true, the node in the supplied Source is wrapped, to create a view. If false, the node and its contained subtree is copied. If null, the system default is chosen.

Since: 8.8

getXMLReader

public XMLReader getXMLReader()
Get the SAX parser (XMLReader) to be used

Returns: the parser

isContinueAfterValidationErrors

public boolean isContinueAfterValidationErrors()
Ask whether processing should continue after a validation error (true when the output is a final output)

Returns: true if processing should continue

isExpandAttributeDefaults

public boolean isExpandAttributeDefaults()
Ask whether to expand default attributes defined in a DTD or schema. By default, default attribute values are expanded

Returns: true if missing attribute values are to take the default value supplied in a DTD or schema, false if they are to be left as absent

isLineNumbering

public boolean isLineNumbering()
Get whether line numbers are to be maintained in the constructed document

Returns: true if line numbers are maintained

isLineNumberingSet

public boolean isLineNumberingSet()
Determine whether setLineNumbering() has been called

Returns: true if setLineNumbering() has been called

isPleaseCloseAfterUse

public boolean isPleaseCloseAfterUse()
Determine whether or not the user of this Source is encouraged to close it as soon as reading is finished.

Returns: true if the source should be closed as soon as it has been consumed

isUseXsiSchemaLocation

public boolean isUseXsiSchemaLocation()
Ask whether or not to use the xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes in an instance document to locate a schema for validation. Note, these attribute are only used if validation is requested. return true (the default) if these attributes are to be used, false if they are to be ignored

isXIncludeAware

public boolean isXIncludeAware()

Get state of XInclude processing.

Returns: current state of XInclude processing. Default value is false.

isXIncludeAwareSet

public boolean isXIncludeAwareSet()

Determine whether setXIncludeAware() has been called.

Returns: true if setXIncludeAware() has been called

merge

public void merge(ParseOptions options)
Merge another set of parseOptions into these parseOptions

Parameters: options the other parseOptions. If both are present, the other parseOptions take precedence

setContinueAfterValidationErrors

public void setContinueAfterValidationErrors(boolean keepGoing)
Say that processing should continue after a validation error (true when the output is a final output)

Parameters: keepGoing true if processing should continue

setDTDValidationMode

public void setDTDValidationMode(int option)
Set whether or not DTD validation of this source is required

Parameters: option one of STRICT, STRIP, DEFAULT

setEntityResolver

public void setEntityResolver(EntityResolver resolver)
Set an EntityResolver to be used when parsing. Note that this will not be used if an XMLReader has been supplied (in that case, the XMLReader should be initialized with the EntityResolver already set.)

Parameters: resolver the EntityResolver to be used

setErrorListener

public void setErrorListener(ErrorListener listener)
Set an ErrorListener to be used when parsing

Parameters: listener the ErrorListener to be used

setExpandAttributeDefaults

public void setExpandAttributeDefaults(boolean expand)
Set whether to expand default attributes defined in a DTD or schema. By default, default attribute values are expanded

Parameters: expand true if missing attribute values are to take the default value supplied in a DTD or schema, false if they are to be left as absent

setLineNumbering

public void setLineNumbering(boolean lineNumbering)
Set whether line numbers are to be maintained in the constructed document

Parameters: lineNumbering true if line numbers are to be maintained

setModel

public void setModel(TreeModel model)
Set the tree model to use. Default is the tiny tree

Parameters: model typically one of the constants TINY_TREE, TINY_TREE_CONDENSED, or LINKED_TREE. However, in principle a user-defined tree model can be used.

Since: 9.2

setPleaseCloseAfterUse

public void setPleaseCloseAfterUse(boolean close)
Set whether or not the user of this Source is encouraged to close it as soon as reading is finished. Normally the expectation is that any Stream in a StreamSource will be closed by the component that created the Stream. However, in the case of a Source returned by a URIResolver, there is no suitable interface (the URIResolver has no opportunity to close the stream). Also, in some cases such as reading of stylesheet modules, it is possible to close the stream long before control is returned to the caller who supplied it. This tends to make a difference on .NET, where a file often can't be opened if there is a stream attached to it.

Parameters: close true if the source should be closed as soon as it has been consumed

setSchemaValidationMode

public void setSchemaValidationMode(int option)
Set whether or not schema validation of this source is required

Parameters: option one of STRICT, LAX, STRIP, PRESERVE, DEFAULT

setStripSpace

public void setStripSpace(int stripAction)
Set the space-stripping action to be applied to the source document

Parameters: stripAction one of IGNORABLE, ALL, or NONE

setTopLevelElement

public void setTopLevelElement(StructuredQName elementName)
Set the name of the top-level element for validation. If a top-level element is set then the document being validated must have this as its outermost element

Parameters: elementName the QName of the required top-level element, or null to unset the value

setTopLevelType

public void setTopLevelType(SchemaType type)
Set the type of the top-level element for validation. If this is set then the document element is validated against this type

Parameters: type the schema type required for the document element, or null to unset the value

setTreeModel

public void setTreeModel(int model)
Set the tree model to use. Default is the tiny tree

Parameters: model one of TINY_TREE, LINKED_TREE or TINY_TREE_CONDENSED

setUseXsiSchemaLocation

public void setUseXsiSchemaLocation(boolean use)
Set whether or not to use the xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes in an instance document to locate a schema for validation. Note, these attribute are only used if validation is requested.

Parameters: use true if these attributes are to be used, false if they are to be ignored

setWrapDocument

public void setWrapDocument(Boolean wrap)
Assuming that the contained Source is a node in a tree, indicate whether a tree should be created as a view of this supplied tree, or as a copy.

Parameters: wrap if true, the node in the supplied Source is wrapped, to create a view. If false, the node and its contained subtree is copied. If null, the system default is chosen.

setXIncludeAware

public void setXIncludeAware(boolean state)

Set state of XInclude processing.

If XInclude markup is found in the document instance, should it be processed as specified in XML Inclusions (XInclude) Version 1.0.

XInclude processing defaults to false.

Parameters: state Set XInclude processing to true or false

Since: 8.9

setXMLReader

public void setXMLReader(XMLReader parser)
Set the SAX parser (XMLReader) to be used

Parameters: parser the SAX parser