org.apache.xalan.templates
Class OutputProperties

java.lang.Object
  extended byorg.apache.xml.utils.UnImplNode
      extended byorg.apache.xalan.templates.ElemTemplateElement
          extended byorg.apache.xalan.templates.OutputProperties
All Implemented Interfaces:
Cloneable, org.w3c.dom.Document, org.w3c.dom.Element, ExpressionNode, org.w3c.dom.Node, org.w3c.dom.NodeList, PrefixResolver, Serializable, javax.xml.transform.SourceLocator, WhitespaceStrippingElementMatcher, XSLTVisitable

public class OutputProperties
extends ElemTemplateElement
implements Cloneable

This class provides information from xsl:output elements. It is mainly a wrapper for Properties, but can not extend that class because it must be part of the ElemTemplateElement heararchy.

An OutputProperties list can contain another OutputProperties list as its "defaults"; this second property list is searched if the property key is not found in the original property list.

See Also:
XSLT DTD, xsl:output in XSLT Specification, Serialized Form

Field Summary
private static Properties m_html_properties
          The default properties when method="html".
private  Properties m_properties
          The output properties.
private  Hashtable m_propertiesLevels
          This ugly field is used during recomposition to track the import precedence at which each attribute was first specified, so we can flag errors about values being set multiple time at the same precedence level.
private static Integer m_synch_object
          Synchronization object for lazy initialization of the above tables.
private static Properties m_text_properties
          The default properties when method="text".
private static Properties m_xml_properties
          The default properties of all output files.
private static Class[] NO_CLASSES
          a zero length Class array used in loadPropertiesFile()
private static Object[] NO_OBJS
          a zero length Object array used in loadPropertiesFile()
(package private) static String S_BUILTIN_EXTENSIONS_UNIVERSAL
          Built-in extensions namespace, reexpressed in {namespaceURI} syntax suitable for prepending to a localname to produce a "universal name".
(package private) static String S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL
          The old built-in extension namespace
(package private) static int S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL_LEN
           
static String S_KEY_CONTENT_HANDLER
          Fully qualified name of class with a default constructor that implements the ContentHandler interface, where the result tree events will be sent to.
static String S_KEY_ENTITIES
          File name of file that specifies character to entity reference mappings.
static String S_KEY_INDENT_AMOUNT
          The number of whitespaces to indent by, if indent="yes".
static String S_OMIT_META_TAG
          Use a value of "yes" if the META tag should be omitted where it would otherwise be supplied.
static String S_USE_URL_ESCAPING
          Use a value of "yes" if the href values for HTML serialization should use %xx escaping.
(package private) static String S_XALAN_PREFIX
           
(package private) static int S_XALAN_PREFIX_LEN
           
(package private) static String S_XSLT_PREFIX
           
(package private) static int S_XSLT_PREFIX_LEN
           
 
Fields inherited from class org.apache.xalan.templates.ElemTemplateElement
m_docOrderNumber, m_firstChild, m_hasVariableDecl, m_nextSibling, m_parentNode, m_prefixTable
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
OutputProperties()
          Creates an empty OutputProperties with no default values.
OutputProperties(Properties defaults)
          Creates an empty OutputProperties with the specified defaults.
OutputProperties(String method)
          Creates an empty OutputProperties with the defaults specified by a property file.
 
Method Summary
private  void checkDuplicates(OutputProperties newProps)
          Check to see if a set of properties is at the same import level as the last set of properties set that was passed as an argument to this method.
 Object clone()
          Clone this OutputProperties, including a clone of the wrapped Properties reference.
 void compose(StylesheetRoot sroot)
          This function is called after everything else has been recomposed, and allows the template to set remaining values that may be based on some other property that depends on recomposition.
 void copyFrom(OutputProperties opsrc)
          Copy the keys and values from the source to this object.
 void copyFrom(Properties src)
          Copy the keys and values from the source to this object.
 void copyFrom(Properties src, boolean shouldResetDefaults)
          Copy the keys and values from the source to this object.
private static String fixupPropertyString(String s, boolean doClipping)
          Fix up a string in an output properties file according to the rules of loadPropertiesFile(java.lang.String, java.util.Properties).
 boolean getBooleanProperty(QName key)
          Searches for the boolean property with the specified key in the property list.
 boolean getBooleanProperty(String key)
          Searches for the boolean property with the specified key in the property list.
static boolean getBooleanProperty(String key, Properties props)
          Searches for the boolean property with the specified key in the property list.
