[xsl] Automatically copying an element's attributes and their values

Subject: [xsl] Automatically copying an element's attributes and their values
From: Mary McRae <marymcrae@xxxxxxxxxxxxx>
Date: Sun, 07 Sep 2003 16:11:06 -0400
I would like to pass through attributes and their
values without having to a) test to see if the
attribute has a value specified, and b) explicitly
output the value.

This is the code I'm currently using:

	<xsl:template match="ns0:para"
			<xsl:when test="@id">
<w:pStyle w:val="Blockindent"/>
<xsl:apply-templates mode="para"/>
<w:pStyle w:val="Blockindent"/>
<xsl:apply-templates mode="para"/>

I tried using the code submitted by Mike Brown in
Dave Pawson's FAQ:

	<xsl:for-each select="@*">
      	<xsl:attribute name="name()">
			<xsl:value-of select="."/>
... Remainder of template

But using MSXML 3.0 in XMLSpy and Xselerator I got
an error "This name may not contain the '('
character: name-->(<--); if I use the default XSLT
processor in XMLSpy I don't get an error, but the
attributes do not appear in my result file. The
final transform will end up being performed using

It should also be noted that my source instance
does not contain namespace prefixes (i.e.
<para>asd;fljk adsflkjsda f</para>
<para id="1234">adlfkj</para>)

Thanks in advance,


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

Current Thread