[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: divide info in several output files

Subject: Re: divide info in several output files
From: Cristobal Galiano Fernandez <c.galiano@xxxxx>
Date: Tue, 06 Mar 2001 13:39:17 +0100
xsl stylesheet divide
Another variation.
Excuseme spanish text but is for my documentation. Your example don't work for me

Cristóbal
---------------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- 2001-03-06. Separacion.XSL
     2001-03-06. "Tapan Nanawati" <tapan_nanawati@xxxxxxxxx> & CGF
     """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
     -Separación de un nodo en varios (Paginación)
     -Tomarla a modo de ejemplo ya que se tomó como punto de partida el propuesto
      por Tapan (que no llegó a funcionar).
     """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -->

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

    <xsl:output method="xml" indent="yes"/>
    <xsl:param name="number">5</xsl:param>

    <xsl:template match="category">
        <!-- Selecciono los nodos 1,6,11,16.... -->
        <xsl:apply-templates select="file[position() mod $number = 1]" />
    </xsl:template>

    <xsl:template match="file">
        <category>
            <!-- Añado el atributo de la Página (ordinal) -->
            <!-- En el caso de la página position() se refiere al ordinal del elemento file
                 que se está procesando 1,2,3,4,5 que se corresponderá con el 1,6,11,16,..
                 del fichero original -->
            <xsl:attribute name="Pagina"><xsl:value-of select="position()" /></xsl:attribute>
            <!-- En función del ordinal de la Página (1,2,3,4,5) calculo los las posiciones de
                 los elementos <file> que irán en cada Página -->
            <xsl:variable name="inicio" select="(position()-1)*$number + 1" />
            <xsl:variable name="fin"    select="position()*$number" />
            <!-- <xsl:copy-of select="$inicio" />-<xsl:copy-of select="$fin" /> -->
            <!-- Copio elementos <file> entre limite de posición  -->
            <xsl:copy-of select="../file[position() &gt;$inicio - 1 and position() &lt;$fin + 1 ]"/>

        </category>
    </xsl:template>

</xsl:stylesheet>


Tapan Nanawati escribió:

> try these XML's and XSL's
> solution posted a few days back
>
> XSL :
> -----------
>
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
> <xsl:param name="number">2</xsl:param>
>
> <xsl:template match="category">
>                 <html>
>                 <title> hello </title>
>                         <body>
>                                 <xsl:apply-templates select="file[position() mod $number = 4]"/>
>                         </body>
>                 </html>
>         </xsl:template>
>         <xsl:template match="file">
>                 <category1>
>                         <!--xsl:apply-templates/-->
>                         <xsl:copy-of select=".| following-sibling::file[position() &lt;
> $number]"/>
>                 </category1>
>         </xsl:template>
> </xsl:stylesheet>
>
> XML:
> ------------
>
> <?xml version="1.0"?>
> <?cocoon-process type="xslt"?>
> <?xml-stylesheet href="category.xsl" type="text/xsl"?>
> <category>
>         <file>file1</file>
>         <file>file2</file>
>         <file>file3</file>
>         <file>file4</file>
>         <file>file5</file>
>         <file>file6</file>
>         <file>file7</file>
>         <file>file8</file>
>         <file>file9</file>
>         <file>file10</file>
>         <file>file11</file>
>         <file>file12</file>
>         <file>file13</file>
>         <file>file14</file>
>         <file>file15</file>
>         <file>file16</file>
>         <file>file17</file>
>         <file>file18</file>
>         <file>file19</file>
>         <file>file20</file>
>         <file>file21</file>
>         <file>file22</file>
>         <file>file23</file>
>         <file>file24</file>
>         <file>file25</file>
>         <file>file26</file>
>         <file>file27</file>
> </category>
>
> Keep on changing the value of  $number  to  get as many entries per page as
> you want.
>
> cheers
>
> Tapan Nanawati
> tapan_nanawati@xxxxxxxxx
> 91-11-6685274 (o)
> 91-98112-98982 (m)
> New Delhi - INDIA
> ------------------------------
> God is real, unless declared integer.
>
> $-----Original Message-----
> $From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> $[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Aniceto López
> $Sent: Thursday, March 01, 2001 9:30 PM
> $To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> $Subject:  divide info in several output files
> $
> $
> $hello everybody;
> $
> $I don`t know how to face this problem:
> $
> $one xml file with a long list of items (28 i.e.)
> $<whatever>
> $  <anything>ryur54wrthigyuif</anything>
> $  <anything>ryureicnsd45gkjuif</anything>
> $  <anything>ihdftuiwtusd78yrt</anything>
> $  <anything>..................
> $</whatever>
> $
> $I need to output a html with a few (10 i.e.) of this itens
> $and a link to other page containing the next 10 and
> $so on til the last page including the last 8 items.
> $
> $The quantity of items can be different from one xml file
> $to another so no quantity-dependant-solution
> $
> $is there any idea/solution for this?
> $thanks in advance
> $
> $ani lopez
> $
> $
> $
> $
> $
> $ XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.