在几篇帖子的帮助下,我一直在组建一个XSLT,最后让它发挥作用。我现在发现处理器只兼容XSLT1.0,这意味着我的XSLT无法工作,因为它在模板的选择中包含匹配函数。
我尝试重新创建它有一些尝试,但实际上没有太多运气用1.0语法替换此部分。我要么以错误的循环结束,要么以错误的方式结束。
<xsl:for-each select="../../../*[matches(name(),'^vco_.*')]/text()">
<xsl:value-of select="concat(.,'-')"/>
</xsl:for-each>
我想我可能不得不做类似以下的事情(这不起作用)或者使用一个函数但是看不到任何正确的东西。
<xsl:for-each select="/exchange/vco/vco.srs/vco_crsc.vco.srs">
<xsl:value-of select=" ancestor-or-self::node()"/>
<xsl:value-of select="concat(.,'-')"/>
</xsl:for-each>
现在的代码和输出跟随
中的XML
<?xml version="1.0" encoding="UTF-8" ?>
<exchange>
<vco>
<vco.srs>
<vco_crsc.vco.srs>BUUBIF</vco_crsc.vco.srs>
<vco_prgc.vco.srs>BUBSBAT02</vco_prgc.vco.srs>
<vco_rouc.vco.srs>USBIFI</vco_rouc.vco.srs>
<cbo>
<cbo.srs>
<cbo_occl.cbo.srs>AJ</cbo_occl.cbo.srs>
<crs>
<crs.srs>
<crs_titl.crs.srs>BSc Banking & Int Finance</crs_titl.crs.srs>
<crs_dptc.crs.srs>B</crs_dptc.crs.srs>
<crs_begd.crs.srs>2003-08-01</crs_begd.crs.srs>
</crs.srs>
</crs>
</cbo.srs>
<cbo.srs>
<cbo_occl.cbo.srs>AJ</cbo_occl.cbo.srs>
<crs>
<crs.srs>
<crs_titl.crs.srs>BSc Banking & Int Finance</crs_titl.crs.srs>
<crs_dptc.crs.srs>B</crs_dptc.crs.srs>
<crs_begd.crs.srs>2003-08-01</crs_begd.crs.srs>
</crs.srs>
</crs>
</cbo.srs>
<cbo.srs>
<cbo_occl.cbo.srs>AJ</cbo_occl.cbo.srs>
<crs>
<crs.srs>
<crs_titl.crs.srs>BSc Banking & Int Finance</crs_titl.crs.srs>
<crs_dptc.crs.srs>B</crs_dptc.crs.srs>
<crs_begd.crs.srs>2003-08-01</crs_begd.crs.srs>
</crs.srs>
</crs>
</cbo.srs>
<cbo.srs>
<cbo_occl.cbo.srs>AJ</cbo_occl.cbo.srs>
<crs>
<crs.srs>
<crs_titl.crs.srs>BSc Banking & Int Finance</crs_titl.crs.srs>
<crs_dptc.crs.srs>B</crs_dptc.crs.srs>
<crs_begd.crs.srs>2003-08-01</crs_begd.crs.srs>
</crs.srs>
</crs>
</cbo.srs>
<cbo.srs>
<cbo_occl.cbo.srs>FJ</cbo_occl.cbo.srs>
<crs>
<crs.srs>
<crs_titl.crs.srs>BSc Banking & Int Finance</crs_titl.crs.srs>
<crs_dptc.crs.srs>B</crs_dptc.crs.srs>
<crs_begd.crs.srs>2003-08-01</crs_begd.crs.srs>
</crs.srs>
</crs>
</cbo.srs>
<cbo.srs>
<cbo_occl.cbo.srs>AJ</cbo_occl.cbo.srs>
<crs>
<crs.srs>
<crs_titl.crs.srs>BSc Banking & Int Finance</crs_titl.crs.srs>
<crs_dptc.crs.srs>B</crs_dptc.crs.srs>
<crs_begd.crs.srs>2003-08-01</crs_begd.crs.srs>
</crs.srs>
</crs>
</cbo.srs>
<cbo.srs>
<cbo_occl.cbo.srs>FJ</cbo_occl.cbo.srs>
<crs>
<crs.srs>
<crs_titl.crs.srs>BSc Banking & Int Finance</crs_titl.crs.srs>
<crs_dptc.crs.srs>B</crs_dptc.crs.srs>
<crs_begd.crs.srs>2003-08-01</crs_begd.crs.srs>
</crs.srs>
</crs>
</cbo.srs>
</cbo>
</vco.srs>
<vco.srs>
<vco_crsc.vco.srs>BUUBIF</vco_crsc.vco.srs>
<vco_prgc.vco.srs>BUBSBAT02</vco_prgc.vco.srs>
<vco_rouc.vco.srs>USBIFA</vco_rouc.vco.srs>
<cbo>
<cbo.srs>
<cbo_occl.cbo.srs>AJ</cbo_occl.cbo.srs>
<crs>
<crs.srs>
<crs_titl.crs.srs>BSc Banking & Int Finance</crs_titl.crs.srs>
<crs_dptc.crs.srs>B</crs_dptc.crs.srs>
<crs_begd.crs.srs>2003-08-01</crs_begd.crs.srs>
</crs.srs>
</crs>
</cbo.srs>
<cbo.srs>
<cbo_occl.cbo.srs>AJ</cbo_occl.cbo.srs>
<crs>
<crs.srs>
<crs_titl.crs.srs>BSc Banking & Int Finance</crs_titl.crs.srs>
<crs_dptc.crs.srs>B</crs_dptc.crs.srs>
<crs_begd.crs.srs>2003-08-01</crs_begd.crs.srs>
</crs.srs>
</crs>
</cbo.srs>
<cbo.srs>
<cbo_occl.cbo.srs>AJ</cbo_occl.cbo.srs>
<crs>
<crs.srs>
<crs_titl.crs.srs>BSc Banking & Int Finance</crs_titl.crs.srs>
<crs_dptc.crs.srs>B</crs_dptc.crs.srs>
<crs_begd.crs.srs>2003-08-01</crs_begd.crs.srs>
</crs.srs>
</crs>
</cbo.srs>
<cbo.srs>
<cbo_occl.cbo.srs>AJ</cbo_occl.cbo.srs>
<crs>
<crs.srs>
<crs_titl.crs.srs>BSc Banking & Int Finance</crs_titl.crs.srs>
<crs_dptc.crs.srs>B</crs_dptc.crs.srs>
<crs_begd.crs.srs>2003-08-01</crs_begd.crs.srs>
</crs.srs>
</crs>
</cbo.srs>
<cbo.srs>
<cbo_occl.cbo.srs>FJ</cbo_occl.cbo.srs>
<crs>
<crs.srs>
<crs_titl.crs.srs>BSc Banking & Int Finance</crs_titl.crs.srs>
<crs_dptc.crs.srs>B</crs_dptc.crs.srs>
<crs_begd.crs.srs>2003-08-01</crs_begd.crs.srs>
</crs.srs>
</crs>
</cbo.srs>
<cbo.srs>
<cbo_occl.cbo.srs>AJ</cbo_occl.cbo.srs>
<crs>
<crs.srs>
<crs_titl.crs.srs>BSc Banking & Int Finance</crs_titl.crs.srs>
<crs_dptc.crs.srs>B</crs_dptc.crs.srs>
<crs_begd.crs.srs>2003-08-01</crs_begd.crs.srs>
</crs.srs>
</crs>
</cbo.srs>
<cbo.srs>
<cbo_occl.cbo.srs>FJ</cbo_occl.cbo.srs>
<crs>
<crs.srs>
<crs_titl.crs.srs>BSc Banking & Int Finance</crs_titl.crs.srs>
<crs_dptc.crs.srs>B</crs_dptc.crs.srs>
<crs_begd.crs.srs>2003-08-01</crs_begd.crs.srs>
</crs.srs>
</crs>
</cbo.srs>
</cbo>
</vco.srs>
</vco>
</exchange>
我的XSL 2.0模板,它做了我想要的:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes" method="xml"/>
<xsl:template match="/exchange">
<ImportTask xlns="http://inplace.quantumit.com.au/import/version_1_0/" xmlns:i="http://www.w3.org/2001/XMLSchema">
<CourseVersions>
<xsl:for-each select="/exchange/vco/vco.srs">
<CourseVersion>
<xsl:apply-templates select="//cbo_occl.cbo.srs | //crs/crs.srs"/>
</CourseVersion>
</xsl:for-each>
</CourseVersions>
</ImportTask>
</xsl:template>
<xsl:template match="cbo_occl.cbo.srs">
<CourseCode>
<!-- select all text-Nodes of vco_* elements -->
<xsl:for-each select="../../../*[matches(name(),'^vco_.*')]/text()">
<xsl:value-of select="concat(.,'-')"/>
</xsl:for-each>
<xsl:value-of select="."/>
</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
</xsl:template>
<xsl:template match="crs/crs.srs">
<xsl:for-each select="exchange/crs/crs.srs">
</xsl:for-each>
<StartDate><xsl:value-of select="crs_begd.crs.srs"/></StartDate>
<Description><xsl:value-of select="crs_titl.crs.srs"/></Description>
<FacultyCode><xsl:value-of select="crs_dptc.crs.srs"/></FacultyCode>
</xsl:template>
</xsl:stylesheet>
我想要的输出
<?xml version="1.0" encoding="UTF-8"?>
<ImportTask xmlns:i="http://www.w3.org/2001/XMLSchema"
xlns="http://inplace.quantumit.com.au/import/version_1_0/">
<CourseVersions>
<CourseVersion>
<CourseCode>BUUBIF-BUBSBAT02-USBIFI-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFI-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFI-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFI-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFI-FJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFI-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFI-FJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFA-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFA-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFA-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFA-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFA-FJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFA-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFA-FJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
</CourseVersion>
<CourseVersion>
<CourseCode>BUUBIF-BUBSBAT02-USBIFI-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFI-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFI-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFI-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFI-FJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFI-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFI-FJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFA-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFA-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFA-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFA-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFA-FJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFA-AJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
<CourseCode>BUUBIF-BUBSBAT02-USBIFA-FJ</CourseCode>
<Version>1</Version>
<EndDate>i:nil="true"</EndDate>
<PrimaryDisciplineCode>i:nil="true"</PrimaryDisciplineCode>
<StartDate>2003-08-01</StartDate>
<Description>BSc Banking & Int Finance</Description>
<FacultyCode>B</FacultyCode>
</CourseVersion>
</CourseVersions>
</ImportTask>
非常感谢
约拿
答案 0 :(得分:1)
如果你需要做的就是检查一个固定的前缀,那么你可以使用starts-with
代替matches
:
<xsl:for-each select="../../../*[starts-with(name(),'vco_')]/text()">