如何检查第一个前一个兄弟是xslt 2.0中上下文节点的w:tbl?

时间:2012-08-30 06:42:20

标签: xml xslt xpath xslt-2.0 xpath-2.0

这是XML文档。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        <w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
                    xmlns:v="urn:schemas-microsoft-com:vml">
        <w:body>

          <w:p>para1</w:p>
          <w:tbl>table data 1</w:tbl>
          <w:p>para2</w:p>   <!-- have to check whether this node is w:tbl or not  with respect to the context node below-->
          <w:tbl>table data 2</w:tbl> <!-- Assume this is context node -->

       </w:body>
      </w:document>

所以,我想检查上下文节点[<w:p>para2</w:p>] 第一个前兄弟[<w:tbl>table data 2</w:tbl>] <w:tbl&gt; 与否。

请指导我摆脱这个问题...

1 个答案:

答案 0 :(得分:6)

我想你要求

<xsl:if test="preceding-sibling::*[1]/self::w:p">....</xsl:if>