xsl-list
[Top] [All Lists]

RE: [xsl] How to retrieve global parameters names and their default values using Saxon?

2006-05-08 12:59:28
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/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--