⚲
Project
Profile
Help
Tour this page
Frequent Planio Questions
Learning Resources
Sign in
Register
Switch Planio account
Open in Planio App
Share current page
Search
:
Projects
All Projects
Help
Tour this page
Frequent Planio Questions
Learning Resources
Sign in
Register
Switch Planio account
Open in Planio App
Share current page
Saxon
Overview
Roadmap
Issues
Calendar
Blog
Documents
Forums
Files
Repository
Download (1.38 KB)
Bug #2689
» OutputPropertiesTest.java
Peter van der Velde
, 2016-03-30 09:30
package
com.anachron.implementation.hertz.parser
;
import
java.io.ByteArrayOutputStream
;
import
javax.xml.transform.Templates
;
import
javax.xml.transform.Transformer
;
import
javax.xml.transform.TransformerException
;
import
javax.xml.transform.TransformerFactory
;
import
javax.xml.transform.stream.StreamResult
;
import
javax.xml.transform.stream.StreamSource
;
import
junit.framework.Assert
;
import
org.junit.Test
;
public
class
OutputPropertiesTest
{
@Test
public
void
testProperties
()
throws
TransformerException
{
TransformerFactory
tfactory
=
TransformerFactory
.
newInstance
();
// <?xml version="1.0" encoding="utf-8"?>
// <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
// version="2.0">
// <xsl:output method="text" encoding="UTF-8" />
// </xsl:stylesheet>
Templates
t
=
tfactory
.
newTemplates
(
new
StreamSource
(
this
.
getClass
().
getResourceAsStream
(
"/outputProperties.xsl"
)));
Transformer
transformer
=
t
.
newTransformer
();
// <?xml version="1.0" encoding="UTF-8"?>
// <test>
// </test>
StreamSource
source
=
new
StreamSource
(
this
.
getClass
().
getResourceAsStream
(
"/outputProperties.xml"
));
// output
StreamResult
result
=
new
StreamResult
(
new
ByteArrayOutputStream
());
// transform
transformer
.
transform
(
source
,
result
);
Assert
.
assertEquals
(
"text"
,
transformer
.
getOutputProperties
().
getProperty
(
"method"
));
}
}
« Previous
1
2
3
Next »
(3-3/3)
Loading...