Project

Profile

Help

Saxon-HE 9.5 and getGlobalParameters ยป GlobalParametersTest.java

Francesco Sblendorio, 2013-05-31 11:55

 
import java.io.*;
import java.util.*;
import javax.xml.transform.stream.*;
import net.sf.saxon.*;
import net.sf.saxon.s9api.*;
import org.junit.*;

public class GlobalParametersTest {

@Test
public void globalParametersTest() throws UnsupportedEncodingException, SaxonApiException {
Configuration configuration = Configuration.newConfiguration();
Processor processor = new Processor(configuration);
XsltCompiler xsltCompiler = processor.newXsltCompiler();

String source="<?xml version='1.0'?>" +
" <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'" +
" xmlns:xs='http://www.w3.org/2001/XMLSchema'" +
" version='2.0'>" +

" <xsl:param name='surname' as='xs:string' />" +
" <xsl:param name='age' as='xs:integer' />" +

" <xsl:template match='/'><xsl:element name='root' /></xsl:template>" +
" </xsl:stylesheet>";

XsltExecutable xsltExecutable = xsltCompiler.compile(new StreamSource(new ByteArrayInputStream(source.getBytes("UTF-8"))));
Map<QName, XsltExecutable.ParameterDetails> params = xsltExecutable.getGlobalParameters();

System.out.println();
int i=0;
for (QName key: params.keySet()) {
System.out.println("Parameter n."+(++i)+": "+key);
}
System.out.println();
}
}
    (1-1/1)