[xsl] Réf. : Re: [xsl] Réf. : RE : [xsl] XML tags to XML attributes with XSL

Subject: [xsl] Réf. : Re: [xsl] Réf. : RE : [xsl] XML tags to XML attributes with XSL
From: lbertin@xxxxxxxxxxxx
Date: Thu, 23 Oct 2003 07:46:24 +0200

I'm sure of that, but i may have typed it the wrong way.

If the xml is :

<message att1="a" att2="b" att3="c">...</message>

I would have get, using copy of :

abc<message att1="a" att2="b" att3="c">...</message>

Which is kind of strange :)


                    Wendell Piez                                                                                                 
                    <wapiez@xxxxxxxxxxxxxxxx>          Pour :  xsl-list@xxxxxxxxxxxxxxxxxxxxxx                                   
                    Envoyé par :                       cc :                                                                      
                    owner-xsl-list@xxxxxxxxxxxx        Objet :      Re: [xsl] Réf. : RE : [xsl]  XML tags to  XML attributes     
                    rytech.com                         with XSL                                                                  
                    22/10/2003 17:14                                                                                             
                    Veuillez répondre à                                                                                          


Jarno suggested using xsl:copy-of, and you reported it placed the value of
your attribute into element content.

Are you sure you said copy-of, not value-of? xsl:value-of would give the
result you reported, but xsl:copy-of would (as Jarno said) copy the
attribute as an attribute (not place its value into the content).

At 04:50 AM 10/22/2003, you wrote:
><xsl:template match="* | @*">
>      <xsl:copy>
>           <xsl:apply-templates select="Attributes"/>
>           <xsl:apply-templates select="* | @* | text()"/>
>      </xsl:copy>
>and it seems to work now.

This works because you are selecting attributes (select="@*") and also
matching them with the same template, which copies them.

The line <xsl:apply-templates select="Attributes"/> is, however, spurious.
It's not doing anything at all, since you don't have any child elements
named "Attributes" -- and if you did, it would break your stylesheet and
your actual attributes would fail to be copied, since they are being copied

by the next instruction <xsl:apply-templates select="* | @* | text()"/>,
and you can't add attributes to an element node after other things have
been placed in its content (as would presumably happen if you had element
children named "Attributes").

So you probably want to delete that line (try it; it will still work) ...
and maybe go back to Jarno's idea as it's a bit tighter (albeit a little
less adaptable).


Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
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

Current Thread