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

Re: REQUIRED vs. IMPLIED attributes

Subject: Re: REQUIRED vs. IMPLIED attributes
From: "Nikolai Grigoriev" <grig@xxxxxxxxxxx>
Date: Sun, 23 Jul 2000 11:30:17 +0400
required vs implied xml
Jeni Tennison wrote:

> For a more generic solution, you can cycle through the attributes that are
> present and make copies of them.  Naturally, this will capture all
> #REQUIRED attributes (as they will be [*must* be] present) and any #IMPLIED
> attributes that are around.

> The problem with this approach is that you cannot change the names of the
> attributes.  This involves using extra knowledge about the mapping between
> the old names and the new names, which you have to either embed in the
> template itself or make explicit elsewhere and reference from within the
> template (let me know if you want to see an example).

In such cases, it may be convenient to delegate attribute processing to separate
templates, instead of a for-each loop. This is more verbose, but (IMHO) it
yields a better manageable code:

<xsl:template match="Link">
    <h2><xsl:apply-templates select="@*|text()"/></h2>
</xsl:template>

<!-- A default rule for processing link attributes -->
<xsl:template match="Link/@*" priority="-1">
    <xsl:copy/>
</xsl:template>

<!-- To change a name of an attribute -->
<xsl:template match="Link/@linkid">
    <xsl:attribute name="name">
        <xsl:value-of select="."/>
    </xsl:attribute>
</xsl:template>

<!-- To prevent an attribute from being copied -->
<xsl:template match="Link/@unused-attribute"/>

<!-- etc. etc. ;-) -->

Regards,

Nikolai Grigoriev
RenderX



 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.