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

Re: How to get page range within a group

Subject: Re: How to get page range within a group
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 12 Sep 2008 09:36:55 -0400
Re:  How to get page range within a group
J.S.,

At 01:38 AM 9/12/2008, you wrote:
Hi All,
I am not able to get the appropriate result. Can anybody let me know about the mistake I am doing. I want a page range within <doc>.

...


<xsl:if test="//doc//pb[position()=1]">
<xsl:variable name="fpage" select="substring-after(//doc//pb[position()=1]/@n,'-')"/>

...


This isn't working for you since the expression //doc//pb[position()=1] does not return what you think it does.

It may appear it should return the first 'pb' element appearing inside each 'doc' element in the document, but this isn't so. The semantics of "//" is not (as it is commonly glossed) "all the nodes (or elements) all the way down the tree". It is an abbreviation for "/descendant-or-self::node()/", which in itself is not a complete XPath expression, but must be completed by adding an axis and node test. In particular, when you say "//pb" you are implicitly adding the child:: axis (as always when no axis is given explicitly) along with the "pb" node test. That is, "//pb" is short for "/descendant-or-self::node()/child::pb".

This is crucial since it means that //pb[1] does not mean "the first 'pb' descendant" but "the first pb child of any descendant".

If you actually want the first descendant, the easiest way to get that is (in your case) "//doc/descendant::pb[1]".

You may have other problems (I haven't shaken the code out completely), but nothing will work right as long as this isn't correct.

I hope that helps,
Wendell



======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

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.