Advertisement
Guest User

Untitled

a guest
Jan 9th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:fo="http://www.w3.org/1999/XSL/Format">
  4.     <xsl:template match="/">
  5.     <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  6.  
  7.         <!-- Layout Master -->
  8.         <fo:layout-master-set>
  9.             <fo:simple-page-master master-name="titlePage"
  10.                                    page-height="297mm" page-width="210mm"
  11.                                    margin="20mm">
  12.                 <fo:region-body margin-top="20mm" background-image="obrazy/bodybg.png" background-repeat="no-repeat"/>
  13.             </fo:simple-page-master>
  14.            
  15.             <fo:simple-page-master master-name="otherPages"
  16.                                    page-height="297mm" page-width="210mm"
  17.                                    margin="20mm">
  18.                 <fo:region-body/>
  19.                 <fo:region-after/>
  20.             </fo:simple-page-master>
  21.            
  22.             <fo:page-sequence-master master-name="order">
  23.                 <fo:repeatable-page-master-alternatives>
  24.                     <fo:conditional-page-master-reference page-position="first" master-reference="titlePage"/>
  25.                     <fo:conditional-page-master-reference page-position="rest" master-reference="otherPages"/>
  26.                 </fo:repeatable-page-master-alternatives>
  27.             </fo:page-sequence-master>
  28.         </fo:layout-master-set>
  29.        
  30.         <!-- Page sequences -->
  31.         <fo:page-sequence master-reference="titlePage">
  32.             <fo:flow flow-name="xsl-region-body">
  33.                 <fo:block text-align="center" font-size="40pt"
  34.                           font-weight="bold" space-after="10mm">
  35.                     Tatry
  36.                 </fo:block>
  37.                 <fo:table table-layout="fixed" width="100%">
  38.                     <fo:table-column column-width="proportional-column-width(1)"/>
  39.                     <fo:table-column column-width="50mm"/>
  40.                     <fo:table-column column-width="50mm"/>
  41.                     <fo:table-column column-width="proportional-column-width(1)"/>
  42.                     <fo:table-body>
  43.                         <fo:table-row>
  44.                             <fo:table-cell column-number="2">
  45.                                 <fo:block>
  46.                                     <fo:external-graphic width="50mm" height="41mm" content-height="scale-to-fit" content-width="scale-to-fit">
  47.                                         <xsl:attribute name="src">
  48.                                             url("<xsl:value-of select="tatry/child::*[1]/zdjecie/@src"/>")
  49.                                         </xsl:attribute>
  50.                                     </fo:external-graphic>
  51.                                 </fo:block>
  52.                             </fo:table-cell>
  53.                             <fo:table-cell column-number="3">
  54.                                 <fo:block>
  55.                                     <fo:external-graphic width="50mm" height="41mm" content-height="scale-to-fit" content-width="scale-to-fit">
  56.                                         <xsl:attribute name="src">
  57.                                             url("<xsl:value-of select="tatry/child::*[2]/zdjecie/@src"/>")
  58.                                         </xsl:attribute>
  59.                                     </fo:external-graphic>
  60.                                 </fo:block>
  61.                             </fo:table-cell>
  62.                         </fo:table-row>
  63.                         <fo:table-row>
  64.                             <fo:table-cell column-number="2">
  65.                                 <fo:block>
  66.                                     <fo:external-graphic width="50mm" height="41mm" content-height="scale-to-fit" content-width="scale-to-fit">
  67.                                         <xsl:attribute name="src">
  68.                                             url("<xsl:value-of select="tatry/child::*[3]/zdjecie/@src"/>")
  69.                                         </xsl:attribute>
  70.                                     </fo:external-graphic>
  71.                                 </fo:block>
  72.                             </fo:table-cell>
  73.                             <fo:table-cell column-number="3">
  74.                                 <fo:block>
  75.                                     <fo:external-graphic width="50mm" height="41mm" content-height="scale-to-fit" content-width="scale-to-fit">
  76.                                         <xsl:attribute name="src">
  77.                                             url("<xsl:value-of select="tatry/child::*[4]/zdjecie/@src"/>")
  78.                                         </xsl:attribute>
  79.                                     </fo:external-graphic>
  80.                                 </fo:block>
  81.                             </fo:table-cell>
  82.                         </fo:table-row>
  83.                     </fo:table-body>
  84.                 </fo:table>
  85.             </fo:flow>
  86.         </fo:page-sequence>
  87.        
  88.         <fo:page-sequence master-reference="otherPages">
  89.             <fo:static-content flow-name="xsl-region-after">
  90.               <fo:block text-align="right"><fo:page-number/></fo:block>
  91.             </fo:static-content>
  92.             <fo:flow flow-name="xsl-region-body">
  93.                 <xsl:apply-templates/>
  94.             </fo:flow>
  95.         </fo:page-sequence>
  96.     </fo:root>
  97.     </xsl:template>
  98.    
  99.     <!-- Object templates -->
  100.     <xsl:template match="szczyt">
  101.         <fo:block page-break-before="always" font-size="25pt"><xsl:value-of select="nazwa"/></fo:block>
  102.         <fo:block>Szczyt <xsl:value-of select="@przynaleznosc"/>.</fo:block>
  103.         <fo:block>
  104.             <fo:external-graphic width="50mm" height="41mm" content-height="scale-to-fit" content-width="scale-to-fit">
  105.                 <xsl:attribute name="src">
  106.                     url("<xsl:value-of select="zdjecie/@src"/>")
  107.                 </xsl:attribute>
  108.             </fo:external-graphic>
  109.         </fo:block>
  110.         <fo:block font-family="Times New Roman">Wysokość:</fo:block>
  111.         <fo:block font-family="Times New Roman" margin-left="2mm">Względna: <xsl:value-of select="wysokosc/wzgledna"/>m.</fo:block>
  112.         <fo:block font-family="Times New Roman" margin-left="2mm">Bezwzględna: <xsl:value-of select="wysokosc/bezwzgledna"/>m.</fo:block>
  113.         <xsl:call-template name="opis_template"/>
  114.     </xsl:template>
  115.    
  116.     <xsl:template match="roślina | zwierze">
  117.         <fo:block page-break-before="always" font-family="Times New Roman" font-size="25pt">
  118.             <xsl:value-of select="nazwa[@jezyk = 'polska']"/>
  119.         </fo:block>
  120.         <fo:block><xsl:value-of select="nazwa[@jezyk = 'łacińska']"/></fo:block>
  121.         <fo:block>
  122.             <fo:external-graphic width="50mm" height="41mm" content-height="scale-to-fit" content-width="scale-to-fit">
  123.                 <xsl:attribute name="src">
  124.                     url("<xsl:value-of select="zdjecie/@src"/>")
  125.                 </xsl:attribute>
  126.             </fo:external-graphic>
  127.         </fo:block>
  128.         <fo:table table-layout="fixed" width="100%" border="2px solid #69b900">
  129.             <fo:table-column column-width="23mm"/>
  130.             <fo:table-column column-width="34mm"/>
  131.             <fo:table-header background-color="#8AFF5A">
  132.                 <fo:table-row>
  133.                     <fo:table-cell number-columns-spanned="2" text-align="center">
  134.                         <fo:block font-weight="bold">Systematyka</fo:block>
  135.                     </fo:table-cell>
  136.                 </fo:table-row>
  137.             </fo:table-header>
  138.             <fo:table-body background-color="#CAFF85">
  139.                 <xsl:apply-templates select="systematyka"/>
  140.                 <xsl:if test="wystepowanie">
  141.                     <fo:table-row>
  142.                         <fo:table-cell background-color="#8AFF5A" number-columns-spanned="2" text-align="center">
  143.                             <fo:block font-weight="bold" font-family="Times New Roman">Występowanie</fo:block>
  144.                         </fo:table-cell>
  145.                     </fo:table-row>
  146.                     <xsl:apply-templates select="wystepowanie"/>
  147.                 </xsl:if>
  148.             </fo:table-body>
  149.         </fo:table>
  150.         <xsl:call-template name="opis_template"/>
  151.     </xsl:template>
  152.    
  153.     <!-- Opis template -->
  154.     <xsl:template name="opis_template">
  155.         <fo:list-block space-before="3mm">
  156.             <xsl:apply-templates select="opis/podpunkt"/>
  157.         </fo:list-block>
  158.         <fo:block space-before="5mm" font-family="Times New Roman">
  159.             Informacje zaczerpnięte z:
  160.             <fo:basic-link color="blue">
  161.                 <xsl:attribute name="external-destination">
  162.                     url("<xsl:value-of select="odnosnik[1]/@href"/>")
  163.                 </xsl:attribute>
  164.             Wikipedii
  165.             </fo:basic-link>
  166.         </fo:block>
  167.     </xsl:template>
  168.    
  169.     <!-- Podpunkt template -->
  170.     <xsl:template match="podpunkt">
  171.         <fo:list-item>
  172.             <fo:list-item-label>
  173.                 <fo:block><xsl:number value="position()"/>:</fo:block>
  174.             </fo:list-item-label>
  175.             <fo:list-item-body>
  176.                 <fo:block font-family="Times New Roman" margin-left="5mm">
  177.                     <fo:inline font-weight="bold"><xsl:value-of select="@o_czym"/>: </fo:inline>
  178.                     <xsl:value-of select="."/>
  179.                 </fo:block>
  180.             </fo:list-item-body>
  181.             <xsl:value-of select="."/>
  182.         </fo:list-item>
  183.     </xsl:template>
  184.    
  185.     <!-- Systematyka template -->
  186.     <xsl:template match="systematyka/child::*">
  187.         <fo:table-row>
  188.             <fo:table-cell border="1px solid #69b900">
  189.                 <fo:block><xsl:value-of select="name(.)"/></fo:block>
  190.             </fo:table-cell>
  191.             <fo:table-cell border="1px solid #69b900" font-family="Times New Roman">
  192.                 <fo:block><xsl:value-of select="."/></fo:block>
  193.             </fo:table-cell>
  194.         </fo:table-row>
  195.     </xsl:template>
  196.    
  197.     <!-- Wystepowanie template -->
  198.     <xsl:template match="kraj">
  199.         <fo:table-row>
  200.             <fo:table-cell border="1px solid #69b900">
  201.                 <fo:block>
  202.                     <xsl:choose>
  203.                         <xsl:when test="string-length(normalize-space(.)) &gt; 9">
  204.                             <xsl:value-of select="substring(normalize-space(.), 1, 9)"/>...
  205.                         </xsl:when>
  206.                         <xsl:otherwise>
  207.                             <xsl:value-of select="."/>
  208.                         </xsl:otherwise>
  209.                     </xsl:choose>
  210.                 </fo:block>
  211.             </fo:table-cell>
  212.             <fo:table-cell border="1px solid #69b900">
  213.                 <fo:block><xsl:value-of select="liczebnosc/@ile"/></fo:block>
  214.             </fo:table-cell>
  215.         </fo:table-row>
  216.     </xsl:template>
  217.    
  218. </xsl:transform>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement