This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Copying Groups of Attributes


Hi Ciaran,

> (At the moment) In my XSL if I want to copy across attributes only if they
> exist 

<xsl:copy-of select="@*" />
Or am I thinking too simple?

> I have
> the following template:
> 
> <xsl:template match="p">
> 	<p>
> 		<xsl:if test="@id">
> 			<xsl:attribute name="align"><xsl:value-of 
select="@id"/></xsl:attribute>
> 		</xsl:if>
> 		<xsl:if test="@class">
> 			<xsl:attribute name="align"><xsl:value-of
> select="@class"/></xsl:attribute>
> 		</xsl:if>
> 		....... and so on for the rest of the attributes
> 	</p>
> </xsl:template>

Well, I don't understand why you're creating align attributes ...
A typo?

If explicitely want to copy only certain attributes, then you could
use something like
<xsl:copy-of select="@id | @class" />

Excluding attributes is a little bit trickier
<xsl:copy-of select="@*[name()!='unwanted' and name()!='dislike']" />
(Assuming you don't have prefixed attributes in a different namespace.)

Hope that helps,
Oliver


/-------------------------------------------------------------------\
|  ob|do        Dipl.Inf. Oliver Becker                             |
|  --+--        E-Mail: obecker@informatik.hu-berlin.de             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]