Comparing apostrophe text in xsl

I have a problem with text with an apostrophe symbol

For example, I'm trying to check this xml having a character, then how can I compare?

<xsl:for each select="country[nation='India's]">

this statement showing error

Relationship Nanda.A

+5
source share
1 answer

One way to do this:

<xsl:variable name="apos" select='"&apos;"'/>

<!-- ... later ... -->

<xsl:for-each select="country[nation=concat('India', $apos, 's')]">

The problem here is twofold:

  • XSLT does not specify how to escape characters in strings. Therefore, 'India\'s'it is not an option.
  • You must go through two different levels of assessment.

It:

  • XML XML Correctness . The XML document that consists of your XSLT program must be well-formed. You cannot violate XML rules.
  • XSLT: ( XML DOM) XSLT.

:

<xsl:for-each select="country[nation='India's']">
<xsl:for-each select="country[nation='India&apos;s']">

XML, XSLT, ( DOM) country[nation='India's'], XPath.

:

<xsl:for-each select="country[nation=concat('India', "'", 's')]">
<xsl:for-each select="country[nation=concat("India", "&apos;", "s")]">

XML-. XSLT (!), ( XSLT ) country[nation=concat('India', "'", 's')], , XPath.

, 1, 2. - , . :

<xsl:for-each select="country[nation=concat('India', &quot;'&quot;, 's')]">

XSLT country[nation=concat('India', "'", 's')].

, " " .

+9

All Articles