xml - xslt转换

标签 xml xslt

我正在开发一个应用程序,我需要转换如下所示的 XML 文档:

<?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE markables SYSTEM "markables.dtd">
<markables>
<markable id="markable_1" mmax_level="coref" span="word_1..word_4"> </markable>
<markable id="markable_2" mmax_level="coref" span="word_6..word_7"> </markable>
<markable id="markable_3" mmax_level="coref" span="word_10..word_24"> </markable>
</markables>

使用 XSLT 样式表。我希望转换的结果为(在本例中)word_1 word_6 word_10,这是我正在使用的 XSL:

<?xml version='1.0' encoding='ISO-8859-1'?>

<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="markable">
  <html>
  <body>
    <tr>
      <td><xsl:value-of select="@span"/></td>
    </tr>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>

结果为word_1..word_4 word_6..word_7 word_10..word_24。我必须在 XSLT 中更改哪些内容?

最佳答案

您需要使用 XSLT 函数,即 fn:substring-before(@span, '..')

关于xml - xslt转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10042682/

相关文章:

Android:如何使 TextView 向左浮动?

使用 UTF-8 进行输出时,Python ElementTree 不会转换不间断空格

xml - XSLT:从一个上下文移动到 for-each 内的其他上下文节点

xslt - XPATH 选择类型的元素名称为 xs :simpleType 的子元素

xslt - 为什么 XPath 中的索引从 1 而不是 0 开始?

c# - 将 T-SQL 转换为 LINQ-to-SQL

xml - http ://xml. apache.org/xml-soap 去哪儿了?

c# - 在 .NET XSLT 中使用 document() 函数会产生错误

c# - 如何以编程方式创建 .xsn (InfoPath) 文件

Listview 上的 Android 子项