static Properties getDefaultMethodProperties(String method)
          Creates an empty OutputProperties with the defaults specified by a property file.
 int getIntProperty(QName key)
          Searches for the int property with the specified key in the property list.
 int getIntProperty(String key)
          Searches for the int property with the specified key in the property list.
static int getIntProperty(String key, Properties props)
          Searches for the int property with the specified key in the property list.
 Properties getProperties()
          Get the Properties object that this class wraps.
 String getProperty(QName key)
          Searches for the property with the specified key in the property list.
 String getProperty(String key)
          Searches for the property with the specified key in the property list.
 Vector getQNameProperties(QName key)
          Searches for the list of qname properties with the specified key in the property list.
 Vector getQNameProperties(String key)
          Searches for the list of qname properties with the specified key in the property list.
static Vector getQNameProperties(String key, Properties props)
          Searches for the list of qname properties with the specified key in the property list.
 QName getQNameProperty(QName key)
          Searches for the qname property with the specified key in the property list.
 QName getQNameProperty(String key)
          Searches for the qname property with the specified key in the property list.
static QName getQNameProperty(String key, Properties props)
          Searches for the qname property with the specified key in the property list.
 boolean isLegalPropertyKey(String key)
          Report if the key given as an argument is a legal xsl:output key.
private static Properties loadPropertiesFile(String resourceName, Properties defaults)
          Load the properties file from a resource stream.
 void recompose(StylesheetRoot root)
          This function is called to recompose all of the output format extended elements.
 void setBooleanProperty(QName key, boolean value)
          Set an output property.
 void setBooleanProperty(String key, boolean value)
          Set an output property.
 void setIntProperty(QName key, int value)
          Set an output property.
 void setIntProperty(String key, int value)
          Set an output property.
 void setMethodDefaults(String method)
          Reset the default properties based on the method.
 void setProperty(QName key, String value)
          Set an output property.
 void setProperty(String key, String value)
          Set an output property.
 void setQNameProperties(QName key, Vector v)
          Set an output property with a QName list value.
 void setQNameProperties(String key, Vector v)
          Set an output property with a QName list value.
 void setQNameProperty(QName key, QName value)
          Set an output property with a QName value.
 void setQNameProperty(String key, QName value)
          Set an output property with a QName value.
 
Methods inherited from class org.apache.xalan.templates.ElemTemplateElement
accept, addOrReplaceDecls, appendChild, appendChild, callChildVisitors, callChildVisitors, callVisitors, canAcceptVariables, canStripWhiteSpace, compareTo, containsExcludeResultPrefix, endCompose, error, error, execute, executeNSDecls, executeNSDecls, exprAddChild, exprGetChild, exprGetNumChildren, exprGetParent, exprSetParent, getBaseIdentifier, getChildNodes, getColumnNumber, getDeclaredPrefixes, getDOMBackPointer, getFirstChild, getFirstChildElem, getLastChild, getLastChildElem, getLength, getLineNumber, getLocalName, getNamespaceForPrefix, getNamespaceForPrefix, getNextSibling, getNextSiblingElem, getNodeName, getNodeType, getOwnerDocument, getOwnerXSLTemplate, getParentElem, getParentNode, getParentNodeElem, getPrefixes, getPreviousSibling, getPreviousSiblingElem, getPublicId, getStylesheet, getStylesheetComposed, getStylesheetRoot, getSystemId, getTagName, getUid, getXmlSpace, getXSLToken, handlesNullPrefixes, hasChildNodes, hasTextLitOnly, hasVariableDecl, insertBefore, isCompiledTemplate, isValidNCName, item, needToCheckExclude, removeChild, replaceChild, replaceChild, resolvePrefixTables, runtimeInit, setDOMBackPointer, setLocaterInfo, setParentElem, setPrefixes, setPrefixes, setUid, setXmlSpace, shouldStripWhiteSpace, unexecuteNSDecls, unexecuteNSDecls
 
Methods inherited from class org.apache.xml.utils.UnImplNode
adoptNode, appendData, cloneNode, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getDoctype, getDocumentElement, getElementById, getElementsByTagName, getElementsByTagNameNS, getEncoding, getImplementation, getNamespaceURI, getNodeValue, getOwnerElement, getPrefix, getSpecified, getStandalone, getStrictErrorChecking, getVersion, hasAttribute, hasAttributeNS, hasAttributes, importNode, insertData, isSupported, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceData, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setEncoding, setNodeValue, setPrefix, setStandalone, setStrictErrorChecking, setValue, setVersion, splitText, substringData
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

