这个XSLT问题对我来说毫无意义 [英] This XSLT problem makes no sense to me
问题描述
上下文:
我正在尝试比较XML树片段,我正在这样做,
输出每个元素的属性树和输出
到一个字符串然后规范化字符串。然后我正在对下面的兄弟:: *进行包含
当前字符串以确定是否
我们有重复项。如果我们有副本,我们移动到下一个项目,
如果没有重复,我们输出小树。
我正在点击一个完全荒谬的问题,我无法包裹我的脑袋
。我花了2个小时试图理解为什么会发生这种情况昨天我将要打电脑。当我输出一个字符串
时,它与逻辑没有直接联系(或者至少显然没有与逻辑相关联),逻辑是有效的。当我删除字符串输出时,
逻辑停止工作。唉!
这里是XSLT片段
< xsl:variable name =" current">
< xsl:apply-templates mode = "串QUOT; />
< / xsl:variable>
< xsl:variable name =" rest">
< xsl:apply-templates select =" following-sibling :: *"
mode =" string" />
< / xsl:variable>
< xsl:variable name =" current-normalized">
< xsl:value-of select =" normalize-space($ current)" />
< / xsl:variable>
< xsl:variable name =" rest-normalized">
< xsl:value-of select =" normalize-space($ rest)" />
< / xsl:variable>
<! - < fix /怎么回事? - >
<! - < xsl:value-of select =" $ current-normalized" /> - >
< xsl:choose>
< xsl:when test =" contains($ rest-normalized,$ current-
normalized)">
< duplicate />
< / xsl:when>
< xsl:otherwise>
< noproblem />
< / xsl:否则>
< / xsl:选择>
< / xsl:template> ;
当< xsl:value-of select =" $ current-normalized" /未被评论
out时,我得到字符串表示在每个项目的输出中以规范化的
形式的XML树和正确的< duplicate /和
< noproblem / get输出在
规范化字符串。当我注释掉< xsl:value-of
select =" $ current-normalized" />时,标准化的当前字符串,如
预期,停止正在输出,但我的所有输出都是< noproblem /> ;.
到底是什么?我在这里错过了什么?
问候
Jean-Francois Michaud
< BLOCKQUOTE>电流)" />
< / xsl:variable>
< xsl:variable name =" rest-normalized">
< xsl:value-of select =" normalize-space(
rest)" />
< / xsl:variable>
<! - < fix /怎么回事? - >
<! - < xsl:value-of select ="
current-normalized" /> - >
< xsl:choose>
< xsl:when test =" contains(
Context:
I''m trying to compare XML tree fragments and I''m doing so by
outputting the attributes of each element in the tree and outputting
it to a string then normalizing the strings. Then I''m doing a contains
of the current string against the following-sibling::* to determine if
we have duplicates. If we have a duplicate, we move to the next item,
if there is no duplicate, we output the small tree.
I''m hitting a completely ridiculous problem that I can''t wrap my head
around. I spend easily 2 hours trying to understand why this happened
yesterday and I''m about to punch the computer. When I output a string
that''s not directly tied to the logic (or at least apparently not tied
to the logic), the logic works. When I remove the string output, the
logic stops working. Argh!
Here''s the XSLT snippet
<xsl:template match="item-wrapper" mode="string">
<xsl:variable name="current">
<xsl:apply-templates mode="string" />
</xsl:variable>
<xsl:variable name="rest">
<xsl:apply-templates select="following-sibling::*"
mode="string" />
</xsl:variable>
<xsl:variable name="current-normalized">
<xsl:value-of select="normalize-space($current)" />
</xsl:variable>
<xsl:variable name="rest-normalized">
<xsl:value-of select="normalize-space($rest)" />
</xsl:variable>
<!-- <fix/What the hell? -->
<!-- <xsl:value-of select="$current-normalized"/>-->
<xsl:choose>
<xsl:when test="contains($rest-normalized, $current-
normalized)">
<duplicate/>
</xsl:when>
<xsl:otherwise>
<noproblem/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
When <xsl:value-of select="$current-normalized"/is not commented
out, I get the string representation of the XML tree in a normalized
form in the output for each item and the correct <duplicate/and
<noproblem/get outputted in the correct location after the
normalized strings. When I comment out the <xsl:value-of
select="$current-normalized"/>, the normalized current string, as
expected, stops being outputted, but all my outputs are <noproblem/>.
What the hell? What am I missing here?
Regards
Jean-Francois Michaud
current)" />
</xsl:variable>
<xsl:variable name="rest-normalized">
<xsl:value-of select="normalize-space(
rest)" />
</xsl:variable>
<!-- <fix/What the hell? -->
<!-- <xsl:value-of select="
current-normalized"/>-->
<xsl:choose>
<xsl:when test="contains(
这篇关于这个XSLT问题对我来说毫无意义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!