public class AugmentedSource
extends java.lang.Object
implements javax.xml.transform.Source
Internally, an AugmentedSource combines an underlying Source object with a
ParseOptions
object holding the selected options. Many Saxon interfaces allow
the ParseOptions to be supplied directly, making this class unnecessary; but it is useful
when passing a Source to a JAXP interface that does not allow further options to be
supplied.
Note that in general a Source
object can only be used once; it is
consumed by use. An augmentedSource object is consumed by use if the underlying
source object is consumed by use.
Constructor and Description |
---|
AugmentedSource(javax.xml.transform.Source source,
ParseOptions options)
Create an AugmentedSource that wraps a given Source object (which must not itself be an
AugmentedSource), with supplied ParseOptions
|
Modifier and Type | Method and Description |
---|---|
void |
addFilter(FilterFactory filter)
Add a filter to the list of filters to be applied to the raw input
|
void |
close()
Close any resources held by this Source.
|
javax.xml.transform.Source |
getContainedSource()
Get the Source object wrapped by this AugmentedSource
|
int |
getDTDValidation()
Get whether or not DTD validation of this source is required
|
org.xml.sax.EntityResolver |
getEntityResolver()
Get the EntityResolver that will be used when parsing
|
UnfailingErrorListener |
getErrorListener()
Get the ErrorListener that will be used when parsing
|
java.util.List<FilterFactory> |
getFilters()
Get the list of filters to be applied to the input.
|
TreeModel |
getModel()
Get the tree model that will be used.
|
ParseOptions |
getParseOptions()
Get the ParseOptions defined in this AugmentedSource
|
int |
getSchemaValidation()
Get whether or not schema validation of this source is required
|
int |
getStripSpace()
Deprecated.
since 9.8 - use getParseOptions().getSpaceStrippingRules()
|
java.lang.String |
getSystemId()
Get the System ID.
|
StructuredQName |
getTopLevelElement()
Get the name of the top-level element for validation.
|
SchemaType |
getTopLevelType()
Get the type of the document element for validation.
|
java.lang.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.
|
org.xml.sax.XMLReader |
getXMLReader()
Get the SAX parser (XMLReader) to be used
|
boolean |
isLineNumbering()
Get whether line numbers are to be maintained in the constructed document
|
boolean |
isLineNumberingSet()
Determine whether setLineNumbering() has been called
|
boolean |
isPleaseCloseAfterUse()
Determine whether or not the user of this Source is encouraged to close it as soon as reading is
finished.
|
boolean |
isXIncludeAware()
Get state of XInclude processing.
|
boolean |
isXIncludeAwareSet()
Determine whether setXIncludeAware() has been called.
|
static AugmentedSource |
makeAugmentedSource(javax.xml.transform.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 required
|
void |
setEntityResolver(org.xml.sax.EntityResolver resolver)
Set an EntityResolver to be used when parsing.
|
void |
setErrorListener(javax.xml.transform.ErrorListener listener)
Set an ErrorListener to be used when parsing
|
void |
setLineNumbering(boolean lineNumbering)
Set whether line numbers are to be maintained in the constructed document
|
void |
setModel(TreeModel model)
Set the tree model to use.
|
void |
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 required
|
void |
setStripSpace(int stripAction)
Deprecated.
since 9.8 - use getParseOptions().setSpaceStrippingRules()
|
void |
setSystemId(java.lang.String id)
Set the System ID.
|
void |
setTopLevelElement(StructuredQName elementName)
Set the name of the top-level element for validation.
|
void |
setTopLevelType(SchemaType type)
Set the type of the top-level element for validation.
|
void |
setWrapDocument(java.lang.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 |
setXIncludeAware(boolean state)
Set state of XInclude processing.
|
void |
setXMLReader(org.xml.sax.XMLReader parser)
Set the SAX parser (XMLReader) to be used
|
public AugmentedSource(javax.xml.transform.Source source, ParseOptions options)
source
- the Source object to be wrapped. This must be an implementation of Source
that Saxon recognizes, or an implementation for which a SourceResolver
has been
registered with the Configuration
. The source must not itself be an
AugmentedSource.
As an alternative to this constructor, consider using the factory method
makeAugmentedSource(javax.xml.transform.Source)
, which does accept any kind of Source including an
AugmentedSource as input.
options
- the ParseOptions to be used. This object may be subsequently modified and the changes
will be effective; furthermore, methods on the AugumentedSource will modify the
supplied ParseOptions.java.lang.IllegalArgumentException
- if the wrapped source is an AugmentedSourcepublic static AugmentedSource makeAugmentedSource(javax.xml.transform.Source source)
source
- the Source object to be wrappedpublic void addFilter(FilterFactory filter)
filter
- a factory for the filter to be addedpublic java.util.List<FilterFactory> getFilters()
public javax.xml.transform.Source getContainedSource()
public ParseOptions getParseOptions()
public void setStripSpace(int stripAction)
stripAction
- one of Whitespace.IGNORABLE
,
Whitespace.ALL
, or Whitespace.NONE
public int getStripSpace()
Whitespace.IGNORABLE
,
Whitespace.ALL
, or Whitespace.NONE
public void setModel(TreeModel model)
model
- typically one of the constants TreeModel.TINY_TREE
,
TreeModel.TINY_TREE_CONDENSED
, or TreeModel.LINKED_TREE
. However, in principle
a user-defined tree model can be used.public TreeModel getModel()
TreeModel.TINY_TREE
,
TreeModel.TINY_TREE_CONDENSED
, or TreeModel.LINKED_TREE
. However, in principle
a user-defined tree model can be used.public void setSchemaValidationMode(int option)
option
- one of Validation.STRICT
,
Validation.LAX
, Validation.STRIP
,
Validation.PRESERVE
, Validation.DEFAULT
public int getSchemaValidation()
Validation.DEFAULT
to use the default validation mode from the Configuration.public void setTopLevelElement(StructuredQName elementName)
elementName
- the QName of the required top-level element, or null to unset the valuepublic StructuredQName getTopLevelElement()
public void setTopLevelType(SchemaType type)
type
- the schema type required for the document element, or null to unset the valuepublic SchemaType getTopLevelType()
public void setDTDValidationMode(int option)
option
- one of Validation.STRICT
,
Validation.STRIP
, Validation.DEFAULT
public int getDTDValidation()
Validation.DEFAULT
to use the default validation mode from the Configuration.public void setLineNumbering(boolean lineNumbering)
lineNumbering
- true if line numbers are to be maintainedpublic boolean isLineNumbering()
public boolean isLineNumberingSet()
public void setXMLReader(org.xml.sax.XMLReader parser)
parser
- the SAX parserpublic org.xml.sax.XMLReader getXMLReader()
public void setWrapDocument(java.lang.Boolean wrap)
This option is used only when the Source is supplied to an interface such as the JAXP Transformer.transform() method where there is no other way of indicating whether a supplied external document should be wrapped or copied. It is not used when the Source is supplied to a Saxon-defined interface.
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.public java.lang.Boolean getWrapDocument()
This option is used only when the Source is supplied to an interface such as the JAXP Transformer.transform() method where there is no other way of indicating whether a supplied external document should be wrapped or copied. It is not used when the Source is supplied to a Saxon-defined interface.
public void setSystemId(java.lang.String id)
setSystemId
in interface javax.xml.transform.Source
id
- the System ID. This provides a base URI for the document, and also the result
of the document-uri() functionpublic java.lang.String getSystemId()
getSystemId
in interface javax.xml.transform.Source
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
.
state
- Set XInclude processing to true
or
false
public boolean isXIncludeAwareSet()
Determine whether setXIncludeAware() has been called.
public boolean isXIncludeAware()
Get state of XInclude processing.
public void setEntityResolver(org.xml.sax.EntityResolver resolver)
resolver
- the EntityResolver to be usedpublic org.xml.sax.EntityResolver getEntityResolver()
setEntityResolver(org.xml.sax.EntityResolver)
,
otherwise null.public void setErrorListener(javax.xml.transform.ErrorListener listener)
listener
- the ErrorListener to be usedpublic UnfailingErrorListener getErrorListener()
setErrorListener(javax.xml.transform.ErrorListener)
,
otherwise null.public void setPleaseCloseAfterUse(boolean close)
close
- true if the source should be closed as soon as it has been consumedpublic boolean isPleaseCloseAfterUse()
public void close()
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.