Package net.sf.saxon
Class AugmentedSource
java.lang.Object
net.sf.saxon.AugmentedSource
- All Implemented Interfaces:
Source
This class wraps a JAXP Source object to provide an extended Source object that
contains options indicating how the Source should be processed: for example,
whether or not it should be validated against a schema. Other options that can
be set include the SAX XMLReader to be used, and the choice of whether a source
in the form of an existing tree should be copied or wrapped.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFilter
(ProxyReceiver filter) Add a filter to the list of filters to be applied to the raw inputvoid
close()
Close any resources held by this Source.Get the Source object wrapped by this AugmentedSourceint
Get whether or not DTD validation of this source is requiredGet the list of filters to be applied to the input.int
Get whether or not schema validation of this source is requiredint
Get the space-stripping action to be applied to the source documentGet the System ID.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.boolean
Get whether line numbers are to be maintained in the constructed documentboolean
Determine whether or not the user of this Source is encouraged to close it as soon as reading is finished.static AugmentedSource
makeAugmentedSource
(Source source) Create an AugmentedSource that wraps a given Source object.void
setDTDValidationMode
(int option) Set whether or not DTD validation of this source is requiredvoid
setLineNumbering
(boolean lineNumbering) Set whether line numbers are to be maintained in the constructed documentvoid
setPleaseCloseAfterUse
(boolean close) Set whether or not the user of this Source is encouraged to close it as soon as reading is finished.void
setSchemaValidationMode
(int option) Set whether or not schema validation of this source is requiredvoid
setStripSpace
(int stripAction) Set the space-stripping action to be applied to the source documentvoid
setSystemId
(String id) Set the System ID.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.void
setXMLReader
(XMLReader parser) Set the SAX parser (XMLReader) to be used
-
Method Details
-
makeAugmentedSource
Create an AugmentedSource that wraps a given Source object. If this is already an AugmentedSource, the original AugmentedSource is returned.- Parameters:
source
- the Source object to be wrapped
-
addFilter
Add a filter to the list of filters to be applied to the raw input -
getFilters
Get the list of filters to be applied to the input. Returns null if there are no filters. -
getContainedSource
Get the Source object wrapped by this AugmentedSource- Returns:
- the contained Source object
-
setStripSpace
public void setStripSpace(int stripAction) Set the space-stripping action to be applied to the source document- Parameters:
stripAction
- one ofWhitespace.IGNORABLE
,Whitespace.ALL
, orWhitespace.NONE
-
getStripSpace
public int getStripSpace()Get the space-stripping action to be applied to the source document- Returns:
- one of
Whitespace.IGNORABLE
,Whitespace.ALL
, orWhitespace.NONE
-
setSchemaValidationMode
public void setSchemaValidationMode(int option) Set whether or not schema validation of this source is required- Parameters:
option
- one ofValidation.STRICT
,Validation.LAX
,Validation.STRIP
,Validation.PRESERVE
,Validation.DEFAULT
-
getSchemaValidation
public int getSchemaValidation()Get whether or not schema validation of this source is required- Returns:
- the validation mode requested, or
Validation.DEFAULT
to use the default validation mode from the Configuration.
-
setDTDValidationMode
public void setDTDValidationMode(int option) Set whether or not DTD validation of this source is required- Parameters:
option
- one ofValidation.STRICT
,Validation.STRIP
,Validation.DEFAULT
-
getDTDValidation
public int getDTDValidation()Get whether or not DTD validation of this source is required- Returns:
- the validation mode requested, or
Validation.DEFAULT
to use the default validation mode from the Configuration.
-
setLineNumbering
public void setLineNumbering(boolean lineNumbering) Set whether line numbers are to be maintained in the constructed document- Parameters:
lineNumbering
-
-
isLineNumbering
public boolean isLineNumbering()Get whether line numbers are to be maintained in the constructed document- Returns:
- true if line numbers are maintained
-
setXMLReader
Set the SAX parser (XMLReader) to be used- Parameters:
parser
-
-
getXMLReader
-
setWrapDocument
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.
-
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.
-
setSystemId
Set the System ID. This sets the System Id on the underlying Source object.- Specified by:
setSystemId
in interfaceSource
- Parameters:
id
- the System ID.
-
getSystemId
Get the System ID. This gets the System Id on the underlying Source object.- Specified by:
getSystemId
in interfaceSource
- Returns:
- the System ID.
-
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. -
isPleaseCloseAfterUse
public boolean isPleaseCloseAfterUse()Determine whether or not the user of this Source is encouraged to close it as soon as reading is finished. -
close
public void close()Close any resources held by this Source. This only works if the underlying Source is one that is recognized as holding closable resources.
-