Q: pattern selection for outside the context node

Tony Graham tgraham at mulberrytech.com
Fri Jul 9 15:57:57 BST 1999


At 8 Jul 1999 18:24 -0700, G. Ken Holman wrote:
 > According to 6.1.1 there are 12 axes you can choose from when building a
 > pattern:
 > 
 >  [5] AxisIdentifier ::=  'from-ancestors'
 >                        | 'from-ancestors-or-self'
 >                        | 'from-attributes'
 >                        | 'from-children'
 >                        | 'from-descendants'
 >                        | 'from-descendants-or-self'
 >                        | 'from-following'
 >                        | 'from-following-siblings'
 >                        | 'from-parent'
 >                        | 'from-preceding'
 >                        | 'from-preceding-siblings'
 >                        | 'from-self'

These are good for location paths, but not for patterns.  Section 6.3
states:

   A pattern must match the grammar for Pattern. A Pattern is set of
   location path patterns separated by |. A location path pattern is a
   location path none of the steps of which use either AxisIdentifiers
   or . or ... Location path patterns can also start with an id() or
   key() function call with a literal argument (see [6.2.2
   Node-sets]). Predicates in a pattern can use arbitrary expressions
   just like predicates in a location path.

 > And according to 6.1.4 there are abbreviations available to be used to
 > address 5 of the axes:
 > 
 >     .       refers to   from-self
 >     @name   refers to   from-attributes   (name of "*" means "all")
 >     name    refers to   from-children     (name of "*" means "all")
 >     ..      refers to   from-parent
 >     //      refers to   from-descendants

But you can't use "." or ".." in a pattern.

 > When the pattern starts with "/", the orientation is from the root of the
 > tree.
 > 
 > The pattern can be comprised of a number of location steps, each step
 > delimited by "/".
 > 
 > The function id() described in 6.2.2 allows you to, in a location step,
 > refer to a node or nodes with unique identifiers.

Provided you specify the ID as a literal string.

 > The function key() is similar to id() in that it allows you to refer to a
 > node or nodes elsewhere in the document, but it does so without the
 > reference needing to be a node with a unique identifier.  There is a short
 > description of the power of the key() function in the free resources
 > section of our web site.

Provided you use literal arguments.

Regards,


Tony Graham
======================================================================
Tony Graham                            mailto:tgraham at mulberrytech.com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9632
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)





More information about the Xml-dev mailing list