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

Transform all tags into attributes with some tags omit

Subject: Transform all tags into attributes with some tags omitted
From: "Philipp Kursawe" <phil.kursawe@xxxxxxxxx>
Date: Fri, 16 May 2008 08:46:50 +0200
 Transform all tags into attributes with some tags omit
Hi all!

I need to transform this rather verbose XML Output into a smaller more
compact, attribute based form. Also I do not need all tags, but wanna
be sure that, if in future a new CHECKDIGIT4 field will be added that
my XSLT is still transforming this new tag. I can use XSLT 2.0 or 1.0.
I have marked the fields I do not need from the source XML. Find below
the expected XML output.
   <VOLEH></VOLEH> <!-- NOT NEEDED -->
       <LGPLA>01 02 0</LGPLA>
       <CORRIDOR>01</CORRIDOR> <!-- NOT NEEDED -->
       <PLATZ> 02 0</PLATZ> <!-- NOT NEEDED -->
       <MEINS>ST</MEINS> <!-- NOT NEEDED -->
     ...more <item/>

The expected output should be looking like this:
  <ES_HEAD tanum="0000057779" qty_lines="0005" ../>
    <item tapos="0001" lgpla="01 02 0" ... />
    <item tapos="0002" lgpla="02 04 0" ... />

I have created this XSTL:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
        <xsl:output method="xml"/>

<xsl:template match="@*|node()">
<xsl:apply-templates select="@*|node()" />

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

<xsl:template name="item-element">
<xsl:attribute name="{name()}" ><xsl:value-of select="." /> </xsl:attribute>


However 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.

Thanks in advance,

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.