Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何避免saxon解析器/xalon解析器中节点/元素之间的空格_Java_Xslt_Xpath_Saxon_Xalan - Fatal编程技术网

Java 如何避免saxon解析器/xalon解析器中节点/元素之间的空格

Java 如何避免saxon解析器/xalon解析器中节点/元素之间的空格,java,xslt,xpath,saxon,xalan,Java,Xslt,Xpath,Saxon,Xalan,我有如下的输入片段 输入片段: <div class="a"> <table> <col width="4" /> <col width="8" /> <col width="5" /> <tbody> <tr> <td>ABC</td>

我有如下的输入片段

输入片段:

    <div class="a">
      <table>
        <col width="4" />
        <col width="8" />
        <col width="5" />
        <tbody>
          <tr>
            <td>ABC</td>
            <td>DEF </td>
            <td>GHI</td>
          </tr>
        </tbody>
      </table>
    </div>
    <div class="x">

    <table>
        <col width="5" />
        <col width="8" />
        <col width="8" />
    <tbody>
          <tr>
            <td>ABC</td>
            <td>DEF </td>
            <td>GHI</td>
          </tr>
        </tbody>
你需要使用

<xsl:strip-space elements="*"/>


在样式表的顶层,告诉它在解析时忽略只有空格的文本节点。

虽然Ian的答案是正确的,但更干净的解决方案是

<xsl:when test="../following-sibling::div[1]/*[1]/self::table">

另外,如果您不关心div和它的表子级之间的任何中间元素,您可以简化为

<xsl:when test="../following-sibling::div[1]/table">

<xsl:when test="../following-sibling::div[1]/table">