如何在 concat 中放置简单的引号 - Xpath 1.0

How to put simple quote in a concat - Xpath 1.0

所以我想创建这个字符串:

insert into TABLE values(651665, 'c e d b f a i');

我已经使用 Xpath 创建了这个字符串:

concat('insert into TABLE values(', //OneNode/@id, ', `', //myNode, '`);')

这给了我:

insert into TABLE values(651665, ` c e d b f a i `);

但现在我想将 ` 替换为 ' 。有没有办法在 Xpath 1.0 中做到这一点?

为易读性包装:

concat(
  'insert into TABLE values(', 
  "'", 
  //OneNode/@id, 
  ', ',
  //myNode, 
  "'",
  ');'
)

XPath 字符串可以以 "' 开头,并且它们不能包含分隔符,即没有字符串转义机制。

这意味着以上是有效的 XPath,但需要额外的转义才能使其在 XML 属性(如 XSLT <xsl:value-of select="..." />)内有效:

<xsl:value-of select="
concat(
  'insert into TABLE values(', 
  &quot;'&quot;, 
  //OneNode/@id, 
  ', ',
  //myNode, 
  &quot;'&quot;,
  ');'
)
" />