Templates
Stay organized with collections
Save and categorize content based on your preferences.
An object that implements this interface is the runtime representation of processed
transformation instructions.
Templates must be thread-safe for a given instance
over multiple threads running concurrently, and may
be used multiple times in a given session.
Public Methods
public
abstract
Properties
getOutputProperties
()
Get the properties corresponding to the effective xsl:output element.
The object returned will
be a clone of the internal values. Accordingly, it can be mutated
without mutating the Templates object, and then handed in to
Transformer.setOutputProperties(Properties)
.
The properties returned should contain properties set by the stylesheet,
and these properties are "defaulted" by default properties specified by
section 16 of the
XSL Transformations (XSLT) W3C Recommendation. The properties that
were specifically set by the stylesheet should be in the base
Properties list, while the XSLT default properties that were not
specifically set should be in the "default" Properties list. Thus,
getOutputProperties().getProperty(String key) will obtain any
property in that was set by the stylesheet, or the default
properties, while
getOutputProperties().get(String key) will only retrieve properties
that were explicitly set in the stylesheet.
For XSLT,
Attribute
Value Templates attribute values will
be returned unexpanded (since there is no context at this point). The
namespace prefixes inside Attribute Value Templates will be unexpanded,
so that they remain valid XPath values.
Returns
- A Properties object, never null.
Create a new transformation context for this Templates object.
Returns
- A valid non-null instance of a Transformer.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eTemplates\u003c/code\u003e interface represents processed transformation instructions and must be thread-safe.\u003c/p\u003e\n"],["\u003cp\u003eIt provides access to output properties defined in the stylesheet or defaulted by XSLT specifications using \u003ccode\u003egetOutputProperties()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt enables the creation of new transformation contexts via \u003ccode\u003enewTransformer()\u003c/code\u003e, which can throw a \u003ccode\u003eTransformerConfigurationException\u003c/code\u003e if unsuccessful.\u003c/p\u003e\n"]]],[],null,["# Templates\n\npublic interface **Templates** \nAn object that implements this interface is the runtime representation of processed\ntransformation instructions.\n\nTemplates must be thread-safe for a given instance\nover multiple threads running concurrently, and may\nbe used multiple times in a given session.\n\n\u003cbr /\u003e\n\n### Public Method Summary\n\n|------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Properties](../../../../reference/java/util/Properties.html) | [getOutputProperties](../../../../reference/javax/xml/transform/Templates.html#getOutputProperties())() Get the properties corresponding to the effective xsl:output element. |\n| abstract [Transformer](../../../../reference/javax/xml/transform/Transformer.html) | [newTransformer](../../../../reference/javax/xml/transform/Templates.html#newTransformer())() Create a new transformation context for this Templates object. |\n\nPublic Methods\n--------------\n\n#### public abstract [Properties](../../../../reference/java/util/Properties.html)\n**getOutputProperties**\n()\n\nGet the properties corresponding to the effective xsl:output element.\nThe object returned will\nbe a clone of the internal values. Accordingly, it can be mutated\nwithout mutating the Templates object, and then handed in to\n[Transformer.setOutputProperties(Properties)](../../../../reference/javax/xml/transform/Transformer.html#setOutputProperties(java.util.Properties)).\n\nThe properties returned should contain properties set by the stylesheet,\nand these properties are \"defaulted\" by default properties specified by\n[section 16 of the\nXSL Transformations (XSLT) W3C Recommendation](http://www.w3.org/TR/xslt#output). The properties that\nwere specifically set by the stylesheet should be in the base\nProperties list, while the XSLT default properties that were not\nspecifically set should be in the \"default\" Properties list. Thus,\ngetOutputProperties().getProperty(String key) will obtain any\nproperty in that was set by the stylesheet, *or* the default\nproperties, while\ngetOutputProperties().get(String key) will only retrieve properties\nthat were explicitly set in the stylesheet.\n\nFor XSLT,\n[Attribute\nValue Templates](http://www.w3.org/TR/xslt#attribute-value-templates) attribute values will\nbe returned unexpanded (since there is no context at this point). The\nnamespace prefixes inside Attribute Value Templates will be unexpanded,\nso that they remain valid XPath values.\n\n\u003cbr /\u003e\n\n##### Returns\n\n- A Properties object, never null. \n\n#### public abstract [Transformer](../../../../reference/javax/xml/transform/Transformer.html)\n**newTransformer**\n()\n\nCreate a new transformation context for this Templates object. \n\n##### Returns\n\n- A valid non-null instance of a Transformer. \n\n##### Throws\n\n| [TransformerConfigurationException](../../../../reference/javax/xml/transform/TransformerConfigurationException.html) | if a Transformer can not be created. |\n|-----------------------------------------------------------------------------------------------------------------------|--------------------------------------|"]]