XML转换 – XSL模板匹配多个条件
发布时间:2020-12-16 22:52:02 所属栏目:百科 来源:网络整理
导读:我正在尝试修改calimero中的ets4_import以匹配旧的ETS4项目和新项目. 是否可以修改 xsl:template match="/" xmlns:b="http://knx.org/xml/project/11" 喜欢的东西 xsl:template match="/" xmlns:b="http://knx.org/xml/project/11 or http://knx.org/xml/pro
我正在尝试修改calimero中的ets4_import以匹配旧的ETS4项目和新项目.
是否可以修改 <xsl:template match="/" xmlns:b="http://knx.org/xml/project/11"> 喜欢的东西 <xsl:template match="/" xmlns:b="http://knx.org/xml/project/11 or http://knx.org/xml/project/10"> XML文件要么以.开头 <?xml version="1.0" encoding="utf-8"?> <KNX xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" CreatedBy="ETS4" ToolVersion="ETS 4.0.3 (Build 3250)" xmlns="http://knx.org/xml/project/11"> 要么 <?xml version="1.0"?> <KNX xmlns="http://knx.org/xml/project/10" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" CreatedBy="ETS4" ToolVersion="4.0.1387.12605"> Here是完整的XSL文件. 有谁能够帮我? 谢谢 UPDATE <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:b10="http://knx.org/xml/project/10" xmlns:b="http://knx.org/xml/project/11" > <xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/> <xsl:template match="/"> <xsl:for-each select="b:KNX/b:Project/b:Installations/b:Installation/b:Topology"> <datapoints> <xsl:for-each select="b:Area/b:Line/b:DeviceInstance/b:ComObjectInstanceRefs/b:ComObjectInstanceRef"> <xsl:sort select="b:Connectors/b:Send/@GroupAddressRefId"/> <xsl:if test="not(preceding::b:Connectors/b:Send/@GroupAddressRefId = current()/b:Connectors/b:Send/@GroupAddressRefId)"> <xsl:for-each select="b:Connectors"> <xsl:variable name="verz" select="document(concat(substring(../@RefId,7),'/',substring-before(../@RefId,'_O'),'.xml'))/b:KNX/b:ManufacturerData/b:Manufacturer/b:ApplicationPrograms/b:ApplicationProgram/b:Static/b:ComObjectTable/b:ComObject[@Id = ../../b:ComObjectRefs/b:ComObjectRef[@Id = current()/../@RefId]/@RefId]" /> <xsl:variable name="grosse"> 是否有可能定义 b: = b: | b10: 这样我就不必更改完整的文件了 解决方法
我认为你在寻找的是:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:b10="http://knx.org/xml/project/10" xmlns:b11="http://knx.org/xml/project/11"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="b10:MyElement|b11:Element"> <!-- Template code... --> </xsl:template> </xsl:stylesheet> 虽然因为你匹配根元素,并且你一次只转换一个XML文档,但我没有看到问题,因为/在任何情况下都会匹配根元素. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |