Search This Blog

Showing posts with label XSLT. Show all posts
Showing posts with label XSLT. Show all posts

Tuesday, December 11, 2012

Simple sflight XSLT transformation for HTML

 <?sap.transform simple?>  
 <!-- NOTE!! For XSLT reference check http://www.w3schools.com/xsl/default.asp -->  
 <tt:transform xmlns:tt="http://www.sap.com/transformation-templates" xmlns:ddic="http://www.sap.com/abapxml/types/dictionary" xmlns:def="http://www.sap.com/abapxml/types/defined" version="1.0">  
 <!-- <tt:root name="ROOT" type="?"/>-->  
  <tt:root name="GT_OUT" type="ddic:TY_FLIGHTS"/>  
  <tt:template>  
   <HTML>  
    <HEAD>  
     <style>  
       .col {  
          border-width: 1px;  
          padding: 7px;  
          border-style: solid;  
          border-color: #DDDDDD;  
          border-collapse:collapase;  
          }  
        .t2 {  
           border-width: 0px;  
          }  
      .space {  
          padding-bottom: 3em;  
          }  
    .myTable2  {  
           font-family: arial;  
           font-size:10pt;  
           width:100%;  
           border-style:solid;  
           border-width: 1px;  
           border-color: #424242;  
           border-collapse: collapse;  
          }  
    .myTable2 th.p {width:7%;color="red";}  
    .myTable2 th.m {width:24%;}  
    .myTable2 th.a {width:34%;}  
    .myTable2 th.k {width:13%;}  
    .myTable2 th.n {width:13%;}  
    .myTable2 th  
          { background-color:#A9D0F5;  
           padding:2px;  
           border:1px solid #424242;  
          }  
    .myTable2 td.p {width:7%;color="red";}  
    .myTable2 td.m {width:24%;}  
    .myTable2 td.a {width:34%;}  
    .myTable2 td.k {width:13%;}  
    .myTable2 td.n {width:13%;}  
    .myTable2 td  
          { padding:2px;  
           border:1px solid #424242;  
          }  
    .myTable2 tr {  
           border-style:solid;  
           border-width:1px;  
           border-color:#dee3ef;  
          }  
     </style>  
    </HEAD>  
    <BODY>  
     <img alt="Allergan" src="https://allergandirect.allergan.com:81/Document/images/image_agn.bmp" width="200"/>  
     <BR/>  
     <H2 align="center">  
      <font color="red">  
       DEMO: Use XSLT to create XLS attachment  
       <BR/>  
       Warning: Size of attachment can get large  
      </font>  
     </H2>  
     <H2>  
      This email was produced by program ZZFLOTH_TRANS_EMAIL_XLS_HTM  
     </H2>  
     <H3>  
      Email Attachment XSLT: ZZFLOTH_TRANS_XLS  
     </H3>  
     <H3>  
      Email Body XSLT: ZZFLOTH_TRANS_HTM  
     </H3>  
     <BR/>  
     <table class="myTable2">  
      <tr>  
       <th class="p">Airline Code</th>  
       <th class="m">Flight Connection</th>  
       <th class="a">Flight date</th>  
       <th class="k">Currency</th>  
       <th class="n">Airfare</th>  
      </tr>  
      <tt:loop ref=".GT_OUT">  
       <tr>  
        <td class="p">  
         <tt:value ref="$ref.CARRID"/>  
        </td>  
        <td class="m">  
         <tt:value ref="$ref.CONNID"/>  
        </td>  
        <td class="a">  
         <tt:value ref="$ref.FLDATE"/>  
        </td>  
        <td class="k">  
         <tt:value ref="$ref.CURRENCY"/>  
        </td>  
        <td class="n">  
         <tt:value ref="$ref.PRICE"/>  
        </td>  
       </tr>  
      </tt:loop>  
     </table>  
     <BR/>  
    </BODY>  
   </HTML>  
  </tt:template>  
 </tt:transform>  

