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

[no subject]

From: menkell@xxxxxxxxxx
Date: Thu, 17 Feb 2000 14:23:40 -0600
input datafld
I am trying to add an attribute to my xml document but when I try to copy
the existing elements and it's attributes it doesn't copy the attributes.
I know in the specification it says it will not copy the attributes.   Does
anyone know of am easy solution to my problem.


example xml file
<customer>
     <input dataFld="blue"/>
     <input dataFld="red"/>
<customer>


What I want my file to look like when it's done.

<customer>
     <input dataFld="blue"  label="My Favorite" format="lowerCase"/>
     <input dataFld="red" label="MyLeastFavorite"/>
<customer>




This is my output that adds the attribute I want but keep the dataFld
attribute.


<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="doc-file"/>

<xsl:template match="/">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>

<xsl:template match="customer">
     <xsl:copy>
     <xsl:for-each select="*">
       <xsl:value-of select="."/>
          <xsl:copy>
          <xsl:variable name="myKey" select="./@dataFld"/>
          <xsl:variable name="currentProperty"
select="document($doc-file)/locale/*[name()=$myKey]"/>
               <xsl:if test="$currentProperty">
                    <xsl:attribute name="{$currentProperty/@type}">
                     <xsl:value-of select="$currentProperty"/>
                    </xsl:attribute>

                </xsl:if>
          </xsl:copy>
     </xsl:for-each>
     </xsl:copy>
</xsl:template>
</xsl:stylesheet>


Thanks!


Laura L. Menke
IBMUSM07(menkell)
Phone 507-253-8901 Tie 5535907
 menkell@xxxxxxxxxx


When facing a difficult task, act as though it is impossible to fail. If
you're going after Moby Dick, take along the
          tartar sauce.



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.