Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XSL to Combine attributes from two nodes

From: jake319@-----.---
To: NULL
Date: 12/7/2006 2:41:00 PM

I have what seems like a simple XSL question.  I want to combine the
attributes of two different nodes together.  Here is some sample XML:
 <?xml version="1.0" encoding="utf-8" ?>
<S Number="21002" Name="North" State="Georgia" >
   <U DateLoaded="2006-11-28" ></U>
</S>

The goal is for the XML to look like so (really, just add the
DateLoaded attribute to <S>:

<S Number="21002" Name="North" State="Georgia" DateLoaded="2006-11-28">


Here is some XSL that is NOT adding the correct value for "DateLoaded"
to the result, rather, the value is blank:

<xsl:template match="root">
	<xsl:element name="root" namespace="http://tempuri.org/root.xsd">
		<xsl:apply-templates/>
	</xsl:element>
</xsl:template>

<xsl:template match="S">
	<xsl:element name="s" use-attribute-sets="sAttributes" />
</xsl:template>

<xsl:attribute-set name="sAttributes">
	<xsl:attribute name="Number">
		<xsl:value-of select="@Number"/>
	</xsl:attribute>
	<xsl:attribute name="Name">
   	        <xsl:value-of select="@Name"/>
	</xsl:attribute>
	<xsl:attribute name="DateLoaded">
	        <xsl:value-of select="u[@DateLoaded]"/>
	</xsl:attribute>
	<xsl:attribute name="State" >
   	       <xsl:value-of select="@State"/>
	</xsl:attribute>	
</xsl:attribute-set>

Thanks for your help.
J



transparent
Print
Mail
Digg
delicious
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