S_XSLT_PREFIX

static final String S_XSLT_PREFIX
See Also:
Constant Field Values

S_XSLT_PREFIX_LEN

static final int S_XSLT_PREFIX_LEN

S_XALAN_PREFIX

static final String S_XALAN_PREFIX
See Also:
Constant Field Values

S_XALAN_PREFIX_LEN

static final int S_XALAN_PREFIX_LEN

S_BUILTIN_EXTENSIONS_UNIVERSAL

static final String S_BUILTIN_EXTENSIONS_UNIVERSAL
Built-in extensions namespace, reexpressed in {namespaceURI} syntax suitable for prepending to a localname to produce a "universal name".

See Also:
Constant Field Values

S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL

static final String S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL
The old built-in extension namespace

See Also:
Constant Field Values

S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL_LEN

static final int S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL_LEN

m_propertiesLevels

private transient Hashtable m_propertiesLevels
This ugly field is used during recomposition to track the import precedence at which each attribute was first specified, so we can flag errors about values being set multiple time at the same precedence level. Note that this field is only used during recomposition, with the OutputProperties object owned by the StylesheetRoot object.


m_properties

private Properties m_properties
The output properties.


S_KEY_INDENT_AMOUNT

public static String S_KEY_INDENT_AMOUNT
The number of whitespaces to indent by, if indent="yes".


S_KEY_CONTENT_HANDLER

public static String S_KEY_CONTENT_HANDLER
Fully qualified name of class with a default constructor that implements the ContentHandler interface, where the result tree events will be sent to.


S_KEY_ENTITIES

public static String S_KEY_ENTITIES
File name of file that specifies character to entity reference mappings.


S_USE_URL_ESCAPING

public static String S_USE_URL_ESCAPING
Use a value of "yes" if the href values for HTML serialization should use %xx escaping.


S_OMIT_META_TAG

public static String S_OMIT_META_TAG
Use a value of "yes" if the META tag should be omitted where it would otherwise be supplied.


m_xml_properties

private static Properties m_xml_properties
The default properties of all output files.


m_html_properties

private static Properties m_html_properties
The default properties when method="html".


m_text_properties

private static Properties m_text_properties
The default properties when method="text".


m_synch_object

private static Integer m_synch_object
Synchronization object for lazy initialization of the above tables.


NO_CLASSES

private static final Class[] NO_CLASSES
a zero length Class array used in loadPropertiesFile()


NO_OBJS

private static final Object[] NO_OBJS
a zero length Object array used in loadPropertiesFile()

Constructor Detail

OutputProperties

public OutputProperties()
Creates an empty OutputProperties with no default values.


OutputProperties

public OutputProperties(Properties defaults)
Creates an empty OutputProperties with the specified defaults.

Parameters:
defaults - the defaults.

OutputProperties

public OutputProperties(String method)
Creates an empty OutputProperties with the defaults specified by a property file. The method argument is used to construct a string of the form output_[method].properties (for instance, output_html.properties). The output_xml.properties file is always used as the base.

At the moment, anything other than 'text', 'xml', and 'html', will use the output_xml.properties file.

Parameters:
method - non-null reference to method name.
Method Detail

fixupPropertyString

private static String fixupPropertyString(String s,
                                          boolean doClipping)
Fix up a string in an output properties file according to the rules of loadPropertiesFile(java.lang.String, java.util.Properties).

Parameters:
s - non-null reference to string that may need to be fixed up.
Returns:
A new string if fixup occured, otherwise the s argument.

loadPropertiesFile

private static Properties loadPropertiesFile(String resourceName,
                                             Properties defaults)
                                      throws IOException
Load the properties file from a resource stream. If a key name such as "org.apache.xslt.xxx", fix up the start of string to be a curly namespace. If a key name starts with "xslt.output.xxx", clip off "xslt.output.". If a key name *or* a key value is discovered, check for : in the text, and fix it up to be ":", since earlier versions of the JDK do not handle the escape sequence (at least in key names).

Parameters:
resourceName - non-null reference to resource name.
defaults - Default properties, which may be null.
Throws:
IOException

getDefaultMethodProperties

public static Properties getDefaultMethodProperties(String method)
Creates an empty OutputProperties with the defaults specified by a property file. The method argument is used to construct a string of the form output_[method].properties (for instance, output_html.properties). The output_xml.properties file is always used as the base.

