如何使用xsl合并多个xml文件?
发布时间:2020-12-16 07:46:19 所属栏目:百科 来源:网络整理
导读:我需要合并下面的3 xml文件uisng xsl in 1.0 在XML FILE:01.xml中 xmlResponse Person FirstNameFirstName_1/FirstName LastNameLastName_1/LastName /Person Person FirstNameFirstName_2/FirstName LastNameLastName_2/LastName /Person/xmlResponse 在XM
我需要合并下面的3 xml文件uisng xsl in 1.0
在XML FILE:01.xml中 <xmlResponse> <Person> <FirstName>FirstName_1</FirstName> <LastName>LastName_1</LastName> </Person> <Person> <FirstName>FirstName_2</FirstName> <LastName>LastName_2</LastName> </Person> </xmlResponse> 在XML FILE:02.xml中 <xmlResponse> <Person> <FirstName>FirstName_2</FirstName> <LastName>LastName_2</LastName> </Person> <Person> <FirstName>FirstName_3</FirstName> <LastName>LastName_3</LastName> </Person> <Person> <FirstName>FirstName_4</FirstName> <LastName>LastName_4</LastName> </Person> </xmlResponse> 在XML FILE:03.xml中 <xmlResponse> <Person> <FirstName>FirstName_5</FirstName> <LastName>LastName_5</LastName> </Person> </xmlResponse> 我需要输出如下(01.xml 02.xml 03.XML) <xmlResponse> <Person> <FirstName>FirstName_1</FirstName> <LastName>LastName_1</LastName> </Person> <Person> <FirstName>FirstName_2</FirstName> <LastName>LastName_2</LastName> </Person> <Person> <FirstName>FirstName_2</FirstName> <LastName>LastName_2</LastName> </Person> <Person> <FirstName>FirstName_3</FirstName> <LastName>LastName_3</LastName> </Person> <Person> <FirstName>FirstName_4</FirstName> <LastName>LastName_4</LastName> </Person> <Person> <FirstName>FirstName_5</FirstName> <LastName>LastName_5</LastName> </Person> </xmlResponse> 希望你的回应,
使用文件功能:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/xmlResponse"> <xsl:copy> <xsl:apply-templates select="Person"/> <xsl:apply-templates select="document('2.xml')/*/Person"/> <xsl:apply-templates select="document('3.xml')/*/Person"/> </xsl:copy> </xsl:template> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |