2016-08-12 4 views
-1

以下のXMLの列と行が複数ある表を生成するXSLT 1.0スタイルシートがあります。私が探しています所望の出力は、列のグループのためのネストされた親列を作成することで、3列(「PromotionInd」、「BrkChgID」、「BrkChgAmtは」)する必要があり、私のXMLに言うことができます下の図に示すように、親列「ブローカー」の下にネストする必要があります。 Desired nested columns layout pictureXSL FOの特定の列グループのネストされた列を動的に生成する方法

以下は私のXMLとXSLTです。あなたはこれを達成するように私を導くことができますか?

XMLデータ

 <PdfPrinter> 
    <Reports> 
    <Report> 
    <BatchDate>2016-08-10T00:00:00</BatchDate> 
    <ClientAccountNo>ABCDE01384</ClientAccountNo> 
    <Source>N</Source> 
    <CDSNo>0000001387</CDSNo> 
    <Price>0.123000</Price> 
    <Qty>-1200</Qty> 
    <TCurrency>USD</TCurrency> 
    <TNettAmt>0</TNettAmt> 
    <LCurrency>USD</LCurrency> 
    <LNettAmt>-86.600000</LNettAmt> 
    <PromotionInd>N</PromotionInd> 
    <BrkChgID>BRK-N</BrkChgID> 
    <BrkChgAmt>50.000000</BrkChgAmt> 
    <ClrChgID>CLR</ClrChgID> 
    <ClrChgAmt>10.000000</ClrChgAmt> 
    <SdcChgID>SDC</SdcChgID> 
    <SdcChgAmt>1.000000</SdcChgAmt> 
    <BinChgID /> 
    <BinChgAmt>0</BinChgAmt> 
    <OthChgAmt>0.000000</OthChgAmt> 
    <TaxAmt>0.000000</TaxAmt> 
    </Report> 
    <Report> 
    <BatchDate>2016-08-10T00:00:00</BatchDate> 
    <ClientAccountNo /> 
    <Source>N</Source> 
    <CDSNo /> 
    <Price>0.123000</Price> 
    <Qty>1200</Qty> 
    <TCurrency>USD</TCurrency> 
    <TNettAmt>0</TNettAmt> 
    <LCurrency>USD</LCurrency> 
    <LNettAmt>147.600000</LNettAmt> 
    <PromotionInd>N</PromotionInd> 
    <BrkChgID /> 
    <BrkChgAmt>0</BrkChgAmt> 
    <ClrChgID /> 
    <ClrChgAmt>0</ClrChgAmt> 
    <SdcChgID /> 
    <SdcChgAmt>0</SdcChgAmt> 
    <BinChgID /> 
    <BinChgAmt>0</BinChgAmt> 
    <OthChgAmt>0</OthChgAmt> 
    <TaxAmt>0</TaxAmt> 
    </Report> 
    <Report> 
    <BatchDate>2016-08-10T00:00:00</BatchDate> 
    <ClientAccountNo>ABCDE00003</ClientAccountNo> 
    <Source>N</Source> 
    <CDSNo>0000000003</CDSNo> 
    <Price>1.589000</Price> 
    <Qty>-2000</Qty> 
    <TCurrency>USD</TCurrency> 
    <TNettAmt>0</TNettAmt> 
    <LCurrency>USD</LCurrency> 
    <LNettAmt>-3114.820000</LNettAmt> 
    <PromotionInd>N</PromotionInd> 
    <BrkChgID>BRK-N</BrkChgID> 
    <BrkChgAmt>50.000000</BrkChgAmt> 
    <ClrChgID>CLR</ClrChgID> 
    <ClrChgAmt>10.000000</ClrChgAmt> 
    <SdcChgID>SDC</SdcChgID> 
    <SdcChgAmt>3.180000</SdcChgAmt> 
    <BinChgID /> 
    <BinChgAmt>0</BinChgAmt> 
    <OthChgAmt>0.000000</OthChgAmt> 
    <TaxAmt>0.000000</TaxAmt> 
    </Report> 
    </Reports> 
    </PdfPrinter> 

EDIT:完全なXSLT 1.0テンプレート

 <xsl:stylesheet 
     version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
     xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
     xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     xmlns:ext="http://exslt.org/common" 
     xmlns:utilityExtension="pdfprinter:extensions:utility" 
     exclude-result-prefixes="msxsl utilityExtension"> 
     <xsl:output method="xml" indent="yes" 
     omit-xml-declaration="yes" encoding="utf-8"/> 

    <xsl:template match="/"> 
    <xsl:variable name="PromotionInd" select="/PdfPrinter/ 
     Reports/Report/PromotionInd" /> 
    <xsl:variable name="ClrChgID" 
    select="/PdfPrinter/Reports/Report/ClrChgID"/> 

<xsl:variable name="Brokerage">Brokerage</xsl:variable> 
<xsl:variable name="ClearingFee">Clearing Fee</xsl:variable> 
<xsl:variable name="columnFontSize">12pt</xsl:variable> 
<xsl:variable name="columnFontType">Helvetica</xsl:variable> 
<xsl:variable name="headerOrgName">Pavan</xsl:variable> 
<xsl:variable name="headerPrintedBy">Printed By</xsl:variable> 
<xsl:variable name="headerPrintedDate">Printed Date</xsl:variable> 
<xsl:variable name="headerReportID">Report ID</xsl:variable> 

