1

我正在尝试用附属链接替换 ​​xml 输出中的 XXXXX。我在想替换功能是一个选项,但我无法让它正常工作。

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <html>
  <body>
  <h2>PayDotCom (By Popularity)</h2>
  <table border="1">
    <tr bgcolor="#9acd32">
      <th>Score</th>
      <th>Affiliate Link</th>
      <th>Name</th>
    </tr>
    <xsl:for-each select="marketplace/Product">
    <tr>
      <td><xsl:value-of select="aps"/></td>
      <td><xsl:value-of select="salespage"/></td>
      <td><xsl:value-of select="name"/></td>
    </tr>
    </xsl:for-each>
  </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

下面是 XML 输出的片段,它显示了 Affiliate Link 下的 XXXXX。

PayDotCom (By Popularity)

Score     Affiliate Link                            Name
52949.7   http://paydotcom.com/r/95330/XXXXX/       The Best Spinner
27828.8   http://paydotcom.com/r/10031/XXXXX/       My Data Team Global Data Entry &     Traditional Data Entry Jobs
12750.9   http://paydotcom.com/r/16329/XXXXX/       3WayLinks.net Subscription
10380.4   http://paydotcom.com/r/9912/XXXXX/        Instant Article Wizard
9438.49   http://paydotcom.com/r/98870/XXXXX/       The Smart Cash System - Make $4000 Per Week From Home

如果我需要澄清更多,请告诉我。提前致谢。

4

1 回答 1

1

replace()是 XPath 2.0 函数,仅在 XSLT 2.0(和 3.0)中可用。

您的样式表是 XSLT 1.0。

substring-before()是 XSLT 1.0 中可用的 XPath 1.0 函数:

<xsl:value-of select="substring-before(salespage, 'XXXXX')"/>
于 2013-10-04T00:05:44.683 回答