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

Re: XSL Working draft question

Subject: Re: XSL Working draft question
From: "Randy Waki" <Waki.Randy@xxxxxxxxxxxxx>
Date: Thu, 20 Aug 1998 13:08:31 -0600
xsl working with attributes
Jeremy CALLES <Jeremy.Calles@xxxxxxxxxxxxxxx> wrote:
> In the 2.7.11.3 paragraph of the XSL WD, Attribute Value Templates is
> explain.
> 
> But in the example 
> 
> <xsl:define-constant name="image-dir" value="/images"/>
> 
> <xsl:template match="photograph">
> <IMG SRC="{constant(image-dir)}/{href}"
> WIDTH="{size/attribute(width)}"/>
> </xsl:template>
> 
> With this source
> 
> <photograph>
>   <href>headquarters.jpg</href>
>   <size width="300"/>
> </photograph>
> 
> I don't understand this match: size/attribute(width)
> Normally an attribute should be matched by the command
> size[attribute(width)],
> according to the 2.6.8 paragraph.

There's an important distinction between slashes and square brackets.
Slashes (see 2.6.2) "navigate" to child elements and attributes. Square
brackets (see 2.6.6) constrain an element without "navigating." So:

    "size/attribute(width)" matches a width attribute of a size element.
    In the example, this navigates from the photograph element (since
    that's what the template matches) to the size element and then to
    the width attribute, resulting in the string "300".

    "size[attribute(width)]" matches a size element which must have a
    width attribute. In the example, this would navigate to the size
    element, which qualifies since it has a width attribute, resulting
    in the empty string since the size element is empty.

To put it another way, it's the distinction between grammar productions
25 and 24 (AttributePattern and AttributeQualifier).

> Is it a typo or a new mean of matching attributes especially for
> Attribute Value Templates.

Kind of the latter. Although the draft doesn't say so in one place, I
think that AttributePatterns are allowed in xsl:if, xsl:when,
xsl:value-of, and attribute value templates (i.e., in boolean tests and
strings); they are currently disallowed in xsl:template, xsl:process,
xsl:for-each, and xsl:number (i.e., when the matching nodes must be
dealt with as nodes).

Randy



 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.