Debian Codegraph @

net/sf/saxon/lib/OutputURIResolver.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.lib;
9
10 import net.sf.saxon.trans.XsltController;
11
12 import javax.xml.transform.Result;
13 import javax.xml.transform.TransformerException;
14 import java.util.function.Function;
15
16
17 /**
18 * This interface defines an OutputURIResolver. This is a counterpart to the JAXP
19 * URIResolver, but is used to map the URI of a secondary result document to a Result object
20 * which acts as the destination for the new document.
21 * <p>From Saxon 9.9 this interface is obsolescent. It is unable to handle the full flexibility
22 * of XSLT 3.0, for example it cannot handle raw output, JSON serialization, or the item-separator
23 * serialization property. A new mechanism has therefore been introduced. This has a low-level
24 * interface {@link XsltController#setResultDocumentResolver(ResultDocumentResolver)}, and a high-level
25 * counterpart at the s9api level, using the setResultDocumentHandler() method on {@link net.sf.saxon.s9api.Xslt30Transformer}
26 * and {@link net.sf.saxon.s9api.XsltTransformer}.</p>
27 */
28
29 public interface OutputURIResolver {
30
31 /**
32 * Get an instance of this OutputURIResolver class.
33 * <p>This method is called every time an xsl:result-document instruction
34 * is evaluated (with an href attribute). The resolve() and close() methods
35 * will be called on the returned instance.</p>
36 * <p>Note that in Saxon-EE, the xsl:result-document instruction executes
37 * asynchronously, which means that documents are not necessarily closed in the
38 * order they are opened, and multiple documents may be open at once.</p>
39 * <p>If the OutputURIResolver is stateless (that is, it retains no information
40 * between resolve() and close()), then the same instance can safely be returned
41 * each time. For a stateful OutputURIResolver, it must either take care to be
42 * thread-safe (handling multiple invocations of xsl:result-document concurrently),
43 * or it must return a fresh instance of itself for each call.</p>
44 */
45
46 OutputURIResolver newInstance();
47
48 /**
49 * Resolve an output URI.
50 *
51 * @param href The relative URI of the output document. This corresponds to the
52 * href attribute of the xsl:result-document instruction.
53 * @param base The base URI that should be used. This is the Base Output URI, typically
54 * the URI of the principal output document
55 * @return a Result object representing the destination for the XML document. The
56 * method can also return null, in which case the standard output URI resolver
57 * will be used to create a Result object.
58 * <p>The systemId property of the returned Result object should normally be the
59 * result of resolving href (as a relative URI) against the value of base.
60 * This systemId is used to enforce the error
61 * conditions in the XSLT specification that disallow writing two result trees to the
62 * same destination, or reading from a destination that is written to in the same
63 * transformation. Setting the systemId to null, or to a deceptive value, will defeat
64 * these error checks (which can sometimes be useful). Equally, setting the systemId
65 * to the same value on repeated calls when different href/base arguments are supplied
66 * will cause a spurious error.</p>
67 * @throws javax.xml.transform.TransformerException
68 * if any error occurs
69 */
70
71 Result resolve(String href, String base) throws TransformerException;
72
73 /**
74 * Signal completion of the result document. This method is called by the system
75 * when the result document has been successfully written. It allows the resolver
76 * to perform tidy-up actions such as closing output streams, or firing off
77 * processes that take this result tree as input. The original Result object is
78 * supplied to identify the document that has been completed. This allows the
79 * OutputURIResolver to be stateless, making it easier to handle the asynchronous
80 * calls of xsl:result-document that arise in Saxon-EE.
81 *
82 * @param result The result object returned by the previous call of resolve()
83 * @throws javax.xml.transform.TransformerException
84 * if any error occurs
85 */
86
87 void close(Result result) throws TransformerException;
88
89 }
90