[英]Multiply <xsl:value-of> result by -1
Novice/beginner XSL user here. 新手/初学者XSL用户在这里。
I have something like the following template in my XSLT document: 我的XSLT文档中有类似以下模板的内容:
<xsl:template name="getpoint"> <xsl:param name="nodenum"/> <xsl:value-of select="//nodeCoord[nodeNumber=$nodenum]/nodeXCoord"/> <xsl:text>,</xsl:text> <xsl:value-of select="//nodeCoord[nodeNumber=$nodenum]/nodeYCoord"/> </xsl:template>
The full XSLT document is being used to produce an SVG graphic. 完整的XSLT文档正用于生成SVG图形。 However, I wish to flip the browser's Y coordinate system upside down since my source data assumes a traditional coordinate system. 但是,由于源数据采用传统坐标系,因此我希望上下颠倒浏览器的Y坐标系。
My question is very simple: how do I multiply nodeYCoord
by -1 and have that result sent to the browser instead of the value produced by the <xsl:value-of>
element? 我的问题很简单:如何将nodeYCoord
乘以-1并将结果发送到浏览器,而不是<xsl:value-of>
元素生成的<xsl:value-of>
?
EDIT: Please do not provide alternative methods on how to flip the Y coordinate system. 编辑:请不要提供有关如何翻转Y坐标系的替代方法。 I have researched this, and for my specific application I am pretty certain this is the best way to go about it (assuming I can make it work). 我已经对此进行了研究,对于我的特定应用程序,我可以肯定这是实现此目标的最佳方法(假设我可以使其工作)。
My question if very simple: how do I multiply nodeYCoord by -1 and have that result sent to the browser instead of the value produced by the
<xsl:value-of>
element? 我的问题是否很简单:如何将nodeYCoord乘以-1并将结果发送到浏览器而不是<xsl:value-of>
元素生成的<xsl:value-of>
?
And the answer is very simple, too: use the minus sign. 答案也很简单:使用减号。 Instead of: 代替:
<xsl:value-of select="//nodeCoord[nodeNumber=$nodenum]/nodeYCoord"/>
write: 写:
<xsl:value-of select="-//nodeCoord[nodeNumber=$nodenum]/nodeYCoord"/>
Please do not provide alternative methods on how to flip the Y coordinate system. 请不要提供有关如何翻转Y坐标系的替代方法。 I have researched this, and for my specific application I am pretty certain this is the best way to go about it (assuming I can make it work). 我已经对此进行了研究,对于我的特定应用程序,我可以肯定这是实现此目标的最佳方法(假设我可以使其工作)。
Perhaps you should take another look at it. 也许您应该再看一遍。
Save your value to a variable and then use it in an xpath expression 将值保存到变量,然后在xpath表达式中使用它
<xsl:variable name="yval" select="//nodeCoord[nodeNumber=$nodenum]/nodeYCoord/text()"/>
<xsl:value-of select="-1 * $yval"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.