<xsl:variable name="headerLogo" select=" 
utilityExtension:MapPath('~/App_Data/Resources/IMAGES/logo.jpg')"/> 

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> 
    <!-- defines the layout master --> 
    <fo:layout-master-set> 
    <fo:simple-page-master master-name="all-pages" page-width="894mm" page-height="1300pt" margin-top="10mm" margin-left="20mm" margin-right="20mm" margin-bottom="10mm"> 
     <fo:region-body region-name="xsl-region-body" column-gap="0in" margin="0.8in" margin-left="0.7in" margin-top="2.3in" margin-bottom="1.8in" padding-top="0in"/> 
     <fo:region-before region-name="xsl-region-before" extent="75mm" /> 
     <fo:region-after region-name="xsl-region-after" extent="7in"/> 
    </fo:simple-page-master> 
    <fo:page-sequence-master master-name="default-sequence"> 
     <fo:single-page-master-reference master-reference="all-pages"/> 
     <fo:repeatable-page-master-reference master-reference="all-pages" /> 
    </fo:page-sequence-master> 
    </fo:layout-master-set> 
    <!-- starts actual layout --> 
    <fo:page-sequence master-reference="default-sequence" initial-page-number="1" id="last-page"> 
    <fo:static-content flow-name="xsl-region-before" width="100%" border-top-style="solid" border-top-color="rgb(192,192,192)" padding-top="1pt"> 
     <fo:block> 
     <fo:table border-collapse="collapse" width="100%" table-layout="fixed" margin-top="-0.002in" padding-left="0.7in" margin-left="0in" border-spacing="5px" space-before.conditionality="retain" space-after.conditionality="retain" space-after="1em" space-before="1em"> 
      <fo:table-column column-width="proportional-column-width(55)" column-number="1"/> 
      <fo:table-column column-width="proportional-column-width(45)" column-number="2"/> 
      <fo:table-column column-width="proportional-column-width(45)" column-number="3"/> 
      <fo:table-column column-width="proportional-column-width(45)" column-number="4"/> 
      <fo:table-column column-width="proportional-column-width(45)" column-number="5"/> 
      <fo:table-body> 
      <fo:table-row> 
       <fo:table-cell width="50%" text-align="left" padding-left="2pt"> 
       <fo:block color="rgb(0,0,128)" font-size="16pt" font-weight="bold">&#160;</fo:block> 
       <fo:block color="rgb(0,0,128)" font-weight="bold"></fo:block> 
       <fo:block padding-left="0in"> 
        <fo:external-graphic src="{$headerLogo}"/>&#160;&#160;&#160;&#160; 
        <fo:block> 
        </fo:block> 
       </fo:block> 
       <fo:block color="rgb(0,0,128)" font-weight="bold">&#160;&#160;&#160;&#160;</fo:block> 
       <fo:block color="rgb(0,0,0)" font-weight="bold" font-family="{$columnFontType}" font-size="{$columnFontSize}"> 
        <xsl:value-of select="$headerReportID"/> : <xsl:value-of select="/PdfPrinter/Reports/Header/ReportID" /> 
       </fo:block> 
       </fo:table-cell> 
       <fo:table-cell></fo:table-cell> 
       <fo:table-cell></fo:table-cell> 
       <fo:table-cell></fo:table-cell> 
       <fo:table-cell width="100%" text-align="left"> 
       <fo:block>&#160;&#160;&#160;&#160;</fo:block> 
       <fo:block>&#160;&#160;&#160;&#160;</fo:block> 
       <fo:block>&#160;&#160;&#160;&#160;</fo:block> 
       <fo:block>&#160;&#160;&#160;&#160;</fo:block> 
       <fo:block>&#160;&#160;&#160;&#160;</fo:block> 
       <fo:block text-align="left"> 
        <fo:inline font-weight="bold" font-family="{$columnFontType}" font-size="{$columnFontSize}"> 
        Page <fo:page-number/> of <fo:page-number-citation ref-id="last-page"/> 
        </fo:inline> 
       </fo:block> 
       <fo:block text-align="left"> 
        <fo:inline font-weight="bold" font-family="{$columnFontType}" font-size="{$columnFontSize}"> 
        <xsl:value-of select="$headerPrintedBy"/> : <xsl:value-of select="$n"/> 
        </fo:inline> 
       </fo:block> 
       <fo:block text-align="left"> 
        <fo:inline font-weight="bold" font-family="{$columnFontType}" font-size="{$columnFontSize}"> 
        <xsl:value-of select="$headerPrintedDate"/> : <xsl:value-of select="/PdfPrinter/Reports/Header/PrintedDate" /> 
        </fo:inline> 
       </fo:block> 
       </fo:table-cell> 
      </fo:table-row> 
      </fo:table-body> 
     </fo:table> 
     <fo:block/> 
     </fo:block> 
     <fo:block text-align="center"> 
     <fo:table padding-left="0.7in" border-bottom-width="5pt" border-width="1pt" font-weight="bold" inline-progression-dimension="auto" width="100%"> 
      <fo:table-column column-number="1"/> 
      <fo:table-body> 
      <fo:table-row border-bottom-color="rgb(0,0,255)" display-align="before"> 
       <fo:table-cell border-bottom-width="3pt" border-bottom-style="solid" border-bottom-color="rgb(255,255,255)" padding="2pt" text-align="left"> 
       <fo:block text-align="center" font-size="13pt" font-weight="bold" font-family="Helvetica" border-bottom="10pt "></fo:block> 
       <fo:block> 
        <xsl:value-of select="/PdfPrinter/Reports/Header/ReportTitle" /> 
       </fo:block> 
       <fo:block border-bottom-width="8pt" text-align="center" background-color="black"/> 
       </fo:table-cell> 
      </fo:table-row> 
      </fo:table-body> 
     </fo:table> 
     </fo:block> 
    </fo:static-content> 
    <fo:flow flow-name="xsl-region-body"> 
     <fo:block text-align="center"> 
     <!-- table start --> 
     <fo:table role="html:table" table-layout="auto" inline-progression-dimension="auto" line-height="2.5" width="100%" border="0px" border-collapse="collapse" border-spacing="3px" border-style="outset hidden" space-before.conditionality="retain" space-after.conditionality="retain" space-after="1em" space-before="1em"> 
      <!--table header--> 
      <xsl:for-each select="/PdfPrinter/Reports/Report[1]/*"> 
      <fo:table-column column-width="proportional-column-width(4.77)" /> 
      </xsl:for-each> 
      <fo:table-header> 
      <fo:table-row height="auto" color="#FFFFFF" background-color="#A1A1A1" text-align="center" font-weight="bold" font-family="Helvetica" font-size="medium"> 
       <xsl:choose> 
       <xsl:when test="$PromotionInd"> 
        <fo:table-cell text-align="center"> 
        <fo:block font-size="13pt" font-family="Helvetica"> 
         <xsl:value-of select="$Brokerage"/> 
        </fo:block> 
        </fo:table-cell> 
       </xsl:when> 
       </xsl:choose> 
       <xsl:choose> 
       <xsl:when test="$ClrChgID"> 
        <fo:table-cell text-align="center"> 
        <fo:block font-size="13pt" font-family="Helvetica"> 
         <xsl:value-of select="$ClearingFee"/> 
        </fo:block> 
        </fo:table-cell> 
       </xsl:when> 
       </xsl:choose> 
      </fo:table-row> 
      <fo:table-row height="auto" color="#FFFFFF" background-color="#A1A1A1" text-align="center" font-weight="bold" font-family="Helvetica" font-size="medium"> 
       <xsl:for-each select="/PdfPrinter/Reports/Report[1]/*"> 
       <fo:table-cell text-align="center"> 
        <fo:block font-size="13pt" font-family="Helvetica"> 
        <xsl:value-of select="name()"/> 
        </fo:block> 
       </fo:table-cell> 
       </xsl:for-each> 
      </fo:table-row> 
      </fo:table-header> 
      <!--table body--> 
      <fo:table-body> 
      <xsl:for-each select="PdfPrinter/Reports/Report"> 
       <fo:table-row display-align="before"> 
       <xsl:for-each select="*"> 
        <fo:table-cell text-align="center" border-top-color="rgb(255, 255, 255)" border-top-style="solid" border-width="1pt" padding="2pt"> 
        <fo:block font-size="13pt" font-family="Helvetica"> 
         <xsl:value-of select="."/> 
        </fo:block> 
        </fo:table-cell> 
       </xsl:for-each> 
       </fo:table-row> 
      </xsl:for-each> 
      </fo:table-body> 
     </fo:table> 
     <!-- table end --> 
     </fo:block> 
     <fo:block id="last-page"/> 
    </fo:flow> 
    </fo:page-sequence> 
</fo:root> 

+0

最小限で**完全な**スタイルシート(私たちはそのままコピーして実行できます)を含む**再現可能な**例を投稿してください。参照:[mcve]。 –

+0

@ michael.hor257k:返信ありがとう、XMLデータを含む完全なXSLTを投稿させてください。探している出力はOP画像リンクにあります。親切にそれを参照してください。ありがとう! –

+0

"* XMLデータを含む完全なXSLTを投稿させてください*"問題を再現するために必要なものだけを投稿してください。 –

答えて

0

私は以下のロジックでこれを解決することができますよ。

 <fo:table-row height="auto" color="#FFFFFF" background-color="#A1A1A1" text-align="center" font-weight="bold" font-family="Helvetica" font-size="medium"> 
       <xsl:choose> 
       <xsl:when test="/PdfPrinter/Reports/Report[1]/*[local-name()='BrkChgID']"> 
        <fo:table-cell text-align="center" column-number="16" number-columns-spanned="3"> 
        <fo:block font-size="13pt" font-family="Helvetica"> 
         <xsl:value-of select="$Brokerage"/> 
        </fo:block> 
        </fo:table-cell> 
       </xsl:when> 
       </xsl:choose> 
      </fo:table-row> 
関連する問題