未定义value-of上的命名空间前缀xsl

时间:2017-08-01 15:24:14

标签: xml xslt

我必须转换xml2xml。我有一个适用于其他XML文件的XSLT文件,我将其调整为后续文件(只是一个测试文件):

<?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 &amp; 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>

我有一个警告:不可能变换器:第13行错误,第28列:未定义值-of上的命名空间前缀xsl

我该怎么办?

1 个答案:

答案 0 :(得分:0)

首先改变这个:

xmlns:xsl="http://www.w3.org/2001/XMLSchema-instance"

为:

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

但是你还有许多其他问题需要进行修正。