2016-05-16 4 views
1

私たちはSSRSからXSLT/HTMLへのいくつかのレポートの移動に取り組んでいますが、私は以下のことを正しく行う方法に固執しています。基本的には<itemid><location>がたくさんありますが、どのようにループするのか分かりません。これをHTML/XSLTで行う方法は?

<CombinedResults> 
    <Results> 
     <Result> 
      <itemid> GAC Test 2</itemid> 
      <displayname> GAC Test 2</displayname> 
      <salesdescription/> 
      <inventorylocation>4</inventorylocation> 
      <locationquantityavailable>10</locationquantityavailable> 
      <locationquantitybackordered/> 
     </Result> 
     <Result> 
      <itemid> GAC Test 2</itemid> 
      <displayname> GAC Test 2</displayname> 
      <salesdescription/> 
      <inventorylocation>2</inventorylocation> 
      <locationquantityavailable>180</locationquantityavailable> 
      <locationquantitybackordered/> 
     </Result> 
    </Results> 
</CombinedResults> 

私のXSLTは、以下のように見えますが、唯一のではなく、すべての場所のための項目を示す、1つの項目と1場所を示しています:

<xsl:template match="/CombinedResults"> 
    <html> 
     <head> 
     <link rel="stylesheet" type="text/css" href="SOMESTYLESHEET"/> 
     </head> 
     <body> 
    <table> 
     <tr> 
     <th>Item ID</th> 
     <th>Location Available</th> 
     </tr> 
     <tr> 
     <td><xsl:value-of select="Results/Result/itemid"/></td> 
     <td><xsl:value-of select="Results/Result/inventorylocation"/></td> 
     </tr> 
    </table> 
     </body> 
    </html> 
    </xsl:template> 

私もしましたが、私のXML結果は以下のようになります私は近くにいると思ったが、うまくいかないと思った。

<xsl:template match="/CombinedResults"> 
    <html> 
     <head> 
     <!-- URL must have ampersands replaced with &amp; --> 
     <link rel="stylesheet" type="text/css" href="SOMECSS"/> 
     </head> 
     <body> 
    <table> 
     <tr> 
     <th>Item ID</th> 
     <th>Location Available</th> 
     </tr> 
     <tr> 
     <!-- 
     <td><xsl:value-of select="Results/Result/itemid"/></td> 
     <td><xsl:value-of select="Results/Result/inventorylocation"/></td> 
     --> 
     <xsl:for-each select="Results/Result/"> 
      <td><xsl:value-of select="itemid"/></td> 
     </xsl:for-each> 
     </tr> 
    </table> 
     </body> 
    </html> 
    </xsl:template> 

何か助けてくれれば大歓迎です!

+1

あなたのXMLには、 ''タグはありません... XMLとXSLTが実際に一致するようにしてください –

+0

また、_desired_出力を表示してください –

答えて

2

あなたの正確な要件は少し曖昧ですが、ここで私はあなたが必要とするものを推測します。出力された

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    version="2.0"> 
    <xsl:output method="html" indent="yes"/> 
    <xsl:template match="/CombinedResults"> 
     <html> 
      <head> 
       <link rel="stylesheet" type="text/css" href="SOMESTYLESHEET"/> 
      </head> 
      <body> 
       <table> 
        <tr> 
         <th>Item ID</th> 
         <th>Location Available</th> 
        </tr> 
       </table> 
       <xsl:apply-templates select=".//Result"/> 
      </body> 
     </html> 
    </xsl:template> 

    <xsl:template match="Result"> 
     <tr> 
      <td><xsl:value-of select="itemid"/></td> 
      <td><xsl:value-of select="inventorylocation"/></td> 
     </tr> 
    </xsl:template> 
</xsl:stylesheet> 

:この入力を想定し

<?xml version="1.0" encoding="UTF-8"?> 
<CombinedResults> 
    <Results> 
     <Result> 
      <itemid> GAC Test 2</itemid> 
      <displayname> GAC Test 2</displayname> 
      <salesdescription/> 
      <inventorylocation>4</inventorylocation> 
      <locationquantityavailable>10</locationquantityavailable> 
      <locationquantitybackordered/> 
     </Result> 
     <Result> 
      <itemid> GAC Test 2</itemid> 
      <displayname> GAC Test 2</displayname> 
      <salesdescription/> 
      <inventorylocation>2</inventorylocation> 
      <locationquantityavailable>180</locationquantityavailable> 
      <locationquantitybackordered/> 
     </Result> 
    </Results> 
</CombinedResults> 

そしてこのXSLT

<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <link rel="stylesheet" type="text/css" href="SOMESTYLESHEET"> 
    </head> 
    <body> 
     <table> 
     <tr> 
      <th>Item ID</th> 
      <th>Location Available</th> 
     </tr> 
     </table> 
     <tr> 
     <td> GAC Test 2</td> 
     <td>4</td> 
     </tr> 
     <tr> 
     <td> GAC Test 2</td> 
     <td>2</td> 
     </tr> 
    </body> 
</html> 
関連する問題