XSLT:深子副本 [英] XSLT: deep child copy

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

问题描述

我的需求:我想深度复制单个选定节点的所有子节点,而不实际复制它.示例:来自

My need: I want to deep copy all the childs of a single selected node without actually copying it. Example: from

<father><son i="1" /><son i="2" /><son i="0"><lastNode /></son></father>

我想提取

<son i="1" /><son i="2" /><son i="0"><lastNode /></son>

我知道我可以用一个循环 for-each 然后一个 xsl:copy-of 来做到这一点.我想知道是否有更简单的表达式来实现相同的结果.有什么想法吗?

I know that i can do this with a cycle for-each and then a xsl:copy-of. I am wondering if there is a simpler expression to achieve the same result. Some idea?

跟进.我的问题遗漏了几点.我应该说所有孩子的意思是所有可能的孩子",包括文本节点;另一个验证更好的问题已经包含答案.其次,我从你们 - 社区 - 那里学到的是,我足够愚蠢,试图通过 XSL 解决实际上更像是 XPATH 问题的问题.感谢大家的洞察力

Follow-up. My question missed a couple of points. I should had said that all the childs means "all the possible childs", including textnodes; another verification that a better question already contains the answer. Second, what I have learned from you - the community - is that I was enough dumb to try to solve by XSL what in facts was more a XPATH issue. Thanks to all of you for this insight

干杯.

推荐答案

尝试选择所有子项..

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
    <xsl:copy-of select="father/*"/>
</xsl:template>
</xsl:stylesheet>

E.G.给定输入

<father><son i="1" /><son i="2" /><niceSon /><son i="0"><lastNode /></son></father>

输出

<son i="1" /><son i="2" /><niceSon /><son i="0"><lastNode /></son>

这篇关于XSLT:深子副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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