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

RE: Retriving next 10 elements?

Subject: RE: Retriving next 10 elements?
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Sat, 19 Aug 2000 10:50:18 +0100
td style wrap
Vetrievel,

Probably your message didn't get through to the list, which refuses
attachments - you should include your files within the messages in order to
send them.

>  Thank you for  your suggestions.We tried with your way.Still it is not
>working.For your reference we have attached those xml&xsl files.We can't
>understand where we are going wrong.If you give your suggestions,it will
>help us  a lot.

OK, you've obviously taken a stylesheet that used the simplified syntax,
just consisting of a literal result element, and then added an xsl:template
into the middle of it.  You can't have a template in the middle of a
simplified stylesheet - you have to convert it to a proper stylesheet to
add the template.

To convert your simplified stylesheet into a proper stylesheet, wrap what
you have within an xsl:template that matches on the root node:

<xsl:template match="/">
  <!-- content of the simplified stylesheet -->
</xsl:template>

And then wrap that template (and any other instructions you want) within an
xsl:stylesheet:

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

<xsl:template match="/">
  <!-- content of the simplified stylesheet -->
</xsl:template>

<!-- other templates -->

</xsl:stylesheet>

In your example, you don't have to go through this because you can just use
xsl:for-each rather than applying templates to achieve the effect you want
to achieve.  The stylesheet can thus be:

---- employeeSS.xsl ----
<?xml version="1.0"?>
<div xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0">
  <table border="5">
    <thead>
      <th>Name</th>
      <th>slno</th>
      <th>DOB</th>
      <th>DOJ</th>
      <th>Designation</th>
      <th>Salary</th>
      <th>Emp_id</th>
    </thead>
    <xsl:for-each select="employees/employee[position() mod 5 = 1]">
      <tr><th colspan="7">Set <xsl:value-of select="position()" /></th></tr>
      <xsl:for-each
          select=". | following-sibling::employee[position() &lt; 5]">
        <tr>
          <td style="padding-left:1em">
            <span><xsl:value-of select="Name"/></span>
          </td>
          <td style="padding-left:1em">
            <span><xsl:value-of select="slno"/></span>
          </td>
          <td style="padding-left:1em">
            <span><xsl:value-of select="DOB"/></span>
          </td>
          <td style="padding-left:1em">
            <span><xsl:value-of select="DOJ"/></span>
          </td>
          <td style="padding-left:1em">
            <span><xsl:value-of select="Designation"/></span>
          </td>
          <td style="padding-left:1em">
            <span><xsl:value-of select="Salary"/></span>
          </td>
          <td style="padding-left:1em">
            <span><xsl:value-of select="Emp_id"/></span>
          </td>   
        </tr>
      </xsl:for-each>
    </xsl:for-each>
  </table>
</div>
----

A few words about the changes I've made.

You needed to put the 'version' attribute on the 'div' element be within
the xsl namespace - xsl:version rather than just 'version'.

It wasn't clear from your stylesheet how you wanted to divide up the groups
of five: the stylesheet can process them in groups of five, but presumably
you want them to appear in those groups, so I've added a header at the top
of each group to show them, and labelled them Set 1, Set 2 and so on.

The XPaths that you use in a simplified stylesheet have the current node
being the root node (/), which means that you have to remember to include
the document element in them.

Finally, I've put all your HTML elements in lowercase so that they are
XHTML-compatible.  There's no harm in doing that, so you may as well.

I've tested this stylesheet with Xalan, SAXON and MSXML (July) and it works
in all three.

I hope that helps,

Jeni

Jeni Tennison
http://www.jenitennison.com/


 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-2011 All Rights Reserved.