Simple sflight XSLT transformation for EXCEL

 <?mso-application progid="Excel.Sheet"?>  
 <?sap.transform simple?>  
 <tt:transform xmlns:tt="http://www.sap.com/transformation-templates" xmlns:ddic="http://www.sap.com/abapxml/types/dictionary" xmlns:def="http://www.sap.com/abapxml/types/defined" version="1.0">  
  <tt:root name="ROOT" type="?"/>  
  <tt:root name="GT_OUT" type="ddic:TY_FLIGHTS"/>  
  <tt:template>  
   <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html=  
 "http://www.w3.org/TR/REC-html40">  
    <!--   <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">  
     <Author>authorname</Author>  
     <LastAuthor>authorname</LastAuthor>  
     <Created>2012-02-01T10:12:47Z</Created>  
     <Company/>  
     <Version>12.00</Version>  
    </DocumentProperties>-->  
    <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">  
     <!-- <ReadOnlyRecommended/>-->  
    </OfficeDocumentSettings>  
    <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">  
     <WindowHeight>11055</WindowHeight>  
     <WindowWidth>19155</WindowWidth>  
     <WindowTopX>0</WindowTopX>  
     <WindowTopY>120</WindowTopY>  
     <ProtectStructure>False</ProtectStructure>  
     <ProtectWindows>False</ProtectWindows>  
    </ExcelWorkbook>  
    <Styles>  
     <Style ss:ID="Default" ss:Name="Normal">  
      <Alignment ss:Vertical="Bottom"/>  
      <Borders/>  
      <Font ss:Color="#000000" ss:FontName="Arial" ss:Size="12" x:Family="Swiss"/>  
      <Interior/>  
      <NumberFormat/>  
      <Protection/>  
     </Style>  
     <Style ss:ID="hdr">  
      <Alignment ss:Horizontal="Center"/>  
      <Borders>  
       <Border ss:Position="Left" ss:Color="#000000" ss:LineStyle="Continuous" ss:Weight="1"/>  
       <Border ss:Position="Right" ss:Color="#000000" ss:LineStyle="Continuous" ss:Weight="1"/>  
       <Border ss:Position="Top" ss:Color="#000000" ss:LineStyle="Continuous" ss:Weight="1"/>  
       <Border ss:Position="Bottom" ss:Color="#000000" ss:LineStyle="Continuous" ss:Weight="1"/>  
      </Borders>  
      <Font ss:Bold="1" ss:Size="20"/>  
      <Interior ss:Color="#A9D0F5" ss:Pattern="Solid"/>  
     </Style>  
     <Style ss:ID="key">  
      <Borders>  
       <Border ss:Position="Left" ss:Color="#000000" ss:LineStyle="Continuous" ss:Weight="1"/>  
       <Border ss:Position="Right" ss:Color="#000000" ss:LineStyle="Continuous" ss:Weight="1"/>  
       <Border ss:Position="Top" ss:Color="#000000" ss:LineStyle="Continuous" ss:Weight="1"/>  
       <Border ss:Position="Bottom" ss:Color="#000000" ss:LineStyle="Continuous" ss:Weight="1"/>  
      </Borders>  
      <Font ss:Bold="1" ss:Size="20"/>  
      <Interior ss:Color="#C0C0C0" ss:Pattern="Solid"/>  
     </Style>  
     <Style ss:ID="12r">  
      <Font ss:Bold="1" ss:Color="red"/>  
     </Style>  
     <Style ss:ID="s62">  
      <Protection/>  
     </Style>  
    </Styles>  
    <Worksheet ss:Name="SFLIGHT" ss:Protected="0">  
     <Table x:FullColumns="1" x:FullRows="1">  
 <!--AutofitWidth only works on datetime/numeric fields     -->  
 <!--     <Column ss:AutoFitWidth="1"/>-->  
 <!--     <Column ss:AutoFitWidth="1"/>-->  
      <Column ss:Width="125"/>  
      <Row ss:AutoFitHeight="1" ss:StyleID="hdr">  
       <Cell>  
        <Data ss:Type="String">Airline Code</Data>  
       </Cell>  
       <Cell>  
        <Data ss:Type="String">Connection</Data>  
       </Cell>  
       <Cell>  
        <Data ss:Type="String">Date</Data>  
       </Cell>  
       <Cell>  
        <Data ss:Type="String">Curr</Data>  
       </Cell>  
       <Cell>  
        <Data ss:Type="String">Airfare</Data>  
       </Cell>  
      </Row>  
      <tt:loop ref=".GT_OUT">  
       <Row ss:AutoFitHeight="1">  
        <Cell ss:StyleID="key">  
         <Data ss:Type="String">  
          <tt:value ref="$ref.CARRID"/>  
         </Data>  
        </Cell>  
        <Cell ss:StyleID="12r">  
         <Data ss:Type="String">  
          <tt:value ref="$ref.CONNID"/>  
         </Data>  
        </Cell>  
        <Cell>  
         <Data ss:Type="String">  
           <tt:value ref="$ref.FLDATE"/>  
         </Data>  
        </Cell>  
        <Cell>  
         <Data ss:Type="String">  
          <tt:value ref="$ref.CURRENCY"/>  
         </Data>  
        </Cell>  
        <Cell>  
         <Data ss:Type="Number">  
          <tt:value ref="$ref.PRICE"/>  
         </Data>  
        </Cell>  
       </Row>  
      </tt:loop>  
     </Table>  
 <!--    <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">  
      <PageSetup>  
       <Header x:Margin="0.3"/>  
       <Footer x:Margin="0.3"/>  
       <PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>  
      </PageSetup>  
      <Unsynced/>  
      <Print>  
       <ValidPrinterInfo/>  
       <HorizontalResolution>600</HorizontalResolution>  
       <VerticalResolution>600</VerticalResolution>  
      </Print>  
      <Selected/>  
      <Panes>  
       <Pane>  
        <Number>3</Number>  
        <ActiveRow>22</ActiveRow>  
        <ActiveCol>2</ActiveCol>  
       </Pane>  
      </Panes>  
      <ProtectObjects>True</ProtectObjects>  
      <ProtectScenarios>True</ProtectScenarios>  
     </WorksheetOptions>-->  
    </Worksheet>  
   </Workbook>  
  </tt:template>  
 </tt:transform>