-
-
Save jpukg/05f2426ab9d608a7060cbdba69b0d5f9 to your computer and use it in GitHub Desktop.
CustomXpath Junit Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package custom.xpath; | |
import java.io.File; | |
import java.io.FileNotFoundException; | |
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.TestCase; | |
import org.junit.Test; | |
public class CustomXpathTest extends TestCase { | |
public CustomXpathTest() { | |
} | |
@Test | |
public void testToLowerCase() throws FileNotFoundException, | |
TransformerException { | |
System.setProperty("javax.xml.transform.TransformerFactory", | |
"org.apache.xalan.processor.TransformerFactoryImpl"); | |
transform("src/test/resources/input.xml", | |
"src/test/resources/customXpath.xslt", | |
"src/test/resources/out.xml"); | |
} | |
public static void transform(String sourcePath, String xsltPath, | |
String resultDir) { | |
TransformerFactory tFactory = TransformerFactory.newInstance(); | |
try { | |
Transformer transformer = tFactory.newTransformer(new StreamSource( | |
new File(xsltPath))); | |
transformer.transform(new StreamSource(new File(sourcePath)), | |
new StreamResult(new File(resultDir))); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment