【发布时间】:2017-08-01 15:24:13
【问题描述】:
我必须转换 xml2xml。我有一个 XSLT 文件,可以很好地与其他 XML 文件配合使用,我将其调整为后续文件(只是一个测试文件):
<?xml version="1.0" encoding="UTF-8"?>
<invoice:request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:invoice="http://www.xmlData.ch/xmlInvoice/XSD"
xsi:schemaLocation="http://www.xmlData.ch/xmlInvoice/XSD
MDInvoiceRequest_400.xsd" role="production">
<invoice:prolog>
<invoice:package>Handy patients</invoice:package>
<invoice:software>Handy patients</invoice:software>
<invoice:validator>tarmedValidator100 ATL Module Copyright © by Suva & santésuisse</invoice:validator>
</invoice:prolog>
<invoice:invoice invoice_id="23">
<invoice:balance>
<invoice:vat>0.00</invoice:vat>
</invoice:balance>
<invoice:detail>
<invoice:services>
<invoice:record_tarmed>Prestation médicale en l'absence du patient (y compris étude de dossier), par période de 5 min
</invoice:record_tarmed>
<invoice:record_tarmed>Rapport médical sur formulaire assurance-maladie, {AA}, {AM}/Rapport intermédiaire/Feuille annexe sur formulaire {AI}
</invoice:record_tarmed>
</invoice:services>
</invoice:detail>
</invoice:invoice>
然后是 XSLT 文件:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="invoice:request">
<xsl:copy>
<xsl:for-each-group select="invoice:invoice " group-by="@invoice_id">
<xsl:element name="Facture">
<xsl:for-each select="current-group()">
<xsl:element name="Package">
<xsl:value-of select="../invoice:prolog/invoice:package"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
我有一个警告:Impossible de Transformer:第 13 行第 28 列错误:未定义 value-of 上的命名空间前缀 xsl
我能做什么?
【问题讨论】:
-
您的样式表被标记为
version="1.0"但xsl:for-each-group需要 XSLT 2.0。你的处理器支持吗? -
感谢您的建议。我做了这两个更改,但结果是一样的。我还能做什么?
-
1. 结果不相同。由于
invoice:前缀未声明,您应该会看到不同的错误消息。 -- 2. 您没有回答我的问题:您的处理器是否支持 XSLT 2.0?更改样式表上的版本与此无关。 -
好的。我用撒克逊人测试过,我有这些错误:
-
好的。我已经用 saxon 进行了测试,但出现了以下错误: XPST0081:尚未声明命名空间前缀“发票” XPST0090:元素
上不允许使用属性@name,但在 xml 文件中使用了发票前缀?请问,我该怎么办?