This conversation would be better conducted on the Saxon list...
You could pick up all constant expressions, of whatever type, using the test
if X instanceof Value
return ((Value)X).getStringValue()
Note that if the expression is written as select="2+2", you will probably
get back the pre-evaluated result, "4".
You could pick up the special case of
<xsl:param>xyz</xsl:param>
using
if X instanceof TextFragmentValue
return ((TextFragmentValue)X).getStringValue()
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Abel Braaksma Online [mailto:abel(_dot_)online(_at_)xs4all(_dot_)nl]
Sent: 10 May 2006 14:37
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] How to retrieve global parameters names
and their default values using Saxon?
A follow up after some testing and trial and error. The
proposed solution works partially, thanks again for this
pointer, but we get (indeed Michael, you were right) strange
results for any <xsl:param> value that is not a quoted literal. So:
A. <xsl:param name="somenameA" select=" 'literal-string-A' "
/> B. <xsl:param name="somenameB" >literal-string-B</xsl:param>
(A) correctly returns "literal-string-A" (incl. quotes)
(B) (in?) correctly returns
"net(_dot_)sf(_dot_)saxon(_dot_)instruct(_dot_)DocumentInstr(_at_)d1a34a"
(without quotes)
We have tried evaluateAsString (Expression and ComputedExpression
classes) and some other things, basically all requiring an
XPathContext, and setting context to null did not help,
although the docs hint as if it should.
My guess is that the XSLT processor sees the content of (B)
as a node set, containing one node, namely a text node. I
wonder, is there a way of doing something like:
rootContext = compiledStylesheet.getRootContext();
if(ParamB.canEvaluateToString())
return ParamB.evaluateToString(rootContext);
else
return null;
So: I would like to know a way to get the normalized string
representation, unless the xsl:param is a node set (other
than a single text node) or an xpath instruction.
Any help on this follow up is greatly appreciated.
Cheers,
Abel
andrew welch wrote:
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
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--