home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F26320_CustomerElemToAttr.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  1.0 KB  |  30 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       XMLtoXML
  4.   Sub-category:   ElemToAttr
  5.   Author:         David Silverlight
  6.                   HeadGeek@xmlpitstop.com
  7.   Created:        2001-05-16
  8.   Description:-
  9.     This stylsheet will convert an xml file that is
  10.     element-based to one that is attribute-based.  In this
  11.     stylesheet, the original customer elements will be
  12.     transformed to attributes.
  13. ================================================================ -->
  14. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:output method="xml"/>
  15.  
  16. <xsl:template match="/">
  17.     <xsl:element name="customers">
  18.         <xsl:for-each select="/customers/customer" >     
  19.             <xsl:element name='{name()}'> 
  20.                 <xsl:for-each select="*" > 
  21.             <xsl:attribute name='{name()}'> <xsl:value-of select="."/></xsl:attribute>
  22.         </xsl:for-each> 
  23.     </xsl:element>
  24.     </xsl:for-each>
  25. </xsl:element>
  26.  
  27. </xsl:template>
  28.  
  29.  
  30. </xsl:stylesheet>