Re: [xsl] Selecting specific portions of a tree.

Subject: Re: [xsl] Selecting specific portions of a tree.
From: Paul Barclay <paul.barclay@xxxxxxxxxxxxxxxxxx>
Date: 09 Dec 2003 16:09:42 +0000
Thanks very much. 

This was actually the basis for producing pages of content in HTML.

I had a list of elements and I needed to render eight elements per page.
I would have used a simple <xsl:for-each...> construct but I was in the
middle of an HTML page.

I converted the html page to a template and passed it a section of the
tree to render, consisting of a part tree collected by a similar process
as described below.

Thanks for your help

Paul


PB
On Tue, 2003-12-09 at 15:26, Mukul Gandhi wrote:
> Hi Paul,
>   I have written the following XSL, to illustrate the
> concept.. I guess, you wish to access the 11th node ;)
> 
> XSL
> ---
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:output method="xml" version="1.0"
> encoding="UTF-8" indent="yes"/>
> 	
> <xsl:template match="root">
>   <xsl:for-each select="child">
>     <xsl:if test="position() = 11">
> 	<xsl:call-template name="print11thNode">
> 	  <xsl:with-param name="x" select="."/>
> 	</xsl:call-template>
>     </xsl:if>
>   </xsl:for-each>
> </xsl:template>
> 	
> <xsl:template name="print11thNode">
>   <xsl:param name="x"/>
>   <xsl:value-of select="$x"/>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> The XML, I have assumed is --
> <?xml version="1.0" encoding="UTF-8"?>
> <root>
>   <child>1</child>
>   <child>2</child>
>   <child>3</child>
>   <child>4</child>
>   <child>5</child>
>   <child>6</child>
>   <child>7</child>
>   <child>8</child>
>   <child>9</child>
>   <child>10</child>
>   <child>11</child>
>   <child>12</child>
>   <child>13</child>
>   <child>14</child>
>   <child>15</child>
> </root>
> 
> I have added the numbers 1,2,3 etc, within child tags,
> for illustration purpose ;)
> 
> I hope, my answer is useful ;)
> 
> Regards,
> Mukul
> 
> --- Paul Barclay <paul.barclay@xxxxxxxxxxxxxxxxxx>
> wrote:
> > Given the XML.
> > 
> > <root>
> > 	<child ..../>
> > 	<child ..../>
> > 	<child ..../>
> > 	<child ..../>
> > 	<child ..../>
> > 	<child ..../>
> > 	<child ..../>
> > 	<child ..../>
> > 	<child ..../>
> > 	<child ..../>
> > 	<child ..../>
> > 	<child ..../>
> > 	<child ..../>
> > 	<child ..../>
> > 	<child ..../>
> > </root>
> > 
> > what is the XSL expression to select the 3rd to the
> > 8th child of root?
> > 
> > Thanks
> > Paul
> > 
> > 
> >
> ________________________________________________________________________
> > 
> > E-mail is an informal method of communication and
> > may be subject to data corruption, interception and
> > unauthorised amendment for which Digital Bridges Ltd
> > will accept no liability. Therefore, it will
> > normally be inappropriate to rely on information
> > contained on e-mail without obtaining written
> > confirmation.
> > 
> > This e-mail may contain confidential and/or
> > privileged information. If you are not the intended
> > recipient (or have received this e-mail in error)
> > please notify the sender immediately and destroy
> > this e-mail. Any unauthorized copying, disclosure or
> > distribution of the material in this e-mail is
> > strictly forbidden.
> > 
> >
> ________________________________________________________________________
> > 
> > 
> >  XSL-List info and archive: 
> > http://www.mulberrytech.com/xsl/xsl-list
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> Free Pop-Up Blocker - Get it now
> http://companion.yahoo.com/
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


________________________________________________________________________

E-mail is an informal method of communication and may be subject to data corruption, interception and unauthorised amendment for which Digital Bridges Ltd will accept no liability. Therefore, it will normally be inappropriate to rely on information contained on e-mail without obtaining written confirmation.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

________________________________________________________________________


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


Current Thread