Stay organized with collections
Save and categorize content based on your preferences.
Templates
public
interface
Templates
javax.xml.transform.Templates
|
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.
Summary
Public methods
getOutputProperties
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 |
Properties |
A Properties object, never null. |
public abstract Transformer newTransformer ()
Create a new transformation context for this Templates object.
Returns |
Transformer |
A valid non-null instance of a Transformer. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-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 2025-02-10 UTC."],[],[],null,["# Templates\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nTemplates\n=========\n\n\n`\npublic\n\n\ninterface\nTemplates\n`\n\n\n`\n\n\n`\n\n|-------------------------------|\n| javax.xml.transform.Templates |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\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\nSummary\n-------\n\n| ### Public methods ||\n|-----------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract `[Properties](/reference/java/util/Properties) | ` `[getOutputProperties](/reference/javax/xml/transform/Templates#getOutputProperties())`() ` Get the properties corresponding to the effective xsl:output element. |\n| ` abstract `[Transformer](/reference/javax/xml/transform/Transformer) | ` `[newTransformer](/reference/javax/xml/transform/Templates#newTransformer())`() ` Create a new transformation context for this Templates object. |\n\nPublic methods\n--------------\n\n### getOutputProperties\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract Properties 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#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\u003cbr /\u003e\n\n| Returns ||\n|-----------------------------------------------|-----------------------------------------|\n| [Properties](/reference/java/util/Properties) | A Properties object, never null. \u003cbr /\u003e |\n\n### newTransformer\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract Transformer newTransformer ()\n```\n\nCreate a new transformation context for this Templates object.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----------------------------------------------------------|----------------------------------------------------|\n| [Transformer](/reference/javax/xml/transform/Transformer) | A valid non-null instance of a Transformer. \u003cbr /\u003e |\n\n| Throws ||\n|-------------------------------------------------------------------------------------------------------|--------------------------------------|\n| [TransformerConfigurationException](/reference/javax/xml/transform/TransformerConfigurationException) | if a Transformer can not be created. |"]]