xsl-list
[Top] [All Lists]

RE: [xsl] XSL String Mapping Problem.

2008-12-10 05:35:55
I used the XML/XSL snippet below. However the "@key eq ." 
seems not to work.

If I introduce a variable it works fine:

    <xsl:variable name="var" select="."/>
    <xsl:value-of select="$map[(_at_)key eq $var]/@val"/>

"." within a predicate refers to the node that you are testing against the
predicate. This is the problem with context dependency - it's nice and
convenient when it does what you are expecting, and it's a rich source of
bugs when it doesn't.

Questions:

1. How to get this mapper working without variable?

You could use current(), but I'd be inclined to use the variable.

2. What is the the 'defacto XPath standard' for mapping  a 
list hardcoded keys to hardcoded values?

The above is fine - though in XSLT, unless you have a processor with an
unusually good optimizer, like Saxon-SA ;-), you can speed it up using keys.

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>
--~--

<Prev in Thread] Current Thread [Next in Thread>