At the moment, anything other than 'text', 'xml', and 'html', will use the output_xml.properties file.

Parameters:
method - non-null reference to method name.
Returns:
Properties object that holds the defaults for the given method.

clone

public Object clone()
Clone this OutputProperties, including a clone of the wrapped Properties reference.

Overrides:
clone in class Object
Returns:
A new OutputProperties reference, mutation of which should not effect this object.
See Also:
Cloneable

setProperty

public void setProperty(QName key,
                        String value)
Set an output property.

Parameters:
key - the key to be placed into the property list.
value - the value corresponding to key.
See Also:
OutputKeys

setProperty

public void setProperty(String key,
                        String value)
Set an output property.

Parameters:
key - the key to be placed into the property list.
value - the value corresponding to key.
See Also:
OutputKeys

getProperty

public String getProperty(QName key)
Searches for the property with the specified key in the property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.

Parameters:
key - the property key.
Returns:
the value in this property list with the specified key value.

getProperty

public String getProperty(String key)
Searches for the property with the specified key in the property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.

Parameters:
key - the property key.
Returns:
the value in this property list with the specified key value.

setBooleanProperty

public void setBooleanProperty(QName key,
                               boolean value)
Set an output property.

Parameters:
key - the key to be placed into the property list.
value - the value corresponding to key.
See Also:
OutputKeys

setBooleanProperty

public void setBooleanProperty(String key,
                               boolean value)
Set an output property.

Parameters:
key - the key to be placed into the property list.
value - the value corresponding to key.
See Also:
OutputKeys

getBooleanProperty

public boolean getBooleanProperty(QName key)
Searches for the boolean property with the specified key in the property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns false if the property is not found, or if the value is other than "yes".

Parameters:
key - the property key.
Returns:
the value in this property list as a boolean value, or false if null or not "yes".

getBooleanProperty

public boolean getBooleanProperty(String key)
Searches for the boolean property with the specified key in the property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns false if the property is not found, or if the value is other than "yes".

Parameters:
key - the property key.
Returns:
the value in this property list as a boolean value, or false if null or not "yes".

getBooleanProperty

public static boolean getBooleanProperty(String key,
                                         Properties props)
Searches for the boolean property with the specified key in the property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns false if the property is not found, or if the value is other than "yes".

Parameters:
key - the property key.
props - the list of properties that will be searched.
Returns:
the value in this property list as a boolean value, or false if null or not "yes".

setIntProperty

public void setIntProperty(QName key,
                           int value)
Set an output property.

Parameters:
key - the key to be placed into the property list.
value - the value corresponding to key.
See Also:
OutputKeys

setIntProperty

public void setIntProperty(String key,
                           int value)
Set an output property.

Parameters:
key - the key to be placed into the property list.
value - the value corresponding to key.
See Also:
OutputKeys

getIntProperty

public int getIntProperty(QName key)
Searches for the int property with the specified key in the property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns false if the property is not found, or if the value is other than "yes".

Parameters:
key - the property key.
Returns:
the value in this property list as a int value, or false if null or not a number.

getIntProperty

public int getIntProperty(String key)
Searches for the int property with the specified key in the property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns false if the property is not found, or if the value is other than "yes".

Parameters:
key - the property key.
Returns:
the value in this property list as a int value, or false if null or not a number.

getIntProperty

public static int getIntProperty(String key,
                                 Properties props)
Searches for the int property with the specified key in the property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns false if the property is not found, or if the value is other than "yes".

Parameters:
key - the property key.
props - the list of properties that will be searched.
Returns:
the value in this property list as a int value, or 0 if null or not a number.

setQNameProperty

public void setQNameProperty(QName key,
                             QName value)
Set an output property with a QName value. The QName will be turned into a string with the namespace in curly brackets.

Parameters:
key - the key to be placed into the property list.
value - the value corresponding to key.
See Also:
OutputKeys

setMethodDefaults

public void setMethodDefaults(String method)
Reset the default properties based on the method.

Parameters:
method - the method value.
See Also:
OutputKeys

setQNameProperty

public void setQNameProperty(String key,
                             QName value)
Set an output property with a QName value. The QName will be turned into a string with the namespace in curly brackets.

Parameters:
key - the key to be placed into the property list.
value - the value corresponding to key.
See Also:
OutputKeys

