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

Re: Pattern for attribute matching

Subject: Re: Pattern for attribute matching
From: "Paul W. Abrahams" <abrahams@xxxxxxxxxxx>
Date: Sat, 31 Jul 1999 15:08:02 -0400
xpath attribute matching
> The XSL-List Digest      Saturday, July 31 1999      Volume 02 : Number 234
>
>
> Date: Fri, 30 Jul 1999 16:16:11 -0400
> From: "Paul W. Abrahams" <abrahams@xxxxxxxxxxx>
> Subject: Pattern for attribute matching
>
> If I want to construct a template that matches a `foo' element with a
> `bar' attribute, the appropriate `match' attribute is:
>
>     match="foo[@bar]"
>
> Moreover, if I want to match any `bar' attribute at all, the appropriate
> `match' attribute is
>
>    match="@bar"
>
> But suppose I want to match a `bar' attribute that's attached to a `foo'
> element.  My first guess would be
>
>   match="foo/@bar"
>
> But that doesn't seem entirely right because attributes are not children
> of element nodes, but rather associated with element nodes.  So if that
> isn't correct, what would be correct?
>
> This question relates to a larger unresolved (apparently) issue in
> XPath: whether attribute nodes are really part of the document tree
> described by XPath, or related in some other way.  Sec. 5 (Data Model)
> says:
>
>    ``XPath operates on a XML document as a tree.  This section descripe
> how XPath models an XML document as a tree.''
>
> But in Sec. 5.3 (Attribute Nodes) it says:
>
>    ``Each element node has an associated set of attribute nodes.''
>
> So where does reality lie?
>
> Paul Abrahams
> abrahams@xxxxxxx
>
> ------------------------------
>
> Date: Fri, 30 Jul 1999 22:24:03 +0100 (BST)
> From: David Carlisle <davidc@xxxxxxxxx>
> Subject: Re: Pattern for attribute matching
>
>   match="foo/@bar"
>
> But that doesn't seem entirely right because attributes are not children
>
> it is right. / does not mean `children' it means `next step' and at each
> step you can change axis along which to travel, here you have @ which is
> short for attribute::, and no specified axis is short for child:: so the
> above is really
>
> child::foo/attribute::bar
>
> which means get bar attributes of foo children.
>
> David
>
> ------------------------
>
> ------------------------------
>
> Date: Fri, 30 Jul 1999 23:41:12 +0100 (BST)
> From: David Carlisle <davidc@xxxxxxxxx>
> Subject: Re: Pattern for attribute matching
>
> > The first match finds foo elements that have a bar attribute.
> > The third match finds children of foo elements that have a bar attribute.
>
> No.
>
> the first finds foo elements that have are children of the current
> node, and have a bar attribute
> the second finds bar attributes of foo children of the current node.
>
> if this is in an apply-templates, then the current node in the matching
> template will be the foo element in the first case but an _attribute
> node_ in the second.
>
> David
>

My intent in the third pattern is to match certain `bar' attributes,
namely, all those in the document that
are associated with `foo' elements.  I guess that the pattern

    foo/@bar

really does that (except for the possible case of the root node being a
`foo').

But the other question remains: is an attribute node a child of its
element node or merely associated with
it?  And if it's merely associated, how can it be part of the document
tree?

Paul Abrahams


 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.