Class StandardResultDocumentResolver
- java.lang.Object
-
- net.sf.saxon.lib.StandardResultDocumentResolver
-
- All Implemented Interfaces:
ResultDocumentResolver
public class StandardResultDocumentResolver extends java.lang.Object implements ResultDocumentResolver
This class defines the default ResultDocumentResolver. This is a counterpart to the JAXP URIResolver, but is used to map the URI of a secondary result document to a Receiver object which acts as the destination for the new document.
-
-
Constructor Summary
Constructors Constructor Description StandardResultDocumentResolver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close(javax.xml.transform.Result result)
Signal completion of the result document.protected javax.xml.transform.stream.StreamResult
createResult(java.net.URI absoluteURI)
static StandardResultDocumentResolver
getInstance()
Get a singular instancestatic javax.xml.transform.stream.StreamResult
makeOutputFile(java.net.URI absoluteURI)
Create an output file (unless it already exists) and return a reference to it as a Result objectjavax.xml.transform.stream.StreamResult
resolve(java.lang.String href, java.lang.String base)
Resolve an output URIReceiver
resolve(XPathContext context, java.lang.String href, java.lang.String baseUri, SerializationProperties properties)
Saxon calls this method when anxsl:result-document
instruction with anhref
attribute is evaluated.
-
-
-
Method Detail
-
getInstance
public static StandardResultDocumentResolver getInstance()
Get a singular instance- Returns:
- the singleton instance of the class
-
resolve
public Receiver resolve(XPathContext context, java.lang.String href, java.lang.String baseUri, SerializationProperties properties) throws XPathException
Description copied from interface:ResultDocumentResolver
Saxon calls this method when anxsl:result-document
instruction with anhref
attribute is evaluated.Note: it may be appropriate for the method to obtain a suitable
Receiver
by calling one of the static factory methods on theSerializerFactory
class. ASerializerFactory
can be obtained by callingcontext.getConfiguration().getSerializerFactory()
.- Specified by:
resolve
in interfaceResultDocumentResolver
- Parameters:
context
- the dynamic evaluation contexthref
- the effective value of thehref
attribute ofxsl:result-document
instruction. This will be a zero-length string if the attribute is omitted.baseUri
- the base output URI of the transformation (typically, the destination of the principal output destination). This may be null if no base output URI is known. The recommended action if it is null is to use thehref
value alone if it is absolute URI, otherwise to raise an error (SaxonErrorCode.SXRD0002
, since there is no W3C-defined code for the condition).properties
- the serialization properties defined explicitly or implicitly on thexsl:result-document
instruction, together with information about character maps in the stylesheet that might be referenced. Serialization parameters can be ignored if the result document is not being serialized. However, if the serialization parameters include a validation factory, then this must not be ignored: a validator must be inserted at a suitable point in the output pipeline.- Returns:
- a new instance of the
Receiver
class, which Saxon will then call to open the output document, and subsequently to close it. ThisReceiver
will receive a sequence of events representing the raw result of thexsl:result-document
instruction, as a regular event sequence conforming to the rules defined inRegularSequenceChecker
.The implementation should set the
systemId
property of the returnedReceiver
to the result of resolving the suppliedhref
against the suppliedbaseUri
. On return from this method, Saxon will check that thesystemId
is non-null and that it satisfies the uniqueness conditions imposed by the XSLT specification. Specifically, it is not permitted for two calls onxsl:result-document
to use the same URI, and this URI must not be read in a call ondoc()
ordocument()
, either before or after executing thexsl:result-document
instruction. - Throws:
XPathException
- if a result document cannot be opened
-
resolve
public javax.xml.transform.stream.StreamResult resolve(java.lang.String href, java.lang.String base) throws XPathException
Resolve an output URI- Parameters:
href
- The relative URI of the output document. This corresponds to the href attribute of the xsl:result-document instruction.base
- The base URI that should be used. This is the base output URI, normally the URI of the principal output file.- Returns:
- a Result object representing the destination for the XML document
- Throws:
XPathException
-
createResult
protected javax.xml.transform.stream.StreamResult createResult(java.net.URI absoluteURI) throws XPathException, java.io.IOException
- Throws:
XPathException
java.io.IOException
-
makeOutputFile
public static javax.xml.transform.stream.StreamResult makeOutputFile(java.net.URI absoluteURI) throws XPathException
Create an output file (unless it already exists) and return a reference to it as a Result object- Parameters:
absoluteURI
- the URI of the output file (which should typically use the "file" scheme)- Returns:
- a Result object referencing this output file
- Throws:
XPathException
- if the URI is not writable
-
close
public void close(javax.xml.transform.Result result) throws XPathException
Signal completion of the result document. This method is called by the system when the result document has been successfully written. It allows the resolver to perform tidy-up actions such as closing output streams, or firing off processes that take this result tree as input. Note that the OutputURIResolver is stateless, so the original href is supplied to identify the document that has been completed.- Throws:
XPathException
-
-