求解一个xslt转换的例子

snow02203835 2019-12-13 03:40:19
现在有xslt转换出来的结果如下:


而我期待的效果是这样的,请问有什么办法可以解决嘛?


附代码:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="bib">
<results>
<xsl:apply-templates/>
</results>
</xsl:template>
<xsl:template match="book">
<result>
<xsl:apply-templates select="./author"/>
</result>
</xsl:template>
<xsl:template match="author">
<xsl:variable name="tests" select="./last"/>
<xsl:copy>
<xsl:copy-of select="./last"/>
<xsl:copy-of select="./first"/>
</xsl:copy>
<xsl:call-template name="join">
<xsl:with-param name="list" select="../../book/title" />
</xsl:call-template>
</xsl:template>
<xsl:template name="join">
<xsl:param name="list"/>
<xsl:for-each select="$list">
<title><xsl:value-of select="."/></title>
</xsl:for-each>
</xsl:template>
<xsl:template match="title"/>
<xsl:template match="publisher"/>
<xsl:template match="price"/>
<xsl:template match="editor"/>
</xsl:stylesheet>


<!DOCTYPE bib SYSTEM "bib.dtd">
<bib>
<book year="1994">
<title>TCP/IP Illustrated</title>
<author>
<last>Stevens</last>
<first>W.</first>
</author>
<publisher>Addison-Wesley</publisher>
<price> 65.95</price>
</book>
<book year="1992">
<title>Advanced Programming in the Unix environment</title>
<author>
<last>Stevens</last>
<first>W.</first>
</author>
<publisher>Addison-Wesley</publisher>
<price>65.95</price>
</book>
<book year="2000">
<title>Data on the Web</title>
<author>
<last>Abiteboul</last>
<first>Serge</first>
</author>
<author>
<last>Buneman</last>
<first>Peter</first>
</author>
<author>
<last>Suciu</last>
<first>Dan</first>
</author>
<publisher>Morgan Kaufmann Publishers</publisher>
<price>39.95</price>
</book>
<book year="1999">
<title>The Economics of Technology and Content for Digital TV</title>
<editor>
<last>Gerbarg</last>
<first>Darcy</first>
<affiliation>CITI</affiliation>
</editor>
<publisher>Kluwer Academic Publishers</publisher>
<price>129.95</price>
</book>
</bib>
...全文
51 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