This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Problems passing attributes
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] Problems passing attributes
- From: "Hewko, Doug" <Doug dot Hewko at ccra-adrc dot gc dot ca>
- Date: Mon, 1 Oct 2001 06:27:19 -0400
- Reply-To: xsl-list at lists dot mulberrytech dot com
Thanks.
Just wondering, why doesn't the following work? The period is not liked by
the parser. I expected the period to mean "self", or the "table" element.
<xsl:template match="table">
<xsl:value-of select=".[@border]">
</xsl:template>
> -----Original Message-----
> From: Wendell Piez [mailto:wapiez@mulberrytech.com]
> Sent: September 28, 2001 2:15 PM
> To: xsl-list@lists.mulberrytech.com
> Subject: Re: [xsl] Problems passing attributes
>
>
> Doug,
>
> Paul's solution is nice because if your input doesn't have a border
> attribute to copy, it avoids getting border="" in your output
> (which you
> might get with plain border="{@border}" in your stylesheet).
>
> It can be further refined as follows:
>
> <xsl:template match="table">
> <table cellspacing="0" cellpadding="0">
> <xsl:copy-of select="@border"/>
> <!-- do the table thing -->
> </table>
> </xsl:template>
>
> which can be further generalized to catch all three attributes:
>
> <xsl:template match="table">
> <table>
> <xsl:copy-of select="@*"/>
> <!-- do the table thing -->
> </table>
> </xsl:template>
>
> -- if you want to copy them all from the input, not set them yourself.
>
> Cheers,
> Wendell
>
> At 12:17 PM 9/28/01, Paul wrote:
> >If you *always* want to emit a border attribute, and you
> *always* want it to
> >be a numeric value (not null), here's an easy way:
> >
> ><xsl:template match="table">
> > <table cellspacing="0" cellpadding="0" border="0">
> > <xsl:if test="@border != ''"><!-- if attribute exists and is
> >non-null -->
> > <xsl:attribute name="border">
> > <xsl:value-of select="@border"/><!-- use
> it's value -->
> > </xsl:attribute>
> > </xsl:if>
> > <!-- do the table thing -->
> > </table>
> ></xsl:template>
> >
> >The last attribute specified in the literal result element
> takes precedence
> >if the same attribute name is used more than once.
> >
> >If you only want to emit a border attribute when a non-null
> one is specified
> >on input, just leave the 'border="0"' out of the literal
> result element
> >begin tag.
> >
> >If you don't care about emitting null border attributes,
> this is the most
> >compact:
> > <table cellspacing="0" cellpadding="0" border="{@border}">
> > <!-- do the table thing -->
> > </table>
>
>
> ======================================================================
> 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
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list