xsl求助高人,再次洗牌。。。。
时间:2011-04-17
来源:互联网
其实这个题目有发过,但没有合适的,想再发一次,再次求助高人。
题目要求是这样的,name 的个数大于等于小于note的情况都要考虑的,所以,,,,
我自己的代码写的很长很复杂,求助高人。。
下面是input:
XML code
题目要求是这样的,name 的个数大于等于小于note的情况都要考虑的,所以,,,,
我自己的代码写的很长很复杂,求助高人。。
下面是input:
XML code
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE persons SYSTEM "persons.dtd"> <persons> <names> <name>Alan Turing</name> <name>Kurt Gödel</name> </names> <notes> <note>Defined a simple theoretical model of computers</note> <note>Proved the incompleteness of arithmetics</note> <note>Prolific author and creator of TeX</note> <note>Proposed a model of concurrency</note> </notes> </persons> 输出: XML Source Code <?xml version="1.0" encoding="UTF-8"?> <persons> <name>Alan Turing</name> <note>Defined a simple theoretical model of computers</note> <name>Kurt Gödel</name> <note>Proved the incompleteness of arithmetics</note> <note>Prolific author and creator of TeX</note> <note>Proposed a model of concurrency</note> </persons> 下面是我的xsl,献丑了!大家帮我简化简化哈。。。 <?xml version="1.0" encoding="UTF-8"?> <xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent ="yes"/> <xsl:template match="persons"> <xsl:copy> <xsl:call-template name="shu"> <xsl:with-param name ="seq1" select="names/name" as="element(name)*"/> <xsl:with-param name="seq2" select ="notes/note" as="element(note)*"/> </xsl:call-template> </xsl:copy> </xsl:template> <xsl:template name="shu"> <xsl:param name="seq1" as="element(name)*"/> <xsl:param name="seq2" as="element(note)*"/> <xsl:choose> <xsl:when test="(empty($seq1)) and (empty($seq2))"/> <xsl:when test="not(empty($seq1))"> <xsl:sequence select="$seq1[1]"/> <xsl:sequence select="$seq2[1]"/> <xsl:call-template name="shu"> <xsl:with-param name="seq1" select="$seq1[position()>1]"/> <xsl:with-param name="seq2" select="$seq2[position()>1]"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:sequence select="$seq2[1]"/> <xsl:call-template name="shu"> <xsl:with-param name="seq2" select="$seq2[position()>1]"/> <xsl:with-param name="seq1" select="()"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:transform>
作者: cqq8638 发布时间: 2011-04-17
依旧没有人理我,自己顶一个!
作者: cqq8638 发布时间: 2011-04-17
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28