Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Problem updating an attribute that appears in both root node and child node!

From: Tedros.G@----------.---
To: NULL
Date: 5/8/2007 4:12:00 AM

Hi
I have an attribute the appears in both the root node and child node
for example, below the attribute VERSION appears in the rood node
(PRODMSG ) and a child node (OPERATION )
================
INPUT XML
================
<?xml version="1.0" encoding="utf-16"?>
<PRODMSG VERSION="1.2" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
ID="00051004_20070503024353">
  <HEADER>
    <OPERATION NAME="PRICE"  VERSION="1.2">
      <USERNAME>SMITGHJ</USERNAME>
      <HOSTNAME>00051004</HOSTNAME>
      <DATETIME>2007-05-03T01:30:16.710</DATETIME>
    </OPERATION>
  </HEADER>
</PRODMSG>

However all I want to do is update the root node (PRODMSG) VERSION
attribute to 2.0 but leave the child node version untouched. Problem
is if I select the PRODMSG and it's attributes and update the version
to 2.0

        .......
	<xsl:template match="@VERSION|PRODMSG">
			<xsl:attribute name="VERSION">2.0</xsl:attribute>
	</xsl:template>
       ......

I get nothing but if I do this .......

================
TRANSFORM
================

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/
>
	<xsl:template match="/">
		<xsl:apply-templates/>
	</xsl:template>

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

	<!--UPDATE the version number to 2.0 -->
	<xsl:template match="@VERSION">
			<xsl:attribute name="VERSION">2.0</xsl:attribute>
	</xsl:template>
</xsl:stylesheet>


I get the following output (ALL the versions are updated to 2.0) .

================
OUTPUT XML
================
<?xml version="1.0" encoding="utf-16"?>
<PRODMSG VERSION="2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
ID="00051004_20070503024353">
  <HEADER>
    <OPERATION NAME="PRICE"  VERSION="2.0">
      <USERNAME>SMITGHJ</USERNAME>
      <HOSTNAME>00051004</HOSTNAME>
      <DATETIME>2007-05-03T01:30:16.710</DATETIME>
    </OPERATION>
  </HEADER>
</PRODMSG>



Please can you tell me what I am doing wrong....

Thank you
Ted



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent