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

Meaning of XPath spec?

Subject: Meaning of XPath spec?
From: chet@xxxxxxxxxxxxxx
Date: Tue, 17 Aug 1999 16:20:16 -0400
xpath spec
In reading thru the XPath spec, I found the following in section 3.3.

     NOTE: The meaning of a Predicate depends crucially on which axis
     applies. For example, preceding::foo[1] returns the first foo
     element in reverse document order, because the axis that applies
     to the [1] predicate is the preceding axis; by contrast,
     (preceding::foo)[1] returns the first foo element in document
     order, because the axis that applies to the [1] predicate is the
     child axis.

I searched thru the grammar, and could not find a way to parse the
second expression.  Nevertheless, XML4J returns the right thing.

In attempting to decipher this path, I wrote the following XML file

================================================================
<?xml version="1.0"?>
<doc>
<buzz>first buzz</buzz>
<foo>first foo</foo>
<foo>second foo</foo>
<foo>third foo</foo>
<bar/>
</doc>
================================================================

and the following XSL file

================================================================
<?xml version="1.0"?> 

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

  <!-- Root xsl:template - start processing here -->
  <xsl:template match="/">
		    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="doc">
	  Rule1(<xsl:apply-templates select="bar"/>)
  </xsl:template>

  <xsl:template match="bar">
    Rule2[preceding::foo](<xsl:copy-of select="preceding::foo"/>)
    Rule2[preceding::foo[1]](<xsl:copy-of select="preceding::foo[1]"/>)
    Rule2[(preceding::foo)](<xsl:copy-of select="(preceding::foo)"/>)
    Rule2[(preceding::foo)[1]](<xsl:copy-of select="(preceding::foo)[1]"/>)
  </xsl:template>

</xsl:stylesheet>
================================================================

and the output from the Lotus XSL processor was

================================================================
          Rule1(
(1)    Rule2[preceding::foo](<foo>first foo</foo><foo>second foo</foo><foo>third foo</foo>)
(2)    Rule2[preceding::foo[1]](<foo>third foo</foo>)
(3)    Rule2[(preceding::foo)](<foo>first foo</foo><foo>second foo</foo><foo>third foo</foo>)
(4)    Rule2[(preceding::foo)[1]](<foo>first foo</foo>)
  )
================================================================

There are quite a few things I don't understand:

(a) why do (1) and (3) produce the same thing, and yet, (2) and (4)
produce different things?

(b) what does

  (preceding::foo)[1]

even mean?  For that matter,

  (preceding::foo)

(c) what is its unabbreviated syntax?

Thanks,
--chet--


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