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

Re: Transform all tags into attributes with some tags

Subject: Re: Transform all tags into attributes with some tags omitted
From: Michael Ludwig <mlu@xxxxxxxxxxxxx>
Date: Fri, 16 May 2008 09:24:58 +0200
Re:  Transform all tags into attributes with some tags
Philipp Kursawe schrieb:

name="item-element" /></xsl:for-each>

[...] I do not like the select statement for the tags. I would rather
like to describe the exceptions so that tag added in the future are
automatically added as attributes without changing the xslt.

Hi Philipp,

I'd use a special mode to the transform, which by default converts
elements to attributes and has exceptions in extra templates. Please
try and modify the following to suit your needs:

<xsl:stylesheet version="1.0"
  <xsl:template match="@*|node()"><!-- identity template -->
      <xsl:apply-templates select="@*|node()"/>
  <xsl:template match="item">
    <xsl:copy><!-- transform elements to attributes -->
      <xsl:apply-templates select="*" mode="attr"/>
  <xsl:template match="*" mode="attr"><!-- element to attribute -->
    <xsl:attribute name="{name()}">
      <xsl:value-of select="."/>
  <!-- exceptions to this rule go here -->
  <xsl:template match="MEINS | PACKGROESSE" mode="attr">
    <!-- dispatch to identity template -->
    <xsl:apply-templates select="."/>

Michael Ludwig

Current Thread


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.
First Name
Last Name
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.