19f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/* 29f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one 39f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * or more contributor license agreements. See the NOTICE file 49f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed with this work for additional information 59f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * regarding copyright ownership. The ASF licenses this file 69f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to you under the Apache License, Version 2.0 (the "License"); 79f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * you may not use this file except in compliance with the License. 89f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * You may obtain a copy of the License at 99f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0 119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Unless required by applicable law or agreed to in writing, software 139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS, 149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * See the License for the specific language governing permissions and 169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * limitations under the License. 179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/* 199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * $Id: OutputProperties.java 468643 2006-10-28 06:56:03Z minchau $ 209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpackage org.apache.xalan.templates; 229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport java.util.Enumeration; 249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport java.util.Properties; 259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport java.util.Vector; 269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport javax.xml.transform.OutputKeys; 289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport javax.xml.transform.TransformerException; 299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xalan.res.XSLMessages; 319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xalan.res.XSLTErrorResources; 329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.serializer.OutputPropertiesFactory; 339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.serializer.OutputPropertyUtils; 349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.utils.FastStringBuffer; 359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.utils.QName; 369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/** 389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This class provides information from xsl:output elements. It is mainly 399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a wrapper for {@link java.util.Properties}, but can not extend that class 409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * because it must be part of the {@link org.apache.xalan.templates.ElemTemplateElement} 419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * heararchy. 429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <p>An OutputProperties list can contain another OutputProperties list as 439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * its "defaults"; this second property list is searched if the property key 449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * is not found in the original property list.</p> 459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a> 469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#output">xsl:output in XSLT Specification</a> 479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpublic class OutputProperties extends ElemTemplateElement 509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson implements Cloneable 519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson{ 529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson static final long serialVersionUID = -6975274363881785488L; 539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Creates an empty OutputProperties with no default values. 559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public OutputProperties() 579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this(org.apache.xml.serializer.Method.XML); 599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Creates an empty OutputProperties with the specified defaults. 639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param defaults the defaults. 659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public OutputProperties(Properties defaults) 679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_properties = new Properties(defaults); 699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Creates an empty OutputProperties with the defaults specified by 739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a property file. The method argument is used to construct a string of 749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the form output_[method].properties (for instance, output_html.properties). 759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The output_xml.properties file is always used as the base. 769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <p>At the moment, anything other than 'text', 'xml', and 'html', will 779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * use the output_xml.properties file.</p> 789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param method non-null reference to method name. 809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public OutputProperties(String method) 829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_properties = new Properties( 849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson OutputPropertiesFactory.getDefaultMethodProperties(method)); 859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Clone this OutputProperties, including a clone of the wrapped Properties 899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * reference. 909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return A new OutputProperties reference, mutation of which should not 929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * effect this object. 939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public Object clone() 959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson OutputProperties cloned = (OutputProperties) super.clone(); 1009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson cloned.m_properties = (Properties) cloned.m_properties.clone(); 1029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return cloned; 1049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (CloneNotSupportedException e) 1069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 1089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set an output property. 1139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the key to be placed into the property list. 1159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value the value corresponding to <tt>key</tt>. 1169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see javax.xml.transform.OutputKeys 1179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setProperty(QName key, String value) 1199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson setProperty(key.toNamespacedString(), value); 1219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set an output property. 1259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the key to be placed into the property list. 1279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value the value corresponding to <tt>key</tt>. 1289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see javax.xml.transform.OutputKeys 1299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setProperty(String key, String value) 1319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if(key.equals(OutputKeys.METHOD)) 1339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson setMethodDefaults(value); 1359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (key.startsWith(OutputPropertiesFactory.S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL)) 1389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson key = OutputPropertiesFactory.S_BUILTIN_EXTENSIONS_UNIVERSAL 1399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson + key.substring(OutputPropertiesFactory.S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL_LEN); 1409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_properties.put(key, value); 1429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Searches for the property with the specified key in the property list. 1469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If the key is not found in this property list, the default property list, 1479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * and its defaults, recursively, are then checked. The method returns 1489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>null</code> if the property is not found. 1499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the property key. 1519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the value in this property list with the specified key value. 1529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public String getProperty(QName key) 1549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_properties.getProperty(key.toNamespacedString()); 1569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Searches for the property with the specified key in the property list. 1609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If the key is not found in this property list, the default property list, 1619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * and its defaults, recursively, are then checked. The method returns 1629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>null</code> if the property is not found. 1639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the property key. 1659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the value in this property list with the specified key value. 1669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public String getProperty(String key) 1689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (key.startsWith(OutputPropertiesFactory.S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL)) 1709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson key = OutputPropertiesFactory.S_BUILTIN_EXTENSIONS_UNIVERSAL 1719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson + key.substring(OutputPropertiesFactory.S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL_LEN); 1729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_properties.getProperty(key); 1739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set an output property. 1779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the key to be placed into the property list. 1799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value the value corresponding to <tt>key</tt>. 1809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see javax.xml.transform.OutputKeys 1819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setBooleanProperty(QName key, boolean value) 1839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_properties.put(key.toNamespacedString(), value ? "yes" : "no"); 1859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set an output property. 1899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the key to be placed into the property list. 1919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value the value corresponding to <tt>key</tt>. 1929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see javax.xml.transform.OutputKeys 1939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setBooleanProperty(String key, boolean value) 1959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_properties.put(key, value ? "yes" : "no"); 1979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Searches for the boolean property with the specified key in the property list. 2019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If the key is not found in this property list, the default property list, 2029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * and its defaults, recursively, are then checked. The method returns 2039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>false</code> if the property is not found, or if the value is other 2049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * than "yes". 2059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the property key. 2079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the value in this property list as a boolean value, or false 2089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * if null or not "yes". 2099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public boolean getBooleanProperty(QName key) 2119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return getBooleanProperty(key.toNamespacedString()); 2139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Searches for the boolean property with the specified key in the property list. 2179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If the key is not found in this property list, the default property list, 2189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * and its defaults, recursively, are then checked. The method returns 2199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>false</code> if the property is not found, or if the value is other 2209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * than "yes". 2219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the property key. 2239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the value in this property list as a boolean value, or false 2249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * if null or not "yes". 2259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public boolean getBooleanProperty(String key) 2279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return OutputPropertyUtils.getBooleanProperty(key, m_properties); 2299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set an output property. 2339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the key to be placed into the property list. 2359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value the value corresponding to <tt>key</tt>. 2369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see javax.xml.transform.OutputKeys 2379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setIntProperty(QName key, int value) 2399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson setIntProperty(key.toNamespacedString(), value); 2419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set an output property. 2459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the key to be placed into the property list. 2479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value the value corresponding to <tt>key</tt>. 2489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see javax.xml.transform.OutputKeys 2499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setIntProperty(String key, int value) 2519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_properties.put(key, Integer.toString(value)); 2539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Searches for the int property with the specified key in the property list. 2579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If the key is not found in this property list, the default property list, 2589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * and its defaults, recursively, are then checked. The method returns 2599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>false</code> if the property is not found, or if the value is other 2609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * than "yes". 2619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the property key. 2639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the value in this property list as a int value, or false 2649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * if null or not a number. 2659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public int getIntProperty(QName key) 2679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return getIntProperty(key.toNamespacedString()); 2699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Searches for the int property with the specified key in the property list. 2739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If the key is not found in this property list, the default property list, 2749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * and its defaults, recursively, are then checked. The method returns 2759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>false</code> if the property is not found, or if the value is other 2769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * than "yes". 2779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the property key. 2799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the value in this property list as a int value, or false 2809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * if null or not a number. 2819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public int getIntProperty(String key) 2839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return OutputPropertyUtils.getIntProperty(key, m_properties); 2859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set an output property with a QName value. The QName will be turned 2909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * into a string with the namespace in curly brackets. 2919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the key to be placed into the property list. 2939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value the value corresponding to <tt>key</tt>. 2949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see javax.xml.transform.OutputKeys 2959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setQNameProperty(QName key, QName value) 2979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson setQNameProperty(key.toNamespacedString(), value); 2999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Reset the default properties based on the method. 3039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param method the method value. 3059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see javax.xml.transform.OutputKeys 3069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setMethodDefaults(String method) 3089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String defaultMethod = m_properties.getProperty(OutputKeys.METHOD); 3109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if((null == defaultMethod) || !defaultMethod.equals(method) 3129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // bjm - add the next condition as a hack 3139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // but it is because both output_xml.properties and 3149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // output_unknown.properties have the same method=xml 3159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // for their default. Otherwise we end up with 3169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // a ToUnknownStream wraping a ToXMLStream even 3179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // when the users says method="xml" 3189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // 3199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson || defaultMethod.equals("xml") 3209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson ) 3219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Properties savedProps = m_properties; 3239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Properties newDefaults = 3249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson OutputPropertiesFactory.getDefaultMethodProperties(method); 3259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_properties = new Properties(newDefaults); 3269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson copyFrom(savedProps, false); 3279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set an output property with a QName value. The QName will be turned 3339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * into a string with the namespace in curly brackets. 3349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the key to be placed into the property list. 3369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value the value corresponding to <tt>key</tt>. 3379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see javax.xml.transform.OutputKeys 3389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setQNameProperty(String key, QName value) 3409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson setProperty(key, value.toNamespacedString()); 3429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Searches for the qname property with the specified key in the property list. 3469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If the key is not found in this property list, the default property list, 3479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * and its defaults, recursively, are then checked. The method returns 3489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>null</code> if the property is not found. 3499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the property key. 3519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the value in this property list as a QName value, or false 3529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * if null or not "yes". 3539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public QName getQNameProperty(QName key) 3559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return getQNameProperty(key.toNamespacedString()); 3579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Searches for the qname property with the specified key in the property list. 3619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If the key is not found in this property list, the default property list, 3629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * and its defaults, recursively, are then checked. The method returns 3639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>null</code> if the property is not found. 3649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the property key. 3669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the value in this property list as a QName value, or false 3679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * if null or not "yes". 3689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public QName getQNameProperty(String key) 3709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return getQNameProperty(key, m_properties); 3729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Searches for the qname property with the specified key in the property list. 3769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If the key is not found in this property list, the default property list, 3779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * and its defaults, recursively, are then checked. The method returns 3789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>null</code> if the property is not found. 3799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the property key. 3819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param props the list of properties to search in. 3829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the value in this property list as a QName value, or false 3839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * if null or not "yes". 3849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public static QName getQNameProperty(String key, Properties props) 3869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String s = props.getProperty(key); 3899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (null != s) 3919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return QName.getQNameFromString(s); 3929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else 3939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 3949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set an output property with a QName list value. The QNames will be turned 3989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * into strings with the namespace in curly brackets. 3999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 4009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the key to be placed into the property list. 4019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param v non-null list of QNames corresponding to <tt>key</tt>. 4029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see javax.xml.transform.OutputKeys 4039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 4049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setQNameProperties(QName key, Vector v) 4059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson setQNameProperties(key.toNamespacedString(), v); 4079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 4109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set an output property with a QName list value. The QNames will be turned 4119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * into strings with the namespace in curly brackets. 4129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 4139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the key to be placed into the property list. 4149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param v non-null list of QNames corresponding to <tt>key</tt>. 4159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see javax.xml.transform.OutputKeys 4169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 4179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setQNameProperties(String key, Vector v) 4189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int s = v.size(); 4219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Just an initial guess at reasonable tuning parameters 4239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson FastStringBuffer fsb = new FastStringBuffer(9,9); 4249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int i = 0; i < s; i++) 4269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson QName qname = (QName) v.elementAt(i); 4289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson fsb.append(qname.toNamespacedString()); 4309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Don't append space after last value 4319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (i < s-1) 4329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson fsb.append(' '); 4339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_properties.put(key, fsb.toString()); 4369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 4399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Searches for the list of qname properties with the specified key in 4409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the property list. 4419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If the key is not found in this property list, the default property list, 4429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * and its defaults, recursively, are then checked. The method returns 4439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>null</code> if the property is not found. 4449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 4459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the property key. 4469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the value in this property list as a vector of QNames, or false 4479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * if null or not "yes". 4489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 4499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public Vector getQNameProperties(QName key) 4509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return getQNameProperties(key.toNamespacedString()); 4529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 4559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Searches for the list of qname properties with the specified key in 4569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the property list. 4579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If the key is not found in this property list, the default property list, 4589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * and its defaults, recursively, are then checked. The method returns 4599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>null</code> if the property is not found. 4609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 4619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the property key. 4629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the value in this property list as a vector of QNames, or false 4639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * if null or not "yes". 4649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 4659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public Vector getQNameProperties(String key) 4669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return getQNameProperties(key, m_properties); 4689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 4719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Searches for the list of qname properties with the specified key in 4729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the property list. 4739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If the key is not found in this property list, the default property list, 4749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * and its defaults, recursively, are then checked. The method returns 4759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>null</code> if the property is not found. 4769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 4779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key the property key. 4789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param props the list of properties to search in. 4799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the value in this property list as a vector of QNames, or false 4809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * if null or not "yes". 4819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 4829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public static Vector getQNameProperties(String key, Properties props) 4839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String s = props.getProperty(key); 4869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (null != s) 4889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Vector v = new Vector(); 4909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int l = s.length(); 4919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson boolean inCurly = false; 4929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson FastStringBuffer buf = new FastStringBuffer(); 4939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // parse through string, breaking on whitespaces. I do this instead 4959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // of a tokenizer so I can track whitespace inside of curly brackets, 4969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // which theoretically shouldn't happen if they contain legal URLs. 4979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int i = 0; i < l; i++) 4989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson char c = s.charAt(i); 5009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (Character.isWhitespace(c)) 5029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (!inCurly) 5049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (buf.length() > 0) 5069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson QName qname = QName.getQNameFromString(buf.toString()); 5089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson v.addElement(qname); 5099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson buf.reset(); 5109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson continue; 5129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else if ('{' == c) 5159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson inCurly = true; 5169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else if ('}' == c) 5179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson inCurly = false; 5189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson buf.append(c); 5209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (buf.length() > 0) 5239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson QName qname = QName.getQNameFromString(buf.toString()); 5259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson v.addElement(qname); 5269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson buf.reset(); 5279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return v; 5309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else 5329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 5339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 5369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This function is called to recompose all of the output format extended elements. 5379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 5389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param root non-null reference to the stylesheet root object. 5399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 5409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void recompose(StylesheetRoot root) 5419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws TransformerException 5429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson root.recomposeOutput(this); 5449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 5479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This function is called after everything else has been 5489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * recomposed, and allows the template to set remaining 5499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * values that may be based on some other property that 5509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * depends on recomposition. 5519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 5529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void compose(StylesheetRoot sroot) throws TransformerException 5539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson super.compose(sroot); 5569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 5609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the Properties object that this class wraps. 5619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 5629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return non-null reference to Properties object. 5639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 5649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public Properties getProperties() 5659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_properties; 5679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 5709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Copy the keys and values from the source to this object. This will 5719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * not copy the default values. This is meant to be used by going from 5729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a higher precedence object to a lower precedence object, so that if a 5739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * key already exists, this method will not reset it. 5749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 5759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param src non-null reference to the source properties. 5769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 5779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void copyFrom(Properties src) 5789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson copyFrom(src, true); 5809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 5839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Copy the keys and values from the source to this object. This will 5849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * not copy the default values. This is meant to be used by going from 5859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a higher precedence object to a lower precedence object, so that if a 5869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * key already exists, this method will not reset it. 5879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 5889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param src non-null reference to the source properties. 5899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param shouldResetDefaults true if the defaults should be reset based on 5909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the method property. 5919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 5929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void copyFrom(Properties src, boolean shouldResetDefaults) 5939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Enumeration keys = src.keys(); 5969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson while (keys.hasMoreElements()) 5989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String key = (String) keys.nextElement(); 6009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (!isLegalPropertyKey(key)) 6029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_OUTPUT_PROPERTY_NOT_RECOGNIZED, new Object[]{key})); //"output property not recognized: " 6039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object oldValue = m_properties.get(key); 6059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (null == oldValue) 6069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 6079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String val = (String) src.get(key); 6089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if(shouldResetDefaults && key.equals(OutputKeys.METHOD)) 6109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 6119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson setMethodDefaults(val); 6129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_properties.put(key, val); 6159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else if (key.equals(OutputKeys.CDATA_SECTION_ELEMENTS)) 6179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 6189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_properties.put(key, (String) oldValue + " " + (String) src.get(key)); 6199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 6249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Copy the keys and values from the source to this object. This will 6259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * not copy the default values. This is meant to be used by going from 6269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a higher precedence object to a lower precedence object, so that if a 6279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * key already exists, this method will not reset it. 6289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 6299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param opsrc non-null reference to an OutputProperties. 6309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 6319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void copyFrom(OutputProperties opsrc) 6329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws TransformerException 6339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 6349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Bugzilla 6157: recover from xsl:output statements 6359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // checkDuplicates(opsrc); 6369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson copyFrom(opsrc.getProperties()); 6379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 6409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Report if the key given as an argument is a legal xsl:output key. 6419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 6429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key non-null reference to key name. 6439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 6449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return true if key is legal. 6459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 6469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public static boolean isLegalPropertyKey(String key) 6479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 6489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return (key.equals(OutputKeys.CDATA_SECTION_ELEMENTS) 6509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson || key.equals(OutputKeys.DOCTYPE_PUBLIC) 6519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson || key.equals(OutputKeys.DOCTYPE_SYSTEM) 6529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson || key.equals(OutputKeys.ENCODING) 6539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson || key.equals(OutputKeys.INDENT) 6549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson || key.equals(OutputKeys.MEDIA_TYPE) 6559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson || key.equals(OutputKeys.METHOD) 6569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson || key.equals(OutputKeys.OMIT_XML_DECLARATION) 6579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson || key.equals(OutputKeys.STANDALONE) 6589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson || key.equals(OutputKeys.VERSION) 6599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson || (key.length() > 0) 6609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson && (key.charAt(0) == '{') 6619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson && (key.lastIndexOf('{') == 0) 6629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson && (key.indexOf('}') > 0) 6639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson && (key.lastIndexOf('}') == key.indexOf('}'))); 6649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** The output properties. 6679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @serial */ 6689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private Properties m_properties = null; 6699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 6719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Creates an empty OutputProperties with the defaults specified by 6729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a property file. The method argument is used to construct a string of 6739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the form output_[method].properties (for instance, output_html.properties). 6749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The output_xml.properties file is always used as the base. 6759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <p>At the moment, anything other than 'text', 'xml', and 'html', will 6769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * use the output_xml.properties file.</p> 6779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 6789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param method non-null reference to method name. 6799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 6809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return Properties object that holds the defaults for the given method. 6819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 6829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @deprecated Use org.apache.xml.serializer.OuputPropertiesFactory. 6839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * getDefaultMethodProperties directly. 6849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 6859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson static public Properties getDefaultMethodProperties(String method) 6869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 6879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return org.apache.xml.serializer.OutputPropertiesFactory.getDefaultMethodProperties(method); 6889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson} 690