我正在开发一个应用程序,我需要转换如下所示的 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/