| 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.trans; |
| 9 | |
| 10 | import net.sf.saxon.Configuration; |
| 11 | import net.sf.saxon.expr.instruct.GlobalParameterSet; |
| 12 | import net.sf.saxon.expr.parser.CodeInjector; |
| 13 | import net.sf.saxon.expr.parser.OptimizerOptions; |
| 14 | import net.sf.saxon.functions.FunctionLibrary; |
| 15 | import net.sf.saxon.lib.OutputURIResolver; |
| 16 | import net.sf.saxon.lib.StandardOutputResolver; |
| 17 | import net.sf.saxon.om.GroundedValue; |
| 18 | import net.sf.saxon.om.Item; |
| 19 | import net.sf.saxon.om.StructuredQName; |
| 20 | import net.sf.saxon.query.QueryLibrary; |
| 21 | import net.sf.saxon.trans.packages.PackageLibrary; |
| 22 | |
| 23 | import javax.xml.transform.ErrorListener; |
| 24 | import javax.xml.transform.URIResolver; |
| 25 | import java.util.Collection; |
| 26 | |
| 27 | /** |
| 28 | * This class exists to hold information associated with a specific XSLT compilation episode. |
| 29 | * In JAXP, the URIResolver and ErrorListener used during XSLT compilation are those defined in the |
| 30 | * TransformerFactory. The .NET API and the s9api API, however, allow finer granularity, |
| 31 | * and this class exists to support that. |
| 32 | */ |
| 33 | |
| 34 | public class CompilerInfo { |
| 35 | |
| 36 | private Configuration config; |
| 37 | private transient URIResolver uriResolver; |
| 38 | private transient OutputURIResolver outputURIResolver = StandardOutputResolver.getInstance(); |
| 39 | private transient ErrorListener errorListener; |
| 40 | private CodeInjector codeInjector; |
| 41 | private int recoveryPolicy = Configuration.RECOVER_WITH_WARNINGS; |
| 42 | private boolean schemaAware; |
| 43 | //private boolean versionWarning; |
| 44 | private String messageReceiverClassName = "net.sf.saxon.serialize.MessageEmitter"; |
| 45 | private StructuredQName defaultInitialMode; |
| 46 | private StructuredQName defaultInitialTemplate; |
| 47 | private FunctionLibrary extensionFunctionLibrary; |
| 48 | private GlobalParameterSet suppliedParameters = new GlobalParameterSet(); |
| 49 | private String defaultCollation; |
| 50 | private PackageLibrary packageLibrary; |
| 51 | private boolean assertionsEnabled = false; |
| 52 | private String targetEdition = "HE"; |
| 53 | private boolean relocatable = false; |
| 54 | private Collection<QueryLibrary> queryLibraries; |
| 55 | private OptimizerOptions optimizerOptions; |
| 56 | |
| 57 | /** |
| 58 | * Create an empty CompilerInfo object with default settings. (Note, this does not |
| 59 | * copy settings from the defaultXsltCompilerInfo held by the configuration. For that, |
| 60 | * use <code>new CompilerInfo(config.getDefaultXsltCompilerInfo()</code>). |
| 61 | */ |
| 62 | |
| 63 | public CompilerInfo(Configuration config) { |
| 64 | this.config = config; |
| 65 | packageLibrary = new PackageLibrary(this); |
| 66 | optimizerOptions = config.getOptimizerOptions(); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Create a CompilerInfo object as a copy of another CompilerInfo object |
| 71 | * |
| 72 | * @param info the existing CompilerInfo object |
| 73 | * @since 9.2 |
| 74 | */ |
| 75 | |
| 76 | public CompilerInfo(CompilerInfo info) { |
| 77 | copyFrom(info); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Copy all properties from a supplied CompilerInfo |
| 82 | * |
| 83 | * @param info the CompilerInfo to be copied |
| 84 | */ |
| 85 | |
| 86 | public void copyFrom(CompilerInfo info) { |
| 87 | config = info.config; |
| 88 | uriResolver = info.uriResolver; |
| 89 | outputURIResolver = info.outputURIResolver; |
| 90 | errorListener = info.errorListener; |
| 91 | codeInjector = info.codeInjector; |
| 92 | recoveryPolicy = info.recoveryPolicy; |
| 93 | schemaAware = info.schemaAware; |
| 94 | messageReceiverClassName = info.messageReceiverClassName; |
| 95 | defaultInitialMode = info.defaultInitialMode; |
| 96 | defaultInitialTemplate = info.defaultInitialTemplate; |
| 97 | extensionFunctionLibrary = info.extensionFunctionLibrary; |
| 98 | suppliedParameters = new GlobalParameterSet(info.suppliedParameters); |
| 99 | defaultCollation = info.defaultCollation; |
| 100 | assertionsEnabled = info.assertionsEnabled; |
| 101 | targetEdition = info.targetEdition; |
| 102 | packageLibrary = new PackageLibrary(info.packageLibrary); |
| 103 | relocatable = info.relocatable; |
| 104 | optimizerOptions = info.optimizerOptions; |
| 105 | queryLibraries = info.queryLibraries; |
| 106 | } |
| 107 | |
| 108 | public Configuration getConfiguration() { |
| 109 | return config; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Say whether just-in-time compilation of template rules should be used for this XSLT compilation |
| 114 | * <p>The same effect can be achieved by {@link #setOptimizerOptions(OptimizerOptions)} with the appropriate |
| 115 | * setting of {@link OptimizerOptions#JIT}.</p> |
| 116 | * |
| 117 | * @param jit true if just-in-time compilation should be used. With this option, static errors in the |
| 118 | * stylesheet code may be reported only when a template rule is first executed |
| 119 | * @since 9.8 |
| 120 | */ |
| 121 | |
| 122 | public void setJustInTimeCompilation(boolean jit) { |
| 123 | if (jit) { |
| 124 | optimizerOptions = optimizerOptions.union(new OptimizerOptions(OptimizerOptions.JIT)); |
| 125 | } else { |
| 126 | optimizerOptions = optimizerOptions.except(new OptimizerOptions(OptimizerOptions.JIT)); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Ask whether just-in-time compilation of template rules is in use for this XSLT compilation |
| 132 | * |
| 133 | * @return true if just-in-time compilation should be used. With this option, static errors in the |
| 134 | * stylesheet code may be reported only when a template rule is first executed |
| 135 | * @since 9.8 |
| 136 | */ |
| 137 | |
| 138 | public boolean isJustInTimeCompilation() { |
| 139 | return optimizerOptions.isSet(OptimizerOptions.JIT); |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Set the URI Resolver to be used in this compilation episode. |
| 144 | * |
| 145 | * @param resolver The URIResolver to be used. This is used to dereference URIs encountered in constructs |
| 146 | * such as xsl:include, xsl:import, and xsl:import-schema. |
| 147 | * @since 8.7 |
| 148 | */ |
| 149 | |
| 150 | public void setURIResolver(URIResolver resolver) { |
| 151 | uriResolver = resolver; |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Set the value of a stylesheet parameter. Static (compile-time) parameters must be provided using |
| 156 | * this method on the XsltCompiler object, prior to stylesheet compilation. Non-static parameters |
| 157 | * may also be provided using this method if their values will not vary from one transformation |
| 158 | * to another. No error occurs at this stage if the parameter is unknown, or if the value is incorrect |
| 159 | * for the parameter. Setting a value for a parameter overwrites any previous value set for the |
| 160 | * same parameter. |
| 161 | * |
| 162 | * @param name the name of the stylesheet parameter |
| 163 | * @param seq the value of the stylesheet parameter |
| 164 | */ |
| 165 | |
| 166 | public void setParameter(StructuredQName name, GroundedValue<?> seq) { |
| 167 | suppliedParameters.put(name, seq); |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Get the values of all stylesheet parameters that have been set using the |
| 172 | * {@link #setParameter(net.sf.saxon.om.StructuredQName, net.sf.saxon.om.GroundedValue)} |
| 173 | * method. |
| 174 | * |
| 175 | * @return the set of all parameters that have been set. |
| 176 | */ |
| 177 | |
| 178 | public GlobalParameterSet getParameters() { |
| 179 | return suppliedParameters; |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Clear the values of all stylesheet parameters that have been set using the |
| 184 | * {@link #setParameter(net.sf.saxon.om.StructuredQName, net.sf.saxon.om.GroundedValue)} |
| 185 | * method. |
| 186 | */ |
| 187 | |
| 188 | public void clearParameters() { |
| 189 | suppliedParameters.clear(); |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Set the target edition under which the stylesheet will be executed. |
| 194 | * |
| 195 | * @param edition the Saxon edition for the run-time environment. One of "EE", "PE", "HE", "JS", or "JS2". |
| 196 | * @since 9.7.0.5. Experimental and subject to change. |
| 197 | */ |
| 198 | |
| 199 | public void setTargetEdition(String edition) { |
| 200 | this.targetEdition = edition; |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * Get the target edition under which the stylesheet will be executed. |
| 205 | * |
| 206 | * @return the Saxon edition for the run-time environment. One of "EE", "PE", "HE", "JS", or "JS2". |
| 207 | * @since 9.7.0.5. Experimental and subject to change. |
| 208 | */ |
| 209 | |
| 210 | public String getTargetEdition() { |
| 211 | return targetEdition; |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Ask whether any package produced by this compiler can be deployed to a different location, with a different base URI |
| 216 | * |
| 217 | * @return if true then static-base-uri() represents the deployed location of the package, |
| 218 | * rather than its compile time location |
| 219 | */ |
| 220 | |
| 221 | public boolean isRelocatable() { |
| 222 | return relocatable; |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * Say whether any package produced by this compiler can be deployed to a different location, with a different base URI |
| 227 | * |
| 228 | * @param relocatable if true then static-base-uri() represents the deployed location of the package, |
| 229 | * rather than its compile time location |
| 230 | */ |
| 231 | |
| 232 | public void setRelocatable(boolean relocatable) { |
| 233 | this.relocatable = relocatable; |
| 234 | } |
| 235 | |
| 236 | /** |
| 237 | * Set the package library to be used during the compilation episode. Any packages referenced |
| 238 | * using xsl:use-package declarations during the stylesheet compilation must be found in this |
| 239 | * package library |
| 240 | * |
| 241 | * @param library the package library |
| 242 | */ |
| 243 | |
| 244 | public void setPackageLibrary(PackageLibrary library) { |
| 245 | packageLibrary = library; |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * Get the package library to be used during the compilation episode. Any packages referenced |
| 250 | * using xsl:use-package declarations during the stylesheet compilation must be found in this |
| 251 | * package library |
| 252 | * |
| 253 | * @return the package library |
| 254 | */ |
| 255 | |
| 256 | public PackageLibrary getPackageLibrary() { |
| 257 | return packageLibrary; |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * Ask whether assertions (xsl:assert instructions) should be enabled. By default |
| 262 | * they are disabled. If assertions are enabled at compile time, then by |
| 263 | * default they will also be enabled at run time; but they can be |
| 264 | * disabled at run time by specific request |
| 265 | * |
| 266 | * @return true if assertions are enabled at compile time |
| 267 | */ |
| 268 | |
| 269 | public boolean isAssertionsEnabled() { |
| 270 | return assertionsEnabled; |
| 271 | } |
| 272 | |
| 273 | /** |
| 274 | * Say whether assertions (xsl:assert instructions) should be enabled. By default |
| 275 | * they are disabled. If assertions are enabled at compile time, then by |
| 276 | * default they will also be enabled at run time; but they can be |
| 277 | * disabled at run time by specific request |
| 278 | * |
| 279 | * @param enabled true if assertions are enabled at compile time |
| 280 | */ |
| 281 | |
| 282 | |
| 283 | public void setAssertionsEnabled(boolean enabled) { |
| 284 | this.assertionsEnabled = enabled; |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Set the optimizer options to be used for compiling queries that use this static context. |
| 289 | * By default the optimizer options set in the {@link Configuration} are used. |
| 290 | * |
| 291 | * @param options the optimizer options to be used |
| 292 | */ |
| 293 | |
| 294 | public void setOptimizerOptions(OptimizerOptions options) { |
| 295 | this.optimizerOptions = options; |
| 296 | } |
| 297 | |
| 298 | /** |
| 299 | * Get the optimizer options being used for compiling queries that use this static context. |
| 300 | * By default the optimizer options set in the {@link Configuration} are used. |
| 301 | * |
| 302 | * @return the optimizer options being used |
| 303 | */ |
| 304 | |
| 305 | public OptimizerOptions getOptimizerOptions() { |
| 306 | return this.optimizerOptions; |
| 307 | } |
| 308 | |
| 309 | |
| 310 | /** |
| 311 | * Set whether bytecode should be generated for the compiled stylesheet. This option |
| 312 | * is available only with Saxon-EE. The default depends on the setting in the configuration |
| 313 | * at the time the XsltCompiler is instantiated, and by default is true for Saxon-EE. |
| 314 | * <p>The same effect can be achieved by {@link #setOptimizerOptions(OptimizerOptions)} with the appropriate |
| 315 | * setting of {@link OptimizerOptions#BYTE_CODE}.</p> |
| 316 | * |
| 317 | * @param option true if bytecode is to be generated, false otherwise |
| 318 | * @since 9.6 |
| 319 | */ |
| 320 | |
| 321 | public void setGenerateByteCode(boolean option) { |
| 322 | if (option) { |
| 323 | optimizerOptions = optimizerOptions.union(new OptimizerOptions(OptimizerOptions.BYTE_CODE)); |
| 324 | } else { |
| 325 | optimizerOptions = optimizerOptions.except(new OptimizerOptions(OptimizerOptions.BYTE_CODE)); |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | |
| 330 | /** |
| 331 | * Ask whether bytecode is to be generated in the compiled code. |
| 332 | * |
| 333 | * @return true if bytecode is to be generated, false if not. |
| 334 | * @since 9.6 |
| 335 | */ |
| 336 | |
| 337 | public boolean isGenerateByteCode() { |
| 338 | return optimizerOptions.isSet(OptimizerOptions.BYTE_CODE); |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Get the URI Resolver being used in this compilation episode. |
| 343 | * |
| 344 | * @return resolver The URIResolver in use. This is used to dereference URIs encountered in constructs |
| 345 | * such as xsl:include, xsl:import, and xsl:import-schema. |
| 346 | * @since 8.7 |
| 347 | */ |
| 348 | |
| 349 | public URIResolver getURIResolver() { |
| 350 | return uriResolver; |
| 351 | } |
| 352 | |
| 353 | /** |
| 354 | * Get the OutputURIResolver that will be used to resolve URIs used in the |
| 355 | * href attribute of the xsl:result-document instruction. |
| 356 | * |
| 357 | * @return the OutputURIResolver. If none has been supplied explicitly, the |
| 358 | * default OutputURIResolver is returned. |
| 359 | * @since 9.2 |
| 360 | */ |
| 361 | |
| 362 | public OutputURIResolver getOutputURIResolver() { |
| 363 | return outputURIResolver; |
| 364 | } |
| 365 | |
| 366 | /** |
| 367 | * Set the OutputURIResolver that will be used to resolve URIs used in the |
| 368 | * href attribute of the xsl:result-document instruction. |
| 369 | * |
| 370 | * @param outputURIResolver the OutputURIResolver to be used. |
| 371 | * @since 9.2 |
| 372 | */ |
| 373 | |
| 374 | public void setOutputURIResolver(OutputURIResolver outputURIResolver) { |
| 375 | this.outputURIResolver = outputURIResolver; |
| 376 | } |
| 377 | |
| 378 | |
| 379 | /** |
| 380 | * Set the ErrorListener to be used during this compilation episode |
| 381 | * |
| 382 | * @param listener The error listener to be used. This is notified of all errors detected during the |
| 383 | * compilation. |
| 384 | * @since 8.7 |
| 385 | */ |
| 386 | |
| 387 | public void setErrorListener(ErrorListener listener) { |
| 388 | errorListener = listener; |
| 389 | } |
| 390 | |
| 391 | /** |
| 392 | * Get the ErrorListener being used during this compilation episode |
| 393 | * |
| 394 | * @return listener The error listener in use. This is notified of all errors detected during the |
| 395 | * compilation. |
| 396 | * @since 8.7 |
| 397 | */ |
| 398 | |
| 399 | public ErrorListener getErrorListener() { |
| 400 | return errorListener; |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Get the name of the class that will be instantiated to create a MessageEmitter, |
| 405 | * to process the output of xsl:message instructions in XSLT. |
| 406 | * |
| 407 | * @return the full class name of the message emitter class. |
| 408 | * @since 9.2 |
| 409 | */ |
| 410 | |
| 411 | public String getMessageReceiverClassName() { |
| 412 | return messageReceiverClassName; |
| 413 | } |
| 414 | |
| 415 | /** |
| 416 | * Set the name of the class that will be instantiated to create a MessageEmitter, |
| 417 | * to process the output of xsl:message instructions in XSLT. |
| 418 | * |
| 419 | * @param messageReceiverClassName the message emitter class. This |
| 420 | * must implement net.sf.saxon.event.Emitter. |
| 421 | * @since 9.2 |
| 422 | */ |
| 423 | |
| 424 | public void setMessageReceiverClassName(String messageReceiverClassName) { |
| 425 | this.messageReceiverClassName = messageReceiverClassName; |
| 426 | } |
| 427 | |
| 428 | /** |
| 429 | * Set the name of the default collation |
| 430 | * |
| 431 | * @param collation the name of the default collation (if the stylesheet doesn't specify otherwise) |
| 432 | * @since 9.6 |
| 433 | */ |
| 434 | |
| 435 | public void setDefaultCollation(String collation) { |
| 436 | this.defaultCollation = collation; |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * Get the name of the default collation |
| 441 | * |
| 442 | * @return the default collation. If none has been specified at the level of this CompilerInfo, |
| 443 | * this defaults to the default collation defined in the Configuration, which in turn defaults |
| 444 | * to the Unicode codepoint collation |
| 445 | * @since 9.6 |
| 446 | */ |
| 447 | |
| 448 | public String getDefaultCollation() { |
| 449 | return this.defaultCollation; |
| 450 | } |
| 451 | |
| 452 | /** |
| 453 | * Set whether trace hooks are to be included in the compiled code. To use tracing, it is necessary |
| 454 | * both to compile the code with trace hooks included, and to supply a TraceListener at run-time |
| 455 | * |
| 456 | * @param injector the code injector used to insert trace or debugging hooks, or null to clear any |
| 457 | * existing entry |
| 458 | * @since 9.4 |
| 459 | */ |
| 460 | |
| 461 | public void setCodeInjector(CodeInjector injector) { |
| 462 | codeInjector = injector; |
| 463 | } |
| 464 | |
| 465 | /** |
| 466 | * Get the registered CodeInjector, if any |
| 467 | * |
| 468 | * @return the code injector used to insert trace or debugging hooks, or null if absent |
| 469 | */ |
| 470 | |
| 471 | public CodeInjector getCodeInjector() { |
| 472 | return codeInjector; |
| 473 | } |
| 474 | |
| 475 | /** |
| 476 | * Determine whether trace hooks are included in the compiled code. |
| 477 | * |
| 478 | * @return true if trace hooks are included, false if not. |
| 479 | * @since 8.9 |
| 480 | */ |
| 481 | |
| 482 | public boolean isCompileWithTracing() { |
| 483 | return codeInjector != null; |
| 484 | } |
| 485 | |
| 486 | /** |
| 487 | * Set the policy for handling recoverable errrors. Note that for some errors the decision can be |
| 488 | * made at run-time, but for the "ambiguous template match" error, the decision is (since 9.2) |
| 489 | * fixed at compile time. |
| 490 | * |
| 491 | * @param policy the recovery policy to be used. The options are {@link Configuration#RECOVER_SILENTLY}, |
| 492 | * {@link Configuration#RECOVER_WITH_WARNINGS}, or {@link Configuration#DO_NOT_RECOVER}. |
| 493 | * @since 9.2 |
| 494 | */ |
| 495 | |
| 496 | public void setRecoveryPolicy(int policy) { |
| 497 | recoveryPolicy = policy; |
| 498 | } |
| 499 | |
| 500 | /** |
| 501 | * Get the policy for handling recoverable errors. Note that for some errors the decision can be |
| 502 | * made at run-time, but for the "ambiguous template match" error, the decision is (since 9.2) |
| 503 | * fixed at compile time. |
| 504 | * |
| 505 | * @return the current policy. |
| 506 | * @since 9.2 |
| 507 | */ |
| 508 | |
| 509 | public int getRecoveryPolicy() { |
| 510 | return recoveryPolicy; |
| 511 | } |
| 512 | |
| 513 | /** |
| 514 | * Ask whether a warning is to be output when the stylesheet version does not match the processor version. |
| 515 | * In the case of stylesheet version="1.0", the XSLT specification requires such a warning unless the user disables it. |
| 516 | * |
| 517 | * @return true if these messages are to be output. |
| 518 | * @since 9.2 |
| 519 | * @deprecated since 9.8.0.2. Always now returns false. See bug 3278. |
| 520 | */ |
| 521 | |
| 522 | public boolean isVersionWarning() { |
| 523 | return false; |
| 524 | } |
| 525 | |
| 526 | /** |
| 527 | * Say whether a warning is to be output when the stylesheet version does not match the processor version. |
| 528 | * In the case of stylesheet version="1.0", the XSLT specification requires such a warning unless the user disables it. |
| 529 | * |
| 530 | * @param warn true if these messages are to be output. |
| 531 | * @since 9.2 |
| 532 | * @deprecated since 9.8.0.2. The method no longer has any effect. See bug 3278. |
| 533 | */ |
| 534 | |
| 535 | public void setVersionWarning(boolean warn) { |
| 536 | |
| 537 | } |
| 538 | |
| 539 | /** |
| 540 | * Say that the stylesheet must be compiled to be schema-aware, even if it contains no |
| 541 | * xsl:import-schema declarations. Normally a stylesheet is treated as schema-aware |
| 542 | * only if it contains one or more xsl:import-schema declarations. If it is not schema-aware, |
| 543 | * then all input documents must be untyped, and validation of temporary trees is disallowed |
| 544 | * (though validation of the final result tree is permitted). Setting the argument to true |
| 545 | * means that schema-aware code will be compiled regardless. |
| 546 | * |
| 547 | * @param schemaAware If true, the stylesheet will be compiled with schema-awareness |
| 548 | * enabled even if it contains no xsl:import-schema declarations. If false, the stylesheet |
| 549 | * is treated as schema-aware only if it contains one or more xsl:import-schema declarations |
| 550 | * @since 9.2 |
| 551 | */ |
| 552 | |
| 553 | public void setSchemaAware(boolean schemaAware) { |
| 554 | this.schemaAware = schemaAware; |
| 555 | } |
| 556 | |
| 557 | /** |
| 558 | * Ask whether schema-awareness has been requested by means of a call on |
| 559 | * {@link #setSchemaAware} |
| 560 | * |
| 561 | * @return true if schema-awareness has been requested |
| 562 | */ |
| 563 | |
| 564 | public boolean isSchemaAware() { |
| 565 | return schemaAware; |
| 566 | } |
| 567 | |
| 568 | /** |
| 569 | * Set the default initial template name for a stylesheet compiled using this CompilerInfo. |
| 570 | * This is only a default; it can be overridden when the stylesheet is executed |
| 571 | * |
| 572 | * @param initialTemplate the name of the default initial template, or null if there is |
| 573 | * no default. No error occurs (until run-time) if the stylesheet does not contain a template |
| 574 | * with this name. |
| 575 | * @since 9.3 |
| 576 | */ |
| 577 | |
| 578 | public void setDefaultInitialTemplate(StructuredQName initialTemplate) { |
| 579 | defaultInitialTemplate = initialTemplate; |
| 580 | } |
| 581 | |
| 582 | /** |
| 583 | * Get the default initial template name for a stylesheet compiled using this CompilerInfo. |
| 584 | * This is only a default; it can be overridden when the stylesheet is executed |
| 585 | * |
| 586 | * @return the name of the default initial template, or null if there is |
| 587 | * no default, as set using {@link #setDefaultInitialTemplate} |
| 588 | * @since 9.3 |
| 589 | */ |
| 590 | |
| 591 | public StructuredQName getDefaultInitialTemplate() { |
| 592 | return defaultInitialTemplate; |
| 593 | } |
| 594 | |
| 595 | /** |
| 596 | * Set the default initial mode name for a stylesheet compiled using this CompilerInfo. |
| 597 | * This is only a default; it can be overridden when the stylesheet is executed |
| 598 | * |
| 599 | * @param initialMode the name of the default initial mode, or null if there is |
| 600 | * no default. No error occurs (until run-time) if the stylesheet does not contain a mode |
| 601 | * with this name. |
| 602 | * @since 9.3 |
| 603 | */ |
| 604 | |
| 605 | public void setDefaultInitialMode(StructuredQName initialMode) { |
| 606 | defaultInitialMode = initialMode; |
| 607 | } |
| 608 | |
| 609 | /** |
| 610 | * Get the default initial mode name for a stylesheet compiled using this CompilerInfo. |
| 611 | * This is only a default; it can be overridden when the stylesheet is executed |
| 612 | * |
| 613 | * @return the name of the default initial mode, or null if there is |
| 614 | * no default, as set using {@link #setDefaultInitialMode} |
| 615 | * @since 9.3 |
| 616 | */ |
| 617 | |
| 618 | public StructuredQName getDefaultInitialMode() { |
| 619 | return defaultInitialMode; |
| 620 | } |
| 621 | |
| 622 | /** |
| 623 | * Set the version of XSLT to be supported by this processor. From Saxon 9.8 this has |
| 624 | * no effect; the processor will always be an XSLT 3.0 processor. |
| 625 | * |
| 626 | * @param version The decimal version number times ten, for example 30 indicates |
| 627 | * XSLT 3.0. |
| 628 | * @since 9.3. Changed in 9.7 to take an integer rather than a decimal. Ignored from 9.8. |
| 629 | * @deprecated since Saxon 9.8 (has no effect). |
| 630 | */ |
| 631 | |
| 632 | public void setXsltVersion(int version) { |
| 633 | } |
| 634 | |
| 635 | /** |
| 636 | * Get the version of XSLT requested for this compilation. |
| 637 | * |
| 638 | * @return 30 (for XSLT 3.0) |
| 639 | * @since 9.3 Changed in 9.7 to take an integer rather than a decimal. Changed in 9.8 to return the |
| 640 | * value 30 unconditionally. |
| 641 | * @deprecated since 9.8 (always returns 30) |
| 642 | */ |
| 643 | |
| 644 | public int getXsltVersion() { |
| 645 | return 30; |
| 646 | } |
| 647 | |
| 648 | /** |
| 649 | * Set a library of extension functions. The functions in this library will be available |
| 650 | * in all modules of the stylesheet. The function library will be searched after language-defined |
| 651 | * libraries (such as built-in functions, user-defined XQuery functions, and constructor |
| 652 | * functions) but before extension functions defined at the Configuration level. |
| 653 | * |
| 654 | * @param library the function library to be added (replacing any that has previously been set). |
| 655 | * May be null to clear a previously-set library |
| 656 | * @since 9.4 |
| 657 | * @deprecated since 9.7. Any extension function library set using this mechanism will |
| 658 | * not be available if the package is saved and reloaded. |
| 659 | */ |
| 660 | |
| 661 | public void setExtensionFunctionLibrary(/*@Nullable*/ FunctionLibrary library) { |
| 662 | this.extensionFunctionLibrary = library; |
| 663 | } |
| 664 | |
| 665 | /** |
| 666 | * Get any function library that was previously set using |
| 667 | * {@link #setExtensionFunctionLibrary(net.sf.saxon.functions.FunctionLibrary)}. |
| 668 | * |
| 669 | * @return the extension function library, or null if none has been set. |
| 670 | * @since 9.4 |
| 671 | */ |
| 672 | |
| 673 | |
| 674 | /*@Nullable*/ |
| 675 | public FunctionLibrary getExtensionFunctionLibrary() { |
| 676 | return extensionFunctionLibrary; |
| 677 | } |
| 678 | |
| 679 | public void setXQueryLibraries(Collection<QueryLibrary> libraries) { |
| 680 | this.queryLibraries = libraries; |
| 681 | } |
| 682 | |
| 683 | public Collection<QueryLibrary> getQueryLibraries() { |
| 684 | return queryLibraries; |
| 685 | } |
| 686 | |
| 687 | } |
| 688 |