xslt - 如何使用 XSL 从父节点复制所有子节点
问题描述
以下是我的输入:
<csv>
<row>
<stuff>a</stuff>
<more>1</more>
<evenmore>123</evenmore>
<roww>
<other>1345</other>
<other>13845</other>
</roww>
</row>
</csv>
预期输出:
<roww>
<other>1345</other>
<other>13845</other>
</roww>
谁能让我知道如何使用 XSL 做到这一点?
解决方案
好吧,这只是为了匹配父节点并执行copy-of
.
该<xsl:copy-of>
元素创建当前节点的副本。
注意:命名空间节点、子节点和当前节点的属性也会自动复制!
实现预期输出的XSLT 1.0解决方案可以是:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/csv">
<xsl:copy-of select="row/roww" />
</xsl:template>
</xsl:stylesheet>
推荐阅读
- kubernetes - 为什么 Kubernetes 中的 pod 会自动挂载服务帐户密钥?
- mysql - 如何一次从所有表中选择?
- sql - 两个元组之间的 SQL 索引,AND 条件
- reactjs - 尝试使用 redux-thunk,但它显示错误,即使对我来说一切都很好
- postgresql - 返回诗的总数,提到死亡的诗和提到爱的诗的平均字符数
- spring-boot - 使用 openhtmltopdf 将 HTML 内容绘制到现有的 PDDocument
- sql-server - 为什么 sqlpackage 发布操作需要 30 分钟?
- express - 从数据库传递对象数组时Expressjs访问控制错误
- r - 自定义函数检查每列的数据类型
- c++ - 为什么这个程序在容器中运行而不在主机上运行?