XSL,匹配后代但不是叶节点 [英] XSL , match descendant but not leaf nodes
问题描述
您好
以下是我的问题。
1。如何匹配desecendant或self节点,但每个条件匹配单个叶子或终端节点
我必须根据选择条件处理属性
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; <的xsl:for-每个选择= QUOT;后代或自节点但不是叶节点" />
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < XSL:选择>
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < XSL:当测试= QUOT;后代">
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; --do处理 -
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < / XSL:当>
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < XSL:否则>
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; --get该叶节点的值---
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < / XSL:否则>
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP; < / XSL:选择>
&NBSP;
您可能需要来发布XML示例,显示您要处理的节点类型。也许
< xsl:for-each select =" descendant-or-self :: * [*]">
是你需要的,它处理后代的所有元素节点 - 或 - 具有至少一个子元素的自身轴。如果你真的对所有类型的节点感兴趣,那就行了。
< xsl:for-each select =" descendant-or-self :: node()[node()]">
Hi
Below is my problem.
1 . how to match the desecendant or self node but a leaf or terminal nodes in a single for each condition
I have to process the attributes based on choose condition
<xsl:for-each select="descendant or self node but not leaf node"/>
<xsl:choose>
<xsl:when test="descendant">
--do processing--
</xsl:when>
<xsl:otherwise>
--get the value of the leaf node ---
</xsl:otherwise>
</xsl:choose>
You might want to post a sample of your XML to show what kind of nodes you want to process. Perhaps
<xsl:for-each select="descendant-or-self::*[*]">
is what you need, it processes all element nodes on the descendant-or-self axis that have at least one child element. If you are really interested in all kind of nodes then do e.g.
<xsl:for-each select="descendant-or-self::node()[node()]">
这篇关于XSL,匹配后代但不是叶节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!