Subject: RE: How to retrieve global parameters names and their default values using Saxon?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 8 May 2006 20:59:12 +0100
|
> Use:
>
> compiledStylesheet = stf.newTemplates(new
> StreamSource(stylesheetPath));
> Executable exec =
> ((PreparedStylesheet)compiledStylesheet).getExecutable();
> IntHashMap map = exec.getCompiledGlobalVariables();
> Iterator iter = map.valueIterator();
> while (iter.hasNext()) {
> Object var = iter.next();
> if (var instanceof GlobalParam) {
> String name = ((GlobalParam)var).getVariableName();
> String value =
> ((GlobalParam)var).getSelectExpression().toString();
>
> cheers
> andrew
Thanks Andrew. It's not as bad as I remembered it ;-)
One caveat here is that toString() won't decompile a complex expression. But
the select expression of a xsl:param will in most cases be a literal, so you
should be OK.
Michael Kay
http://www.saxonica.com/
|