Re: Questions on the new XSL spec (section 2.6)

Subject: Re: Questions on the new XSL spec (section 2.6)
From: James Clark <jjc@xxxxxxxxxx>
Date: Tue, 29 Dec 1998 12:52:03 +0700
Steve Dahl wrote:
> 
> In section 2.6, the new pattern rules seem confusing to me:
> 
>     Can '.', '..', ancestor(), ancestor-or-self(), and id() appear in
> match patterns, or only in select patterns?

Yes.

>     What does it mean when they occur in a match pattern, if that's
> permitted?

See 2.6.2 under Matching, second paragraph.  These are kind of confusing
when used as match patterns; one case is definitely useful:

 id("foo")

matches an element with ID "foo".

>     Can these patterns appear in a SubtreeExpr? In other words, can they
> appear as a "child" of another pattern? For example, is
> 'a/b/ancestor(c)/d' a permitted pattern?

Yes.

>     If this is permitted, what does it mean if they are preceded by '/'?

See 2.6.2 under Composition.

As a select pattern:

 foo selects foo element children

 / does composition, so foo/bar means for each foo child, select each
bar child.

As a useful example, consider

foo/id(@ref)/bar

This finds foo children of the current node, then gets the ref attribute
of each foo child, finds the element that each such attribute
references, then finds the bar child of each such element.

> What does it mean if they are preceded by '//'?

See 2.6.2 under Subtrees.

foo//bar

means

  for each node X in the foo element children of the current node
    for each node Y in the subtree rooted at X
       select the bar children of Y

Thus

  foo//..

would mean

  for each node X in the foo element children of the current node
    for each node Y in the subtree rooted at X
       select the parent of Y

It's well-defined but not terribly useful (XT doesn't currently
implement any of the cases you mention in match patterns).

>     It's possible in the new pattern syntax to have '@x' followed
> immediately by '/'. But '@x/y' is a pattern that doesn't seem to make
> any sense. 

It makes sense; it just can't ever match a node.

> What kinds of NodeExpr are allowed to follow an
> AttributeExpr, when they are separated by '/' or '//'?

Any kind.

> Similarly, what
> kinds of NodeExpr are allowed to follow a TextExpr, CommentExpr, or
> PiExpr?

Any kind.

James



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread