XSLT 1.0 不执行正则表达式,但我认为在这种情况下您不需要它们。我将从身份转换开始
<!-- copy everything from input to output verbatim, except where overridden
by more specific templates -->
<xsl:template match="@*|node()">
<xsl:copy><xsl:apply-templates select="@*|node()" /></xsl:copy>
</xsl:template>
然后用一个模板覆盖它,该模板匹配紧跟在inlinegraphic
元素后面并包含的任何文本节点.eps
<xsl:template match="text()[preceding-sibling::node()[1][self::inlinegraphic]]
[contains(., '.eps')]">
<!-- take everything before the first .eps as the graphic name -->
<graphic name="{normalize-space(substring-before(., '.eps'))}.eps"
source="ISBN" in-line="yes"/>
<!-- and leave everything after that as normal text -->
<xsl:value-of select="substring-after(., '.eps')" />
</xsl:template>
最后添加一个模板来移除inlinegraphic
元素本身
<xsl:template match="inlinegraphic" />