我有大量被部分标记的OCRed文档。我正在尝试创建目录内的工作链接。内容列表已格式化
<document>
<text>
<list>
<item>Chapter 1<ref>7</ref></item>
<item>Chapter 2<ref>27</ref></item>
<item>Chapter 3<ref>54</ref></item>
<item>Chapter 4<ref>77</ref></item>
</list>
<body>
OCRED text <pb n="7-8" xml:id="VAB0003"/> OCRED text
</body>
</document>
有没有一种不那么复杂的方法来实现这一点?
发布于 2012-10-17 09:23:56
我想你要找的东西是这样的:
<xsl:template match="ref*">
<xsl:variable name="page" select="."/>
<xsl:variable name="target"
select="//pb[contains(
concat(' ',translate(@n,'-',' '),' '),
concat(' ',$page,' '))]/@xml:id"/>
<xsl:copy>
<xsl:if test="$target">
<xsl:attribute name='target'>
<xsl:value-of select="$target"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
复杂的连接存在于target
的定义中,以确保匹配页码的完整标记;在XSLT2.0中,它可以更优雅地完成,并且不需要连接,但不会更简洁。
https://stackoverflow.com/questions/12906719
复制相似问题