2016-05-07 1 views
0

Saxon XSLT 2.0シンプルトランスフォーム(Exchanger XMLエディタを使用)を使用して、XMLファイルとXSLドキュメントからHTMLファイルを生成しようとしていますが、拾った。私は自分のXSLスタイルシートにエラーがあると想定していますが、どこにいるのかわかりません。XSLT 2.0変換で適切なhtml文書が生成されない

私はここでhttps://drive.google.com/open?id=0B9o30hEqwvyDSjRsbWlZVUpyNzA

は私のXSLスタイルシート(である...ここでは完全なHTML文書を作成するために必要なすべての4つのファイル(1つのXSL、1つのXML、1つのCSS、および1 PNG)をアップロードしています使用<xsl:for-each-group select="//employee" group-by="gender">はスタートのために、...上記のリンクに含まれる1)と同じである

<?xml version="1.0" encoding="UTF-8" ?> 


<xsl:stylesheet version="2.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 

    <xsl:output method="html" 
     doctype-system="about:legacy-compat" 
     encoding="UTF-8" 
     indent="yes" /> 

    <xsl:template match="/"> 
     <html> 
     <head> 
      <title>Employment Report</title> 
      <link href="horizons.css" rel="stylesheet" type="text/css" /> 
     </head> 

     <body> 
      <div id="wrap"> 
       <header> 
        <img src="horizons.png" alt="Horizons TechNet" /> 
       </header> 

       <h1>Employment Report</h1> 
       <xsl:for-each-group select="employee" group-by="gender"> 

        <table id="summary"> 
         <tr> 
          <th>Gender</th> 
          <td> 
           <xsl:value-of select="current-grouping-key()" /> 
          </td> 
         </tr> 
         <tr> 
          <th>Employees</th> 
          <td> 
           <xsl:value-of select="count(current-group())" /> 
          </td> 
         </tr> 
         <tr> 
          <th>Average Compensation</th> 
          <td> 
           <xsl:value-of select="avg(current-group()//salary+bonus+commission)"/> 
          </td> 
         </tr> 
        </table> 


        <table id="emptable"> 
         <tr> 
          <th>ID</th> 
          <th>Department</th> 
          <th>Education Level</th> 
          <th>Total Compensation</th> 
         </tr> 

        <xsl:apply-templates select="employee"> 
         <xsl:sort select="sum(salary+bonus+commission)" order="descending" data-type="number" /> 
        </xsl:apply-templates> 

        </table> 

       </xsl:for-each-group> 

      </div> 
     </body> 

     </html> 
    </xsl:template> 

<xsl:template name="employee"> 
    <tr> 
     <td><xsl:value-of select="@empID" /></td> 
     <td><xsl:value-of select="department" /></td> 
     <td><xsl:value-of select="title" /></td> 
     <td><xsl:value-of select="edLevel" /></td> 
     <td><xsl:value-of select="sum(salary+bonus+commission)" /></td> 
    </tr> 
</xsl:template> 


</xsl:stylesheet> 

答えて

1

。そして、私はまたあなたの代わりに、最後のテンプレートに、あなたは+を使用して、sumいくつかの場所でmatch属性のnameを持っているあなたの代わりに<xsl:apply-templates select="employee">

<xsl:apply-templates select="current-group()">をしたいと思い、私はあなたがどちらかsumまたは+を使用してアイテムを合計したいと思います両方ともではありません。

<?xml version="1.0" encoding="UTF-8" ?> 



<xsl:stylesheet version="2.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 

    <xsl:output method="html" 
     doctype-system="about:legacy-compat" 
     encoding="UTF-8" 
     indent="yes" /> 

    <xsl:template match="/"> 
     <html> 
      <head> 
       <title>Employment Report</title> 
       <link href="horizons.css" rel="stylesheet" type="text/css" /> 
      </head> 

      <body> 
       <div id="wrap"> 
        <header> 
         <img src="horizons.png" alt="Horizons TechNet" /> 
        </header> 

        <h1>Employment Report</h1> 
        <xsl:for-each-group select="//employee" group-by="gender"> 

         <table id="summary"> 
          <tr> 
           <th>Gender</th> 
           <td> 
            <xsl:value-of select="current-grouping-key()" /> 
           </td> 
          </tr> 
          <tr> 
           <th>Employees</th> 
           <td> 
            <xsl:value-of select="count(current-group())" /> 
           </td> 
          </tr> 
          <tr> 
           <th>Average Compensation</th> 
           <td> 
            <xsl:value-of select="avg(current-group()/sum(salary | bonus |commission))"/> 
           </td> 
          </tr> 
         </table> 


         <table id="emptable"> 
          <tr> 
           <th>ID</th> 
           <th>Department</th> 
           <th>Education Level</th> 
           <th>Total Compensation</th> 
          </tr> 

          <xsl:apply-templates select="current-group()"> 
           <xsl:sort select="sum(salary | bonus | commission)" order="descending"/> 
          </xsl:apply-templates> 

         </table> 

        </xsl:for-each-group> 

       </div> 
      </body> 

     </html> 
    </xsl:template> 

    <xsl:template match="employee"> 
     <tr> 
      <td><xsl:value-of select="@empID" /></td> 
      <td><xsl:value-of select="department" /></td> 
      <td><xsl:value-of select="title" /></td> 
      <td><xsl:value-of select="edLevel" /></td> 
      <td><xsl:value-of select="sum(salary | bonus | commission)" /></td> 
     </tr> 
    </xsl:template> 


</xsl:stylesheet> 
+0

これはちょっと助けてくれました。ありがとうございます。ほとんどの文書はまだ表示されていません。 – codeRed

+0

xmlのすべての情報を表示しますが、htmlでフォーマットされていません。また、xslが検索しようとしているものではなく、各従業員のすべての情報でした。 – codeRed

+0

@codeRed、私はいくつかの修正を加えて、私が今デスクトップにいて、自分の携帯電話を投稿しなくても、完全なスタイルシートを投稿しました。 –

関連する問題