javax.xml.transform

Interface Templates

public interface Templates

An object that implements this interface is the runtime representation of processed transformation instructions.

Templates must be threadsafe for a given instance over multiple threads running concurrently, and may be used multiple times in a given session.

Method Summary

Properties
getOutputProperties()
Get the properties corresponding to the effective xsl:output element.
Transformer
newTransformer()
Create a new transformation context for this Templates object.

Method Details

getOutputProperties

public 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.
Usages and Demos :

View More Examples of getOutputProperties()
   1: import javax.xml.transform.Transformer;
   2: import javax.xml.transform.Templates;
   3: 
   4:         ...
   5: public class TRAXTemplatesImpl implements TRAXTemplates {
   6:     private Templates templates;
   7:     XMLResolvingService resolvingService;
   8:         ...
   9:     public Properties getOutputProperties(){
  10:         return templates.getOutputProperties();
  11:     }

View Full Code Here
   1:         try {
   2:             Templates pss = tryCache(style);
   3:             Transformer transformer = pss.newTransformer();
   4:         ...
   5:             Properties details = pss.getOutputProperties();
   6: 
   7:         ...
   8:             String mime = pss.getOutputProperties().getProperty(OutputKeys.MEDIA_TYPE);
   9:             if (mime==null) {
  10:         ...
  11: 
  12:     private synchronized Templates tryCache(String url) throws TransformerException, java.io.IOException {

View Full Code Here
   1: import javax.xml.transform.Source;
   2: import javax.xml.transform.Templates;
   3: import javax.xml.transform.Transformer;
   4:         ...
   5: 
   6:             Templates templates = null;
   7:             Transformer transformer;
   8:         ...
   9:             else
  10:                 mimeType = templates.getOutputProperties().getProperty(OutputKeys.MEDIA_TYPE);
  11:             if (mimeType == null) {

View Full Code Here
   1: 
   2:                 Templates sheet = factory.newTemplates(styleSource);
   3: 
   4:         ...
   5:     private File makeOutputFile(File directory, String localName,
   6:                                  Templates sheet) {
   7:         ...
   8:         String mediaType = sheet.getOutputProperties().getProperty(
   9:                                     OutputKeys.MEDIA_TYPE);
  10:         ...
  11:         Source style = factory.getAssociatedStylesheet(sourceInput, null, null, null);
  12:         Templates sheet = factory.newTemplates(style);

View Full Code Here
   1:     private File makeOutputFile(File directory, String localName,
   2:                                  Templates sheet) {
   3:         ...
   4:         String mediaType = sheet.getOutputProperties().getProperty(
   5:                                     OutputKeys.MEDIA_TYPE);
   6:         ...
   7:         Source style = factory.getAssociatedStylesheet(sourceInput, null, null, null);
   8:         Templates sheet = factory.newTemplates(style);
   9:         if (showTime) {
  10:         ...
  11:     public void processDirectory(
  12:         List sources, Templates sheet, File outputDir, ArrayList parameterList, String initialMode)

View Full Code Here

newTransformer

public Transformer newTransformer()
            throws TransformerConfigurationException
Create a new transformation context for this Templates object.
Returns:
A valid non-null instance of a Transformer.
Throws:
TransformerConfigurationException - if a Transformer can not be created.
Usages and Demos :

View More Examples of newTransformer()
   1:     : transformerCreation(source) && target(tFactory) {
   2:     Templates templates = (Templates)_cache.get(source.getSystemId());
   3:         ...
   4:     if (templates == null) {
   5:         templates = tFactory.newTemplates(source);
   6:         ...
   7:     }
   8:     return templates.newTransformer();
   9:     }

View Full Code Here
   1: package ru.arptek.arpsite.templates.selectors;
   2: 
   3:         ...
   4: 
   5: import javax.xml.transform.Templates;
   6: import javax.xml.transform.Transformer;
   7:         ...
   8: 
   9: import ru.arptek.arpsite.templates.DependencyListener;
  10: import ru.arptek.arpsite.templates.TransformerSelector;
  11:         ...
  12:             throws TransformerConfigurationException {
  13:         Transformer result = templates.newTransformer();

View Full Code Here
   1: 
   2: import javax.xml.transform.Templates;
   3: import javax.xml.transform.Transformer;
   4:         ...
   5:         xFactory.setAttribute("use-classpath",Boolean.TRUE);
   6:         Templates templates = null;
   7:         Transformer xformer = null;
   8:         ...
   9:             templates = xFactory.newTemplates(transletSource);
  10:             xformer = templates.newTransformer();
  11:         } catch (TransformerConfigurationException tce) {

View Full Code Here
   1: import javax.xml.transform.Source;
   2: import javax.xml.transform.Templates;
   3: import javax.xml.transform.Transformer;
   4:         ...
   5: 
   6:             Templates template = factory.newTemplates(new StreamSource(xsltStream));
   7: 
   8:         ...
   9:             Transformer xformer = template.newTransformer();

View Full Code Here
   1: 
   2: import javax.xml.transform.Templates;
   3: import javax.xml.transform.Transformer;
   4:         ...
   5:         xFactory.setAttribute("generate-translet",Boolean.TRUE);
   6:         Templates translet = null;
   7:         try {
   8:         ...
   9:         try {
  10:             xformer = translet.newTransformer();
  11:         } catch (TransformerConfigurationException tce) {

View Full Code Here