Project

Profile

Help

Transformer bug: OutputProperty

Added by Anonymous about 13 years ago

Legacy ID: #9436807 Legacy Poster: mcarrolle (mcarrolle)

Hi, I use saxon 9.3.0.4. I found a strange behaviour of the transformer. The code below is a junit test that fails because the value of "OuputProperty" is not always reset (See comment in the code). [code] System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl"); Transformer transformer = TransformerFactory.newInstance().newTransformer(); System.err.println(transformer.getOutputProperty(OutputKeys.METHOD)); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); // first reset transformer.reset(); transformer.setOutputProperty(OutputKeys.METHOD, "text"); System.err.println(transformer.getOutputProperty(OutputKeys.METHOD));//result is [text] // second reset transformer.reset(); //Assertion fails because result is [xml] assertEquals(null, transformer.getOutputProperty(OutputKeys.METHOD)); [/code] Bye.


Replies (2)

RE: Transformer bug: OutputProperty - Added by Anonymous about 13 years ago

Legacy ID: #9446256 Legacy Poster: Michael Kay (mhkay)

Are you trying to test that the output property is reset to the value "null"? The spec is a little vague here. The initial values for output properties are supposed to be as defined in section 16 of the XSLT 1.0 specification. In fact most of the defaults defined in XSLT 1.0 are context-dependent in one way or another. Despite this, Saxon defaults the "method" property to "xml", and I think this is a legimate interpretation of the spec.

RE: Transformer bug: OutputProperty - Added by Anonymous about 13 years ago

Legacy ID: #9453220 Legacy Poster: mcarrolle (mcarrolle)

No, I am testing that after each reset on the transformer, the value of the "method" property is reset. If I modify the previous code snippet by moving the line 4: [System.err.println(transformer.getOutputProperty(OutputKeys.METHOD)); ], after the second reset the default value of the "method" property is [text] (code below). I think that defaults the "method" property to "xml" is a good choice too. [code] System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl"); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); // first reset transformer.reset(); System.err.println(transformer.getOutputProperty(OutputKeys.METHOD));//result is [null] transformer.setOutputProperty(OutputKeys.METHOD, "text"); System.err.println(transformer.getOutputProperty(OutputKeys.METHOD));//result is [text] // second reset transformer.reset(); //Assertion fails because result is [text] assertEquals(null, transformer.getOutputProperty(OutputKeys.METHOD)); [/code]

    (1-2/2)

    Please register to reply