xsl-list
[Top] [All Lists]

Re: Selecting specific portions of a tree.

2003-12-09 08:26:11
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(_dot_)barclay(_at_)digitalbridges(_dot_)com>
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