0

我尝试使用分析字符串,但在 Firefox 中我得到了一些错误

“firefox XSLT 转换期间发生错误:XSLT 转换失败。”

源文件 XML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE XML><?xml-stylesheet type="text/xsl" href="file:///home/dariusz/Dokumenty/speedup/szablo_makro/style.xsl"?>
 <positions>
  <position>
   <name>item name</name>
   <pkwiu>some symbol</pkwiu>
   <id>1</id>
   <quantity>4</quantity>
   <unit>szt.</unit>
   <netto>100</netto>
   <brutto>123</brutto>
   <bonus>0,00</bonus>
   <netto_after_bonus>100</netto_after_bonus>
   <netto_sum>400</netto_sum>
   <vatrate>23%</vatrate>
   <vat>92</vat>
   <gross_sum>492</gross_sum>
   <val_bonus>0,00</val_bonus>
   <producer_pn>1117</producer_pn>
   <producer>1111113</producer>
   <notes></notes>
   <barcode>444444444444</barcode>
   <code>code name</code>
   <pos_currency>PLN</pos_currency>
   <loan_gross>0,00</loan_gross>
   <loan_netto>0,00</loan_netto>
   <loan_vat>0,00</loan_vat>
   <diff_loan_gross>492</diff_loan_gross>
   <diff_loan_netto>400,00</diff_loan_netto>
   <diff_loan_vat>92</diff_loan_vat>
   <add_ware_cols_str>Nr first: 543 ., Nr. second: 2201 szt., Nr.third: 18987 szt., Waga brutto: 0,21 kg., ilość w opak. zbiorczym.: 2 szt., </add_ware_cols_str>
  </position>
 </positions>

XSL 的来源:

<?xml version="1.0" encoding="ISO-8859-2"?>
<!-- Edited with XML Spy v4.2 -->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
  <style type="text/css">
  .duzy {font-family: tahoma, helvetica; font-size:12px;}
  </style>
  <body bgcolor="white" style="font-family: tahoma; font-size:10px;">
   <table style="border-width: 0px; border-style:solid;font-size:10px;" width="100%" cellspacing="1" cellpadding="1" bgcolor="black">
      <tr bgcolor="white">
        <th align="center" width="5%">Lp.</th>

        <th align="center" width="28%">Nazwa</th>
        <th align="center" width="7%">Nr. art. FIRST</th>   
        <th align="center" width="7%">EAN</th>  
        <th align="center" width="10%">PKWIU</th>   
        <th align="center" width="6%">Ilość</th>
        <th align="center" width="5%">J.m.</th> 
        <th align="center" width="8%">Cena NETTO</th>       
        <th align="center" width="8%">Wartość NETTO</th>            
        <th align="center" width="5%">Stawka VAT</th>           
    <th align="center" width="8%">Kwota VAT</th>            
        <th align="center" width="8%">Wartość BRUTTO</th>               
      </tr>
      <xsl:for-each select="positions/position">
      <tr bgcolor="white">
        <td align="right"><xsl:value-of select="id"/></td>
        <td align="left"><xsl:value-of select="name"/> </td>
        <td align="center">
         <xsl:variable name="warcol" select="add_ware_cols_str"/>

     <xsl:analyze-string select="$warcol" regex="first: \d+">
        <xsl:matching-substring>
          <xsl:value-of select="."/>
        </xsl:matching-substring>
        <xsl:non-matching-substring>

        </xsl:non-matching-substring>
      </xsl:analyze-string>


</td>

        <td align="center"><xsl:value-of select="barcode"/></td>
        <td align="center"><xsl:value-of select="pkwiu"/></td>      
        <td align="center" ><xsl:value-of select="quantity"/></td>
        <td align="center"><xsl:value-of select="unit"/></td>           
        <td align="right" ><xsl:value-of select="netto"/></td>      
        <td align="right" ><xsl:value-of select="netto_sum"/></td>      
        <td align="center"><xsl:value-of select="vatrate"/></td>        
        <td align="right" ><xsl:value-of select="vat"/></td>        
        <td align="right" ><xsl:value-of select="gross_sum"/></td>      
      </tr>
      </xsl:for-each>
    </table><br/>
</body>
  </html>
</xsl:template>
</xsl:stylesheet>

但是当我使用 Editix XML Editor-11.0 时生成的 htm 文件是正确的。请帮忙。

达里奥

4

1 回答 1

1

所有浏览器中的本机 XSLT 处理器仅支持 XSLT 1.0,它不包括 xsl:analyze-string 指令(或任何其他正则表达式支持)。要在浏览器中运行 XSLT 2.0,可以使用 Saxon-CE。

于 2013-09-06T07:24:23.167 回答