Xslt 使用xsl确定一个特定标记后面是否跟有另一个特定标记
我有代码检查head1是否为空,并写入错误日志:Xslt 使用xsl确定一个特定标记后面是否跟有另一个特定标记,xslt,Xslt,我有代码检查head1是否为空,并写入错误日志: <xsl:template match="w:p[w:pPr/w:pStyle/@w:val='head1']"> <xsl:variable name="elementValue"> <xsl:apply-templates mode="title.text.only" /> </xsl:variable> <xsl:choose>
<xsl:template match="w:p[w:pPr/w:pStyle/@w:val='head1']">
<xsl:variable name="elementValue">
<xsl:apply-templates mode="title.text.only" />
</xsl:variable>
<xsl:choose>
<xsl:when test="$elementValue = ''">
<xsl:message>ERROR: Encountered an head 1 paragraph with no text content.</xsl:message>
<xsl:call-template name="revealDocPosition"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="sectionTitle" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
错误:遇到没有文本内容的标题1段落。
但是我还需要代码来检查head1后面的标记是否是body标记,如果不是,请给我一个错误。我不关心body标签的内容,只关心h1后面跟着body标签。我不知道如何做到这一点,只是我对使用正则表达式的研究没有成功。我不可能是第一个检查这个或类似的东西的人。这是一种错误的做法:
<xsl:when test=following-sibling::$elementValue[1][self::body]>
<xsl:otherwise>
<xsl:message>ERROR: Encountered an head 1 paragraph that was not followed by a body tag.</xsl:message>
<xsl:call-template name="revealDocPosition"/>
</xsl:otherwise>
</xsl:when>
错误:遇到标题1段落,该段落后面没有正文标记。
有什么想法吗?你能发布XML部分吗?这里是我要搜索的内容的一个片段,标题1后接正文:第三方通知和/或许可证云使用的开源软件产品或组件所需的通知以及适用的许可证信息在下表中确定。是否满足要求?谢谢!这段代码检查head1后面是否跟body。有没有办法测试head1后面是否有body?