1
|
package eu.dnetlib.data.collector;
|
2
|
|
3
|
import org.junit.Before;
|
4
|
import org.junit.Test;
|
5
|
|
6
|
import eu.dnetlib.miscutils.functional.xml.ApplyXslt;
|
7
|
|
8
|
public class ApplyXsltTest {
|
9
|
|
10
|
private final String xslt = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
11
|
+ "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" "
|
12
|
+ "xmlns:dyn=\"http://exslt.org/dynamic\" extension-element-prefixes=\"dyn\"> " + "<xsl:param name=\"elem\" select=\"string('aa')\"/> "
|
13
|
+ "<xsl:template match=\"/\"> " + "<output>" + "<cc><xsl:value-of select=\"//*[local-name()=$elem]\" /></cc>" + "</output>"
|
14
|
+ "</xsl:template>" + "</xsl:stylesheet>";
|
15
|
|
16
|
private ApplyXslt f;
|
17
|
|
18
|
@Before
|
19
|
public void setUp() throws Exception {
|
20
|
//System.out.println(xslt);
|
21
|
f = new ApplyXslt(xslt);
|
22
|
System.out.println(f.getTransformer().getClass().getCanonicalName());
|
23
|
}
|
24
|
|
25
|
@Test
|
26
|
public void test() {
|
27
|
System.out.println(f.evaluate("<record><aa>1234</aa><bb>metadata</bb></record>"));
|
28
|
}
|
29
|
|
30
|
}
|