-
Bug
-
Resolution: Fixed
-
P4
-
1.1.3, 1.2.0, 1.4.1, 5.0
-
1.3
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2047942 | 5.0 | Venugopal K | P4 | Closed | Fixed | tiger |
Name: eaR10174 Date: 10/10/2001
javax.xml.transform.Transformer.setOutputProperties(Properties oformat) does not revert
the values of changed properties to values defined in the stylesheet when the argument
'oformat' is null (See test.java below). The javadoc description of the method
Transformer.setOutputProperties() (jdk1.4.0beta-b82) reads:
"public abstract void setOutputProperties(Properties oformat)
throws IllegalArgumentException
...
If argument to this function is null, any properties previously set are removed, and
the value will revert to the value defined in the templates object."
This bug is found in the builds jdk1.4.0-beta3-b82, jaxp-1.1.3 and affects a new JCK1.4
test
api/javax_xml/transform/Transformer/index.html#GetSetOProperties[GetSetOProperties010]
------------------------------------test.java-----------------------------
import javax.xml.transform.stream.StreamSource;
import java.io.StringReader;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.OutputKeys;
public class test {
private static Transformer transformer;
private static void printPropertyValue(String name) {
System.out.print(name);
System.out.print("=");
System.out.println(transformer.getOutputProperty(name));
}
public static void main (String[] args) {
try {
String xslData = "<?xml version='1.0'?>"
+ "<xsl:stylesheet"
+ " version='1.0'"
+ " xmlns:xsl='http://www.w3.org/1999/XSL/Transform'"
+ ">\n"
+ " <xsl:output method='xml' indent='yes'"
+ " encoding='UTF-8'/>\n"
+ " <xsl:template match='/'>\n"
+ " Hello World! \n"
+ " </xsl:template>\n"
+ "</xsl:stylesheet>";
/* Create a transform factory instance */
TransformerFactory tfactory = TransformerFactory.newInstance();
/* Create a StreamSource instance */
StreamSource streamSource = new StreamSource(new StringReader(xslData));
transformer = tfactory.newTransformer(streamSource);
System.out.println("In stylesheet: ");
printPropertyValue(OutputKeys.INDENT);
printPropertyValue(OutputKeys.ENCODING);
transformer.setOutputProperty(OutputKeys.INDENT, "no");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-16");
System.out.println("\nBefore method call: ");
printPropertyValue(OutputKeys.INDENT);
printPropertyValue(OutputKeys.ENCODING);
transformer.setOutputProperties(null);
System.out.println("\nAfter method call: ");
printPropertyValue(OutputKeys.INDENT);
printPropertyValue(OutputKeys.ENCODING);
} catch (Exception e) {
e.printStackTrace();
}
}
}
---------------------------------------------------------------------------
---------------------------------------------------------------------------
% java -showversion test
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b82)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b82, mixed mode)
In stylesheet:
indent=yes
encoding=UTF-8
Before method call:
indent=no
encoding=UTF-16
After method call:
indent=no
encoding=UTF-16
---------------------------------------------------------------------------
======================================================================
javax.xml.transform.Transformer.setOutputProperties(Properties oformat) does not revert
the values of changed properties to values defined in the stylesheet when the argument
'oformat' is null (See test.java below). The javadoc description of the method
Transformer.setOutputProperties() (jdk1.4.0beta-b82) reads:
"public abstract void setOutputProperties(Properties oformat)
throws IllegalArgumentException
...
If argument to this function is null, any properties previously set are removed, and
the value will revert to the value defined in the templates object."
This bug is found in the builds jdk1.4.0-beta3-b82, jaxp-1.1.3 and affects a new JCK1.4
test
api/javax_xml/transform/Transformer/index.html#GetSetOProperties[GetSetOProperties010]
------------------------------------test.java-----------------------------
import javax.xml.transform.stream.StreamSource;
import java.io.StringReader;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.OutputKeys;
public class test {
private static Transformer transformer;
private static void printPropertyValue(String name) {
System.out.print(name);
System.out.print("=");
System.out.println(transformer.getOutputProperty(name));
}
public static void main (String[] args) {
try {
String xslData = "<?xml version='1.0'?>"
+ "<xsl:stylesheet"
+ " version='1.0'"
+ " xmlns:xsl='http://www.w3.org/1999/XSL/Transform'"
+ ">\n"
+ " <xsl:output method='xml' indent='yes'"
+ " encoding='UTF-8'/>\n"
+ " <xsl:template match='/'>\n"
+ " Hello World! \n"
+ " </xsl:template>\n"
+ "</xsl:stylesheet>";
/* Create a transform factory instance */
TransformerFactory tfactory = TransformerFactory.newInstance();
/* Create a StreamSource instance */
StreamSource streamSource = new StreamSource(new StringReader(xslData));
transformer = tfactory.newTransformer(streamSource);
System.out.println("In stylesheet: ");
printPropertyValue(OutputKeys.INDENT);
printPropertyValue(OutputKeys.ENCODING);
transformer.setOutputProperty(OutputKeys.INDENT, "no");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-16");
System.out.println("\nBefore method call: ");
printPropertyValue(OutputKeys.INDENT);
printPropertyValue(OutputKeys.ENCODING);
transformer.setOutputProperties(null);
System.out.println("\nAfter method call: ");
printPropertyValue(OutputKeys.INDENT);
printPropertyValue(OutputKeys.ENCODING);
} catch (Exception e) {
e.printStackTrace();
}
}
}
---------------------------------------------------------------------------
---------------------------------------------------------------------------
% java -showversion test
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b82)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b82, mixed mode)
In stylesheet:
indent=yes
encoding=UTF-8
Before method call:
indent=no
encoding=UTF-16
After method call:
indent=no
encoding=UTF-16
---------------------------------------------------------------------------
======================================================================
- backported by
-
JDK-2047942 Transformer.setOutputProperties(null) doesn't revert properties values
- Closed
- relates to
-
JDK-5061166 Regression(Bug4512806) : transformer.setOutputProperties(null)
- Closed