| 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.packages; |
| 9 | |
| 10 | import net.sf.saxon.om.GroundedValue; |
| 11 | import net.sf.saxon.om.Item; |
| 12 | import net.sf.saxon.om.StructuredQName; |
| 13 | import net.sf.saxon.style.StylesheetPackage; |
| 14 | |
| 15 | import javax.xml.transform.Source; |
| 16 | import java.util.Map; |
| 17 | |
| 18 | /** |
| 19 | * Information about a package held in a package library; the package may or may not be loaded in memory |
| 20 | */ |
| 21 | public class PackageDetails { |
| 22 | /** |
| 23 | * The name and version number of the package |
| 24 | */ |
| 25 | public VersionedPackageName nameAndVersion; |
| 26 | /** |
| 27 | * The original package name, as defined by the <code>@base</code> attribute in the |
| 28 | * configuration file. |
| 29 | * |
| 30 | * <p>Required only if the package name defined in the name attribute differs from the |
| 31 | * package name in the XSLT source. If present, the value must match the package name |
| 32 | * defined in the XSLT source. Using this attribute allows packages to be renamed. |
| 33 | * This is useful when a package has static parameters whose values are bound in child |
| 34 | * withParam elements: it allows two instances of a package to be made available (under |
| 35 | * different names) with different bindings for the static parameters.</p> |
| 36 | */ |
| 37 | public String baseName; |
| 38 | /** |
| 39 | * A short name for the package. Useful when nominating the package as the value of |
| 40 | * the -xsl option on the command line. |
| 41 | * |
| 42 | * <p>Any convenient short name for the package name/version combination. |
| 43 | * This can be used for convenience as the value of the -xsl option on the Transform |
| 44 | * command line. (We suggest using a value that is unlikely to be confused with a |
| 45 | * filename, for example * if the same stylesheet package is used all the time.)</p> |
| 46 | */ |
| 47 | public String shortName; |
| 48 | /** |
| 49 | * The executable form of the compiled package |
| 50 | */ |
| 51 | public StylesheetPackage loadedPackage; |
| 52 | /** |
| 53 | * A Source object identifying a location where the source XSLT code of the package |
| 54 | * is to be found. Note that in general a Source is consumed by use (so it can only |
| 55 | * be read once); the sourceLocation is therefore typically useless once a loadedPackage |
| 56 | * exists. |
| 57 | */ |
| 58 | public Source sourceLocation; |
| 59 | /** |
| 60 | * A Source object identifying a location where the compiled SEF code of the package |
| 61 | * is to be found. Note that in general a Source is consumed by use (so it can only |
| 62 | * be read once); the exportLocation is therefore typically useless once a loadedPackage |
| 63 | * exists. |
| 64 | */ |
| 65 | public Source exportLocation; |
| 66 | /** |
| 67 | * The priority of this version of a package relative to other versions of the same |
| 68 | * package. By default (if two versions have the same priority), the higher version |
| 69 | * is used. This attribute allows (for example) version 2.0.10 to be marked as the preferred |
| 70 | * release even if a version 3.0-beta is available, by giving the two versions different |
| 71 | * priority. A numerically higher value indicates a higher priority. |
| 72 | */ |
| 73 | public Integer priority; |
| 74 | /** |
| 75 | * The values of static stylesheet parameters for this package instance. In a function |
| 76 | * library, two instances of the same package may exist with different settings for |
| 77 | * stylesheet parameters, but they must then be given an alias package name. The nameAndVersion |
| 78 | * contains this alias; the baseName contains the original name as defined in the XSLT source |
| 79 | * code. |
| 80 | */ |
| 81 | public Map<StructuredQName, GroundedValue<?>> staticParams; |
| 82 | /** |
| 83 | * During processing (compilation) of a package, the <code>beingProcessed</code> field |
| 84 | * indicates the thread in which this processing is taking place; at other times, the field |
| 85 | * is null. This field is used when checking for cycles of package dependencies. |
| 86 | */ |
| 87 | public Thread beingProcessed; |
| 88 | } |
| 89 |