This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: divide info in several output files
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] divide info in several output files
- From: Cristobal Galiano Fernandez <c dot galiano at ua dot es>
- Date: Tue, 06 Mar 2001 13:39:17 +0100
- Organization: Universidad de Alicante
- References: <MKEPLCACCCLCDCCDGIJDEEFKCBAA.tapan_nanawati@yahoo.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
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@yahoo.com> & 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() >$inicio - 1 and position() <$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() <
> $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@yahoo.com
> 91-11-6685274 (o)
> 91-98112-98982 (m)
> New Delhi - INDIA
> ------------------------------
> God is real, unless declared integer.
>
> $-----Original Message-----
> $From: owner-xsl-list@lists.mulberrytech.com
> $[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Aniceto López
> $Sent: Thursday, March 01, 2001 9:30 PM
> $To: XSL-List@lists.mulberrytech.com
> $Subject: [xsl] 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