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

Transforming elements into attributes

Subject: Transforming elements into attributes
From: "Daniel Joshua" <daniel.joshua@xxxxxxxxxxxx>
Date: Fri, 30 Apr 2004 15:18:12 +0800
transforming xml elements into attributes
Hi,

Is there a nice 'readable' way to transform elements into attributes?

Currently, I need to copy and paste for each one.

XSL:

  <xsl:template match="form">
    <form>
      <xsl:if test="@name">
        <xsl:attribute name="name">
          <xsl:value-of select="name"/>
        </xsl:attribute>
      </xsl:if>
      <xsl:if test="@action">
        <xsl:attribute name="action">
          <xsl:value-of select="action"/>
        </xsl:attribute>
      </xsl:if>
      <xsl:if test="@method">
        <xsl:attribute name="method">
          <xsl:value-of select="method"/>
        </xsl:attribute>
      </xsl:if>
      <xsl:apply-templates/>
    </form>
  </xsl:template>

XML:

  <form>
    <name>form</name>
    <url>submit.do</url>
    <method>post</method>
    <content>
      ...
    </content>
  </form>


Regards,
Daniel

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.