【问题标题】:XSLT preceding sibling to limit foreachXSLT 在同级之前限制 foreach
【发布时间】:2018-04-19 05:48:53
【问题描述】:

我的 xml 的一大块是:

<svg>
<g id='NOCUT'>
<line x="5.0"/>
<line x="55.0"/>
<path x="50.0"/>
<line x="0.0"/>
<line x="55.0"/>
.
.
</g>
</svg>

在我的 xslt 中,我应该只能在遇到 x=0 之前读取此列表;它之后的所有元素都需要忽略。

我尝试写如下内容,但它不起作用:

<xsl:for-each select="svg[g/@id='NOCUT']">
<xsl:for-each select="g/*[preceding-sibling::node[line/@x = '0.0']]">
<xsl:value-of select="x"/>      
</xsl:foreach>
</xsl:foreach>

我做错了什么?

【问题讨论】:

    标签: c# .net xml xslt xslt-1.0


    【解决方案1】:

    你可以使用

    <xsl:for-each select="g/*[not(preceding-sibling::line[@x = '0.0'])]">
    

    而不是

    <xsl:for-each select="g/*[preceding-sibling::node[line/@x = '0.0']]">
    

    还有

    &lt;xsl:value-of select="x"/&gt; 更改为&lt;xsl:value-of select="@x"/&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多