Subject: Re: XSL Working draft question From: "Randy Waki" <Waki.Randy@xxxxxxxxxxxxx> Date: Thu, 20 Aug 1998 13:08:31 -0600 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: XSL Working draft question, James Clark | Thread | Differences between CSS and XSL., sonja . kangas |
Differences between CSS and XSL., sonja . kangas | Date | Re: Any examples of server side XML, Kent Fitch |
Month |