Subject: RE: [xsl] Getting max attribute value of an element by attribute value... From: "Brinkman, Theodore" <Theodore.Brinkman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 28 Nov 2001 14:39:38 -0500 |
Never mind. I figured it out. I accidentally typed <xsl:variable name="ability"/> instead of <xsl:param name="ability"/>. - Theo -----Original Message----- From: Brinkman, Theodore [mailto:Theodore.Brinkman@xxxxxxxxxxxxxxxxxxxx] Sent: Wednesday, November 28, 2001 2:24 PM To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx' Subject: RE: [xsl] Getting max attribute value of an element by attribute value... That solved it. Now I've got another problem, though. I've got a new template that takes a parameter and returns a formatted version of that parameter. No problems there. I'm trying to rewrite another template to be able to be called regardless of what entity is currently matched. The two templates in question are below. (The various '???Mod' templates are identical except the ??? part is replaced throughout. Any place with '...' denotes a bulk of non-problematic, or essentially identical code removed for clarity's sake.) - - - - - <xsl:template name="strMod"> <xsl:variable name="str" select="abilities/@str"/> <xsl:variable name="mod" select="($str div 2) - 5"/> <xsl:value-of select="round($mod - .5)"/> </xsl:template> <xsl:template name="abilityMod"> <xsl:variable name="ability"/> <xsl:variable name="up" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/> <xsl:variable name="lo" select="'abcdefghijklmnopqrstuvwxyz'"/> <xsl:if test="translate($ability,$up,$lo)='str'"><xsl:call-template name="strMod"/></xsl:if> ... </xsl:template> - - - - - Excerpt from MUCH larger stylesheet. - - - - - <xsl:for-each select="skills/skill"> <tr> ... <td class="borderbottom" valign="bottom" align="middle" width="13%"> <font style="FONT-SIZE: 8pt"> <xsl:call-template name="formatMod"> <xsl:with-param name="mod"> <xsl:call-template name="abilityMod"> <xsl:with-param name="ability"> <xsl:value-of select="@ability"/> </xsl:with-param> </xsl:call-template> </xsl:with-param> </xsl:call-template> </font> </td> ... </tr> </xsl:for-each> - - - - - The pertinant xml looks something like this: - - - - - <DD3e-character attributes="..."> ... <abilities str="18" dex="13" con="15" int="6" wis="7" cha="11"/> ... <skills> <skill name="Run" ranks="4" ability="STR" uri="../skill/run.xml"/> </skills> ... </DD3e-character> - - - - - The 'strMod' template works fine if the last match was 'DD3e-character', but I'm in the midst of an <xsl:for-each select='skills/skill'>, and I need to do an <xsl:call-template name="strMod"/> which doesn't return a darned thing at that point. What's the syntax for an absolute path from the root node? - Theo -----Original Message----- From: David_N_Bertoni@xxxxxxxxx [mailto:David_N_Bertoni@xxxxxxxxx] Sent: Wednesday, November 28, 2001 12:58 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Getting max attribute value of an element by attribute value... "Brinkman, Theodore" <Theodore.Brinkman@xxxxxxxxxxxxxxxxxxxx> wrote: > <xml:call-template name="hitPoints"/> should return: > 26 = 17 + (+2 * 3) + (1 * 3) > > But instead I get: > NaN = 17 + (+2 * 3) + (1 * 3) > > All of the xsl:call-template calls within hitPoints return the proper > values. What am I missing here? > > - Theo It's hard to tell, since you don't provide your implementation of the template conMod, but it looks like it's returning the string '+2'. If that's the case, '+2' cannot be converted to a number, as there is no unary + operator in XPath. Thus, it's converted to NaN and the result of any numeric operation with NaN is always NaN. Dave XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Announce: Upcoming XSL styles, G. Ken Holman | Thread | [xsl] value-of select="." returning, L Rutker |
[xsl] Announce: Upcoming XSL styles, G. Ken Holman | Date | Re: [xsl] Getting max attribute val, Jörg Heinicke |
Month |