getQNameProperty

public QName getQNameProperty(QName key)
Searches for the qname property with the specified key in the property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.

Parameters:
key - the property key.
Returns:
the value in this property list as a QName value, or false if null or not "yes".

getQNameProperty

public QName getQNameProperty(String key)
Searches for the qname property with the specified key in the property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.

Parameters:
key - the property key.
Returns:
the value in this property list as a QName value, or false if null or not "yes".

getQNameProperty

public static QName getQNameProperty(String key,
                                     Properties props)
Searches for the qname property with the specified key in the property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.

Parameters:
key - the property key.
props - the list of properties to search in.
Returns:
the value in this property list as a QName value, or false if null or not "yes".

setQNameProperties

public void setQNameProperties(QName key,
                               Vector v)
Set an output property with a QName list value. The QNames will be turned into strings with the namespace in curly brackets.

Parameters:
key - the key to be placed into the property list.
v - non-null list of QNames corresponding to key.
See Also:
OutputKeys

setQNameProperties

public void setQNameProperties(String key,
                               Vector v)
Set an output property with a QName list value. The QNames will be turned into strings with the namespace in curly brackets.

Parameters:
key - the key to be placed into the property list.
v - non-null list of QNames corresponding to key.
See Also:
OutputKeys

getQNameProperties

public Vector getQNameProperties(QName key)
Searches for the list of qname properties with the specified key in the property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.

Parameters:
key - the property key.
Returns:
the value in this property list as a vector of QNames, or false if null or not "yes".

getQNameProperties

public Vector getQNameProperties(String key)
Searches for the list of qname properties with the specified key in the property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.

Parameters:
key - the property key.
Returns:
the value in this property list as a vector of QNames, or false if null or not "yes".

getQNameProperties

public static Vector getQNameProperties(String key,
                                        Properties props)
Searches for the list of qname properties with the specified key in the property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.

Parameters:
key - the property key.
props - the list of properties to search in.
Returns:
the value in this property list as a vector of QNames, or false if null or not "yes".

recompose

public void recompose(StylesheetRoot root)
               throws javax.xml.transform.TransformerException
This function is called to recompose all of the output format extended elements.

Overrides:
recompose in class ElemTemplateElement
Parameters:
root - non-null reference to the stylesheet root object.
Throws:
javax.xml.transform.TransformerException

compose

public void compose(StylesheetRoot sroot)
             throws javax.xml.transform.TransformerException
This function is called after everything else has been recomposed, and allows the template to set remaining values that may be based on some other property that depends on recomposition.

Overrides:
compose in class ElemTemplateElement
Throws:
javax.xml.transform.TransformerException

getProperties

public Properties getProperties()
Get the Properties object that this class wraps.

Returns:
non-null reference to Properties object.

copyFrom

public void copyFrom(Properties src)
Copy the keys and values from the source to this object. This will not copy the default values. This is meant to be used by going from a higher precedence object to a lower precedence object, so that if a key already exists, this method will not reset it.

Parameters:
src - non-null reference to the source properties.

copyFrom

public void copyFrom(Properties src,
                     boolean shouldResetDefaults)
Copy the keys and values from the source to this object. This will not copy the default values. This is meant to be used by going from a higher precedence object to a lower precedence object, so that if a key already exists, this method will not reset it.

Parameters:
src - non-null reference to the source properties.
shouldResetDefaults - true if the defaults should be reset based on the method property.

copyFrom

public void copyFrom(OutputProperties opsrc)
              throws javax.xml.transform.TransformerException
Copy the keys and values from the source to this object. This will not copy the default values. This is meant to be used by going from a higher precedence object to a lower precedence object, so that if a key already exists, this method will not reset it.

Parameters:
opsrc - non-null reference to an OutputProperties.
Throws:
javax.xml.transform.TransformerException

checkDuplicates

private void checkDuplicates(OutputProperties newProps)
                      throws javax.xml.transform.TransformerException
Check to see if a set of properties is at the same import level as the last set of properties set that was passed as an argument to this method. This operation assumes that the OutputProperties are being called from most important to least important, in document order.

Parameters:
newProps - non-null reference to OutputProperties that is about to be added to this set.
Throws:
javax.xml.transform.TransformerException

isLegalPropertyKey

public boolean isLegalPropertyKey(String key)
Report if the key given as an argument is a legal xsl:output key.

Parameters:
key - non-null reference to key name.
Returns:
true if key is legal.