从节点内查找节点 [英] Looking A Nodes From Within Nodes

查看:53
本文介绍了从节点内查找节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经编写了一个模板,可以对子树进行一些工作,但是我想用

替换我最初工作的子树。我该怎么做?


困惑,好的,这是一个例子:


< node>

< node>

< node>

< / node>

< node>

< / node>

< / node>

< node> **

< node>

< / node>

< node>

< /节点>

< / node> **

< / node>

这是一个装满node的二叉树。标签。让'我让我工作

从我用**指示的节点标签开始的子树。让's $

说我已经在子树上完成了我的工作,我想用这个主树替换子树

改变。我还想

更改顶级节点标签(例如,更新属性标签)。

我不能做像
这样的事情/>
< xsl:element>

< xsl:attribute counter =" / node / @ counter + 1" />

< xsl:copy-of select =" / node / * [position()= 1]" />

< xsl:copy-of select =" $ outputofsubtreework" />

< / xsl:element>


因为,虽然它会在这种情况下起作用,但我事先并不知道如何

树会有很多级别。


有人能帮帮我吗? :)


Johnny


***通过Developersdex发送 http://www.developersdex.com ***

不要只是参加USENET ......获得奖励!


I''ve written a template that does some work on a subtree, but I want to
replace the subtree that I originally worked on. How would I do this?

Confused, Okay, here''s an example:

<node>
<node>
<node>
</node>
<node>
</node>
</node>
<node> **
<node>
</node>
<node>
</node>
</node> **
</node>

This is a binary tree full of "node" tags. Let''s let I was working on
the subtree starting at the node tag I''ve indicated by the **s. Let''s
say I''ve done my work on the subtree and I want to replace the subtree
in this master tree with the one I''ve just changed. I also want to
change the top level node tag (for example, updating the attribute tag).
I can''t do something like

<xsl:element>
<xsl:attribute counter="/node/@counter+1"/>
<xsl:copy-of select="/node/*[position()=1]"/>
<xsl:copy-of select="$outputofsubtreework"/>
</xsl:element>

Because, while it will work in this case, I don''t know in advance how
many levels the tree will have.

Can anyone help me out here? :)

Johnny

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!

推荐答案

outputofsubtreework" />

< / xsl:element>


因为虽然它会在这种情况下起作用,但我事先并不知道这个树会有多少级别。


任何人都可以帮我出去吗? :)


Johnny


***通过Developersdex发送 http://www.developersdex.com ***

不要只是参加USENET ......获得奖励!
outputofsubtreework"/>
</xsl:element>

Because, while it will work in this case, I don''t know in advance how
many levels the tree will have.

Can anyone help me out here? :)

Johnny

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!




确认!对不起,我错误地说了这个问题。当我说顶级

节点标签时,我的意思是指出子树根的父节点。

所以,在这个例子中,它是'树的根,但在另一种情况下,

它可能不是。


并且为这个例子道歉,压痕没有显示出来正确。

Ack! Sorry, I phrased the problem incorrectly. When I said "top level
node tag", I meant to indicate the parent of the root of the subtree.
So, in this example, it''s the root of the tree, but in another scenario,
it might not be.

And apologies for the example, by indentations didn''t show up correctly.
__<




Johnny


***通过Developersdex http://www.developersdex.com ***

Don''只是参加USENET ......获得奖励!



Johnny

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


>我想用我刚改变的那个替换这个主树中的子树
> I want to replace the subtree
。我还想更改顶级节点标签(例如,更新属性标签)。
我不能做类似的事情

< xsl:element>
< xsl:attribute counter =" / node / @ counter + 1" />
< xsl:copy-of select =" / node / * [position()= 1] " />
< xsl:copy-of select ="
in this master tree with the one I''ve just changed. I also want to
change the top level node tag (for example, updating the attribute tag).
I can''t do something like

<xsl:element>
<xsl:attribute counter="/node/@counter+1"/>
<xsl:copy-of select="/node/*[position()=1]"/>
<xsl:copy-of select="


这篇关于从节点内查找节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