6
|
1 |
/*
|
|
2 |
* reserved comment block
|
|
3 |
* DO NOT REMOVE OR ALTER!
|
|
4 |
*/
|
|
5 |
/*
|
|
6 |
* Copyright 1999-2004 The Apache Software Foundation.
|
|
7 |
*
|
|
8 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9 |
* you may not use this file except in compliance with the License.
|
|
10 |
* You may obtain a copy of the License at
|
|
11 |
*
|
|
12 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13 |
*
|
|
14 |
* Unless required by applicable law or agreed to in writing, software
|
|
15 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17 |
* See the License for the specific language governing permissions and
|
|
18 |
* limitations under the License.
|
|
19 |
*/
|
|
20 |
/*
|
|
21 |
* $Id: OutputPropertiesFactory.java,v 1.2.4.1 2005/09/15 08:15:21 suresh_emailid Exp $
|
|
22 |
*/
|
|
23 |
package com.sun.org.apache.xml.internal.serializer;
|
|
24 |
|
16953
|
25 |
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
|
6
|
26 |
import java.io.BufferedInputStream;
|
|
27 |
import java.io.IOException;
|
|
28 |
import java.io.InputStream;
|
|
29 |
import java.security.AccessController;
|
|
30 |
import java.security.PrivilegedAction;
|
|
31 |
import java.util.Enumeration;
|
|
32 |
import java.util.Properties;
|
|
33 |
|
|
34 |
import javax.xml.transform.OutputKeys;
|
|
35 |
|
|
36 |
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
|
|
37 |
import com.sun.org.apache.xml.internal.serializer.utils.Utils;
|
|
38 |
import com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException;
|
|
39 |
|
|
40 |
/**
|
|
41 |
* This class is a factory to generate a set of default properties
|
|
42 |
* of key/value pairs that are used to create a serializer through the
|
|
43 |
* factory {@link SerializerFactory SerilizerFactory}.
|
|
44 |
* The properties generated by this factory
|
|
45 |
* may be modified to non-default values before the SerializerFactory is used to
|
|
46 |
* create a Serializer.
|
|
47 |
* <p>
|
|
48 |
* The given output types supported are "xml", "text", and "html".
|
|
49 |
* These type strings can be obtained from the
|
|
50 |
* {@link Method Method} class in this package.
|
|
51 |
* <p>
|
|
52 |
* Other constants defined in this class are the non-standard property keys
|
|
53 |
* that can be used to set non-standard property values on a java.util.Properties object
|
|
54 |
* that is used to create or configure a serializer. Here are the non-standard keys:
|
|
55 |
* <ul>
|
|
56 |
* <li> <b>S_KEY_INDENT_AMOUNT </b> -
|
|
57 |
* The non-standard property key to use to set the indentation amount.
|
|
58 |
* The "indent" key needs to have a value of "yes", and this
|
|
59 |
* properties value is a the number of whitespaces to indent by per
|
|
60 |
* indentation level.
|
|
61 |
*
|
|
62 |
* <li> <b>S_KEY_CONTENT_HANDLER </b> -
|
|
63 |
* This non-standard property key is used to set the name of the fully qualified
|
|
64 |
* Java class that implements the ContentHandler interface.
|
|
65 |
* The output of the serializer will be SAX events sent to this an
|
|
66 |
* object of this class.
|
|
67 |
*
|
|
68 |
* <li> <b>S_KEY_ENTITIES </b> -
|
|
69 |
* This non-standard property key is used to specify the name of the property file
|
|
70 |
* that specifies character to entity reference mappings. A line in such a
|
|
71 |
* file is has the name of the entity and the numeric (base 10) value
|
|
72 |
* of the corresponding character, like this one: <br> quot=34 <br>
|
|
73 |
*
|
|
74 |
* <li> <b>S_USE_URL_ESCAPING </b> -
|
|
75 |
* This non-standard property key is used to set a value of "yes" if the href values for HTML serialization should
|
|
76 |
* use %xx escaping.
|
|
77 |
*
|
|
78 |
* <li> <b>S_OMIT_META_TAG </b> -
|
|
79 |
* This non-standard property key is used to set a value of "yes" if the META tag should be omitted where it would
|
|
80 |
* otherwise be supplied.
|
|
81 |
* </ul>
|
|
82 |
*
|
|
83 |
* @see SerializerFactory
|
|
84 |
* @see Method
|
|
85 |
* @see Serializer
|
|
86 |
*/
|
|
87 |
public final class OutputPropertiesFactory
|
|
88 |
{
|
|
89 |
/** S_BUILTIN_EXTENSIONS_URL is a mnemonic for the XML Namespace
|
|
90 |
*(http://xml.apache.org/xalan) predefined to signify Xalan's
|
|
91 |
* built-in XSLT Extensions. When used in stylesheets, this is often
|
|
92 |
* bound to the "xalan:" prefix.
|
|
93 |
*/
|
|
94 |
private static final String
|
|
95 |
S_BUILTIN_EXTENSIONS_URL = "http://xml.apache.org/xalan";
|
|
96 |
|
|
97 |
/**
|
|
98 |
* The old built-in extension url. It is still supported for
|
|
99 |
* backward compatibility.
|
|
100 |
*/
|
|
101 |
private static final String
|
|
102 |
S_BUILTIN_OLD_EXTENSIONS_URL = "http://xml.apache.org/xslt";
|
|
103 |
|
|
104 |
//************************************************************
|
|
105 |
//* PUBLIC CONSTANTS
|
|
106 |
//************************************************************
|
|
107 |
/**
|
|
108 |
* This is not a public API.
|
|
109 |
* This is the built-in extensions namespace,
|
|
110 |
* reexpressed in {namespaceURI} syntax
|
|
111 |
* suitable for prepending to a localname to produce a "universal
|
|
112 |
* name".
|
|
113 |
*/
|
|
114 |
public static final String S_BUILTIN_EXTENSIONS_UNIVERSAL =
|
|
115 |
"{" + S_BUILTIN_EXTENSIONS_URL + "}";
|
|
116 |
|
|
117 |
// Some special Xalan keys.
|
|
118 |
|
|
119 |
/**
|
|
120 |
* The non-standard property key to use to set the
|
|
121 |
* number of whitepaces to indent by, per indentation level,
|
|
122 |
* if indent="yes".
|
|
123 |
*/
|
|
124 |
public static final String S_KEY_INDENT_AMOUNT =
|
|
125 |
S_BUILTIN_EXTENSIONS_UNIVERSAL + "indent-amount";
|
|
126 |
|
|
127 |
/**
|
|
128 |
* The non-standard property key to use to set the
|
|
129 |
* number of whitepaces to indent by, per indentation level,
|
|
130 |
* if indent="yes".
|
|
131 |
*/
|
|
132 |
public static final String S_KEY_LINE_SEPARATOR =
|
|
133 |
S_BUILTIN_EXTENSIONS_UNIVERSAL + "line-separator";
|
|
134 |
|
|
135 |
/** This non-standard property key is used to set the name of the fully qualified
|
|
136 |
* Java class that implements the ContentHandler interface.
|
|
137 |
* Fully qualified name of class with a default constructor that
|
|
138 |
* implements the ContentHandler interface, where the result tree events
|
|
139 |
* will be sent to.
|
|
140 |
*/
|
|
141 |
|
|
142 |
public static final String S_KEY_CONTENT_HANDLER =
|
|
143 |
S_BUILTIN_EXTENSIONS_UNIVERSAL + "content-handler";
|
|
144 |
|
|
145 |
/**
|
|
146 |
* This non-standard property key is used to specify the name of the property file
|
|
147 |
* that specifies character to entity reference mappings.
|
|
148 |
*/
|
|
149 |
public static final String S_KEY_ENTITIES =
|
|
150 |
S_BUILTIN_EXTENSIONS_UNIVERSAL + "entities";
|
|
151 |
|
|
152 |
/**
|
|
153 |
* This non-standard property key is used to set a value of "yes" if the href values for HTML serialization should
|
|
154 |
* use %xx escaping. */
|
|
155 |
public static final String S_USE_URL_ESCAPING =
|
|
156 |
S_BUILTIN_EXTENSIONS_UNIVERSAL + "use-url-escaping";
|
|
157 |
|
|
158 |
/**
|
|
159 |
* This non-standard property key is used to set a value of "yes" if the META tag should be omitted where it would
|
|
160 |
* otherwise be supplied.
|
|
161 |
*/
|
|
162 |
public static final String S_OMIT_META_TAG =
|
|
163 |
S_BUILTIN_EXTENSIONS_UNIVERSAL + "omit-meta-tag";
|
|
164 |
|
|
165 |
/**
|
|
166 |
* The old built-in extension namespace, this is not a public API.
|
|
167 |
*/
|
|
168 |
public static final String S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL =
|
|
169 |
"{" + S_BUILTIN_OLD_EXTENSIONS_URL + "}";
|
|
170 |
|
|
171 |
/**
|
|
172 |
* This is not a public API, it is only public because it is used
|
|
173 |
* by outside of this package,
|
|
174 |
* it is the length of the old built-in extension namespace.
|
|
175 |
*/
|
|
176 |
public static final int S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL_LEN =
|
|
177 |
S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL.length();
|
|
178 |
|
12458
|
179 |
/**
|
|
180 |
* This non-standard, Oracle-impl only property key is used as if OutputKeys.STANDALONE is specified but
|
|
181 |
* without writing it out in the declaration; It can be used to reverse the change by Xalan patch 1495.
|
|
182 |
* Since Xalan patch 1495 can cause incompatible behavior, this property is add for application to neutralize
|
|
183 |
* the effect of Xalan patch 1495
|
|
184 |
*/
|
|
185 |
/**
|
|
186 |
* <p>Is Standalone</p>
|
|
187 |
*
|
|
188 |
* <ul>
|
|
189 |
* <li>
|
|
190 |
* <code>yes</code> to indicate the output is intended to be used as standalone
|
|
191 |
* </li>
|
|
192 |
* <li>
|
|
193 |
* <code>no</code> has no effect.
|
|
194 |
* </li>
|
|
195 |
* </ul>
|
|
196 |
*/
|
|
197 |
public static final String ORACLE_IS_STANDALONE = "http://www.oracle.com/xml/is-standalone";
|
|
198 |
|
6
|
199 |
//************************************************************
|
|
200 |
//* PRIVATE CONSTANTS
|
|
201 |
//************************************************************
|
|
202 |
|
|
203 |
private static final String S_XSLT_PREFIX = "xslt.output.";
|
|
204 |
private static final int S_XSLT_PREFIX_LEN = S_XSLT_PREFIX.length();
|
|
205 |
private static final String S_XALAN_PREFIX = "org.apache.xslt.";
|
|
206 |
private static final int S_XALAN_PREFIX_LEN = S_XALAN_PREFIX.length();
|
|
207 |
|
|
208 |
/** Synchronization object for lazy initialization of the above tables. */
|
|
209 |
private static Integer m_synch_object = new Integer(1);
|
|
210 |
|
|
211 |
/** the directory in which the various method property files are located */
|
|
212 |
private static final String PROP_DIR = "com/sun/org/apache/xml/internal/serializer/";
|
|
213 |
/** property file for default XML properties */
|
|
214 |
private static final String PROP_FILE_XML = "output_xml.properties";
|
|
215 |
/** property file for default TEXT properties */
|
|
216 |
private static final String PROP_FILE_TEXT = "output_text.properties";
|
|
217 |
/** property file for default HTML properties */
|
|
218 |
private static final String PROP_FILE_HTML = "output_html.properties";
|
|
219 |
/** property file for default UNKNOWN (Either XML or HTML, to be determined later) properties */
|
|
220 |
private static final String PROP_FILE_UNKNOWN = "output_unknown.properties";
|
|
221 |
|
|
222 |
//************************************************************
|
|
223 |
//* PRIVATE STATIC FIELDS
|
|
224 |
//************************************************************
|
|
225 |
|
|
226 |
/** The default properties of all output files. */
|
|
227 |
private static Properties m_xml_properties = null;
|
|
228 |
|
|
229 |
/** The default properties when method="html". */
|
|
230 |
private static Properties m_html_properties = null;
|
|
231 |
|
|
232 |
/** The default properties when method="text". */
|
|
233 |
private static Properties m_text_properties = null;
|
|
234 |
|
|
235 |
/** The properties when method="" for the "unknown" wrapper */
|
|
236 |
private static Properties m_unknown_properties = null;
|
|
237 |
|
|
238 |
private static final Class
|
|
239 |
ACCESS_CONTROLLER_CLASS = findAccessControllerClass();
|
|
240 |
|
|
241 |
private static Class findAccessControllerClass() {
|
|
242 |
try
|
|
243 |
{
|
|
244 |
// This Class was introduced in JDK 1.2. With the re-architecture of
|
|
245 |
// security mechanism ( starting in JDK 1.2 ), we have option of
|
|
246 |
// giving privileges to certain part of code using doPrivileged block.
|
|
247 |
// In JDK1.1.X applications won't be having security manager and if
|
|
248 |
// there is security manager ( in applets ), code need to be signed
|
|
249 |
// and trusted for having access to resources.
|
|
250 |
|
|
251 |
return Class.forName("java.security.AccessController");
|
|
252 |
}
|
|
253 |
catch (Exception e)
|
|
254 |
{
|
|
255 |
//User may be using older JDK ( JDK <1.2 ). Allow him/her to use it.
|
|
256 |
// But don't try to use doPrivileged
|
|
257 |
}
|
|
258 |
|
|
259 |
return null;
|
|
260 |
}
|
|
261 |
|
|
262 |
/**
|
|
263 |
* Creates an empty OutputProperties with the property key/value defaults specified by
|
|
264 |
* a property file. The method argument is used to construct a string of
|
|
265 |
* the form output_[method].properties (for instance, output_html.properties).
|
|
266 |
* The output_xml.properties file is always used as the base.
|
|
267 |
*
|
|
268 |
* <p>Anything other than 'text', 'xml', and 'html', will
|
|
269 |
* use the output_xml.properties file.</p>
|
|
270 |
*
|
|
271 |
* @param method non-null reference to method name.
|
|
272 |
*
|
|
273 |
* @return Properties object that holds the defaults for the given method.
|
|
274 |
*/
|
|
275 |
static public final Properties getDefaultMethodProperties(String method)
|
|
276 |
{
|
|
277 |
String fileName = null;
|
|
278 |
Properties defaultProperties = null;
|
|
279 |
// According to this article : Double-check locking does not work
|
|
280 |
// http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-toolbox.html
|
|
281 |
try
|
|
282 |
{
|
|
283 |
synchronized (m_synch_object)
|
|
284 |
{
|
|
285 |
if (null == m_xml_properties) // double check
|
|
286 |
{
|
|
287 |
fileName = PROP_FILE_XML;
|
|
288 |
m_xml_properties = loadPropertiesFile(fileName, null);
|
|
289 |
}
|
|
290 |
}
|
|
291 |
|
|
292 |
if (method.equals(Method.XML))
|
|
293 |
{
|
|
294 |
defaultProperties = m_xml_properties;
|
|
295 |
}
|
|
296 |
else if (method.equals(Method.HTML))
|
|
297 |
{
|
|
298 |
if (null == m_html_properties) // double check
|
|
299 |
{
|
|
300 |
fileName = PROP_FILE_HTML;
|
|
301 |
m_html_properties =
|
|
302 |
loadPropertiesFile(fileName, m_xml_properties);
|
|
303 |
}
|
|
304 |
|
|
305 |
defaultProperties = m_html_properties;
|
|
306 |
}
|
|
307 |
else if (method.equals(Method.TEXT))
|
|
308 |
{
|
|
309 |
if (null == m_text_properties) // double check
|
|
310 |
{
|
|
311 |
fileName = PROP_FILE_TEXT;
|
|
312 |
m_text_properties =
|
|
313 |
loadPropertiesFile(fileName, m_xml_properties);
|
|
314 |
if (null
|
|
315 |
== m_text_properties.getProperty(OutputKeys.ENCODING))
|
|
316 |
{
|
|
317 |
String mimeEncoding = Encodings.getMimeEncoding(null);
|
|
318 |
m_text_properties.put(
|
|
319 |
OutputKeys.ENCODING,
|
|
320 |
mimeEncoding);
|
|
321 |
}
|
|
322 |
}
|
|
323 |
|
|
324 |
defaultProperties = m_text_properties;
|
|
325 |
}
|
|
326 |
else if (method.equals(com.sun.org.apache.xml.internal.serializer.Method.UNKNOWN))
|
|
327 |
{
|
|
328 |
if (null == m_unknown_properties) // double check
|
|
329 |
{
|
|
330 |
fileName = PROP_FILE_UNKNOWN;
|
|
331 |
m_unknown_properties =
|
|
332 |
loadPropertiesFile(fileName, m_xml_properties);
|
|
333 |
}
|
|
334 |
|
|
335 |
defaultProperties = m_unknown_properties;
|
|
336 |
}
|
|
337 |
else
|
|
338 |
{
|
|
339 |
// TODO: Calculate res file from name.
|
|
340 |
defaultProperties = m_xml_properties;
|
|
341 |
}
|
|
342 |
}
|
|
343 |
catch (IOException ioe)
|
|
344 |
{
|
|
345 |
throw new WrappedRuntimeException(
|
|
346 |
Utils.messages.createMessage(
|
|
347 |
MsgKey.ER_COULD_NOT_LOAD_METHOD_PROPERTY,
|
|
348 |
new Object[] { fileName, method }),
|
|
349 |
ioe);
|
|
350 |
}
|
|
351 |
// wrap these cached defaultProperties in a new Property object just so
|
|
352 |
// that the caller of this method can't modify the default values
|
|
353 |
return new Properties(defaultProperties);
|
|
354 |
}
|
|
355 |
|
|
356 |
/**
|
|
357 |
* Load the properties file from a resource stream. If a
|
|
358 |
* key name such as "org.apache.xslt.xxx", fix up the start of
|
|
359 |
* string to be a curly namespace. If a key name starts with
|
|
360 |
* "xslt.output.xxx", clip off "xslt.output.". If a key name *or* a
|
|
361 |
* key value is discovered, check for \u003a in the text, and
|
|
362 |
* fix it up to be ":", since earlier versions of the JDK do not
|
|
363 |
* handle the escape sequence (at least in key names).
|
|
364 |
*
|
|
365 |
* @param resourceName non-null reference to resource name.
|
|
366 |
* @param defaults Default properties, which may be null.
|
|
367 |
*/
|
|
368 |
static private Properties loadPropertiesFile(
|
|
369 |
final String resourceName,
|
|
370 |
Properties defaults)
|
|
371 |
throws IOException
|
|
372 |
{
|
|
373 |
|
|
374 |
// This static method should eventually be moved to a thread-specific class
|
|
375 |
// so that we can cache the ContextClassLoader and bottleneck all properties file
|
|
376 |
// loading throughout Xalan.
|
|
377 |
|
|
378 |
Properties props = new Properties(defaults);
|
|
379 |
|
|
380 |
InputStream is = null;
|
|
381 |
BufferedInputStream bis = null;
|
|
382 |
|
|
383 |
try
|
|
384 |
{
|
|
385 |
if (ACCESS_CONTROLLER_CLASS != null)
|
|
386 |
{
|
|
387 |
is = (InputStream) AccessController
|
|
388 |
.doPrivileged(new PrivilegedAction() {
|
|
389 |
public Object run()
|
|
390 |
{
|
|
391 |
return OutputPropertiesFactory.class
|
|
392 |
.getResourceAsStream(resourceName);
|
|
393 |
}
|
|
394 |
});
|
|
395 |
}
|
|
396 |
else
|
|
397 |
{
|
|
398 |
// User may be using older JDK ( JDK < 1.2 )
|
|
399 |
is = OutputPropertiesFactory.class
|
|
400 |
.getResourceAsStream(resourceName);
|
|
401 |
}
|
|
402 |
|
|
403 |
bis = new BufferedInputStream(is);
|
|
404 |
props.load(bis);
|
|
405 |
}
|
|
406 |
catch (IOException ioe)
|
|
407 |
{
|
|
408 |
if (defaults == null)
|
|
409 |
{
|
|
410 |
throw ioe;
|
|
411 |
}
|
|
412 |
else
|
|
413 |
{
|
|
414 |
throw new WrappedRuntimeException(
|
|
415 |
Utils.messages.createMessage(
|
|
416 |
MsgKey.ER_COULD_NOT_LOAD_RESOURCE,
|
|
417 |
new Object[] { resourceName }),
|
|
418 |
ioe);
|
|
419 |
//"Could not load '"+resourceName+"' (check CLASSPATH), now using just the defaults ", ioe);
|
|
420 |
}
|
|
421 |
}
|
|
422 |
catch (SecurityException se)
|
|
423 |
{
|
|
424 |
// Repeat IOException handling for sandbox/applet case -sc
|
|
425 |
if (defaults == null)
|
|
426 |
{
|
|
427 |
throw se;
|
|
428 |
}
|
|
429 |
else
|
|
430 |
{
|
|
431 |
throw new WrappedRuntimeException(
|
|
432 |
Utils.messages.createMessage(
|
|
433 |
MsgKey.ER_COULD_NOT_LOAD_RESOURCE,
|
|
434 |
new Object[] { resourceName }),
|
|
435 |
se);
|
|
436 |
//"Could not load '"+resourceName+"' (check CLASSPATH, applet security), now using just the defaults ", se);
|
|
437 |
}
|
|
438 |
}
|
|
439 |
finally
|
|
440 |
{
|
|
441 |
if (bis != null)
|
|
442 |
{
|
|
443 |
bis.close();
|
|
444 |
}
|
|
445 |
if (is != null)
|
|
446 |
{
|
|
447 |
is.close();
|
|
448 |
}
|
|
449 |
}
|
|
450 |
|
|
451 |
// Note that we're working at the HashTable level here,
|
|
452 |
// and not at the Properties level! This is important
|
|
453 |
// because we don't want to modify the default properties.
|
|
454 |
// NB: If fixupPropertyString ends up changing the property
|
|
455 |
// name or value, we need to remove the old key and re-add
|
|
456 |
// with the new key and value. However, then our Enumeration
|
|
457 |
// could lose its place in the HashTable. So, we first
|
|
458 |
// clone the HashTable and enumerate over that since the
|
|
459 |
// clone will not change. When we migrate to Collections,
|
|
460 |
// this code should be revisited and cleaned up to use
|
|
461 |
// an Iterator which may (or may not) alleviate the need for
|
|
462 |
// the clone. Many thanks to Padraig O'hIceadha
|
|
463 |
// <padraig@gradient.ie> for finding this problem. Bugzilla 2000.
|
|
464 |
|
|
465 |
Enumeration keys = ((Properties) props.clone()).keys();
|
|
466 |
while (keys.hasMoreElements())
|
|
467 |
{
|
|
468 |
String key = (String) keys.nextElement();
|
|
469 |
// Now check if the given key was specified as a
|
|
470 |
// System property. If so, the system property
|
|
471 |
// overides the default value in the propery file.
|
|
472 |
String value = null;
|
|
473 |
try
|
|
474 |
{
|
16953
|
475 |
value = SecuritySupport.getSystemProperty(key);
|
6
|
476 |
}
|
|
477 |
catch (SecurityException se)
|
|
478 |
{
|
|
479 |
// No-op for sandbox/applet case, leave null -sc
|
|
480 |
}
|
|
481 |
if (value == null)
|
|
482 |
value = (String) props.get(key);
|
|
483 |
|
|
484 |
String newKey = fixupPropertyString(key, true);
|
|
485 |
String newValue = null;
|
|
486 |
try
|
|
487 |
{
|
16953
|
488 |
newValue = SecuritySupport.getSystemProperty(newKey);
|
6
|
489 |
}
|
|
490 |
catch (SecurityException se)
|
|
491 |
{
|
|
492 |
// No-op for sandbox/applet case, leave null -sc
|
|
493 |
}
|
|
494 |
if (newValue == null)
|
|
495 |
newValue = fixupPropertyString(value, false);
|
|
496 |
else
|
|
497 |
newValue = fixupPropertyString(newValue, false);
|
|
498 |
|
|
499 |
if (key != newKey || value != newValue)
|
|
500 |
{
|
|
501 |
props.remove(key);
|
|
502 |
props.put(newKey, newValue);
|
|
503 |
}
|
|
504 |
|
|
505 |
}
|
|
506 |
|
|
507 |
return props;
|
|
508 |
}
|
|
509 |
|
|
510 |
/**
|
|
511 |
* Fix up a string in an output properties file according to
|
|
512 |
* the rules of {@link #loadPropertiesFile}.
|
|
513 |
*
|
|
514 |
* @param s non-null reference to string that may need to be fixed up.
|
|
515 |
* @return A new string if fixup occured, otherwise the s argument.
|
|
516 |
*/
|
|
517 |
static private String fixupPropertyString(String s, boolean doClipping)
|
|
518 |
{
|
|
519 |
int index;
|
|
520 |
if (doClipping && s.startsWith(S_XSLT_PREFIX))
|
|
521 |
{
|
|
522 |
s = s.substring(S_XSLT_PREFIX_LEN);
|
|
523 |
}
|
|
524 |
if (s.startsWith(S_XALAN_PREFIX))
|
|
525 |
{
|
|
526 |
s =
|
|
527 |
S_BUILTIN_EXTENSIONS_UNIVERSAL
|
|
528 |
+ s.substring(S_XALAN_PREFIX_LEN);
|
|
529 |
}
|
|
530 |
if ((index = s.indexOf("\\u003a")) > 0)
|
|
531 |
{
|
|
532 |
String temp = s.substring(index + 6);
|
|
533 |
s = s.substring(0, index) + ":" + temp;
|
|
534 |
|
|
535 |
}
|
|
536 |
return s;
|
|
537 |
}
|
|
538 |
|
|
539 |
}
|