Function call within xslif test

Asked 2 years ago, Updated 2 years ago, 229 views

As shown below, I would like to apply another function (normalize-space) to a given element within the if function conditions and use the results for comparison.
does not allow you to view xml with xsl on your browser, including the following:(The screen is blank)
If you delete the description below, it will be displayed normally.
Is this kind of description impossible?
Also, if there is an alternative plan, please let me know.
Thank you for your cooperation.

Also, the XSL version is 1.0 because I want to read it in C#.

<xsl:if test="element1/element2[element3/normalize-space(element4)='AAA']/element5!='">
~
</xsl:if>

Additional
I have created a template to apply to the corresponding elements as follows:
It doesn't seem to be applied within [ ] below, so it didn't work...
element1/element2 [element3/element4='AAA']/element5

<xsl:template match="element1/element2/element3/element4">
    <xsl:call-template name="normalizespace">
      <xsl:with-param name="string" select="."/>
    </xsl:call-template>
  </xsl:template>

  <xsl:template name="normalizespace">
    <xsl:param name="string"/>
    <xsl:value-of-select="normalize-space($string)"/>
  </xsl:template>

c# xpath xsl xslt

2022-11-23 08:39

1 Answers

<xsl:if test="element1/element2[element3/normalize-space(element4)='AAA']/element5!='">
~
</xsl:if>

However, it is not correct as XPath. normalize-space() is a function, and function calls cannot be placed at least immediately after [].

<xsl:if test="element1/element2[normalize-space(element3/element4)='AAA']/element5!='">
~
</xsl:if>

must be written as


2022-11-23 16:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.