This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Problems passing attributes


To add to what David and Jarno have said:

self::*[@border]

translates into English as "the context node (itself), if it has a 'border' 
attribute"

and would be almost the same as .[@border], except that the latter is not 
allowed (as Jarno said). (I say almost the same since '.' is short not for 
"self::*" but for "self::node()". node() selects nodes of any type, whereas 
* selects only nodes of the primary type of the axis, usually elements.)

*[@border]

is short for "child::*[@border]"

But "self::" and "child::" have nothing to do with namespaces; rather, they 
are XPath axis specifiers. Check out the XPath spec for full details. As 
Jarno and David said, XPath is built into XSLT and no special namespace 
apparatus is needed to use it.

Don't get thrown off by the appearance of the colon. 'self::*' and 'self:*' 
are two very different things. 'self::*' is the element on the self axis, 
whereas 'self:*' would be short for 'child::self:*', meaning all elements 
in the 'self' namespace on the child axis.

But please don't ever use a namespace prefix like 'self' or 'child' or 
'ancestor' unless you want your code to be unintelligible even to yourself. 
This would truly be horrible:

self::ancestor:node[@child:border]

which would translate as "the context node itself, if and only if it is an 
element named 'ancestor:node' and has an attribute named 'child:border'". 
Yikes!

Confused yet? :-)

Cheers,
Wendell


======================================================================
Wendell Piez                            mailto:wapiez@mulberrytech.com
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
======================================================================


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]