|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: REQUIRED vs. IMPLIED attributes
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








