Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XSL to Combine attributes from two nodes

From: "jakistra" <jake319@-----.--->
To: NULL
Date: 12/8/2006 6:20:00 AM

Thank you Erwan!  That did the trick... the attributes are combined.

There is an oddity with the transformed XML.  It has a automated
namespace prefiexed to the attribute name (auto-ns1) like so:

<s auto-ns1:Number=3D"21002" auto-ns1:Name=3D"North"
auto-ns1:DateLoaded=3D"2006-11-28">

I can work around it, but wonder if there's an easy way to prevent the
prefix?

Thanks for your help!!
J=2E

Erwan Amoureux wrote:
> the probleme is the xpath here
>
> <xsl:attribute name=3D"DateLoaded">
> <xsl:value-of select=3D"u[@DateLoaded]"/>
> </xsl:attribute>
>
> 1- Don't forget xml/spath is case sensitive
>
> there is a tag U but not tag u
>
> 2- here you select the u element with a DateLoaded attribute not the
> DateLoaded attibute
>
> try this
> <xsl:attribute name=3D"DateLoaded">
> <xsl:value-of select=3D"U/@DateLoaded"/>
> </xsl:attribute>
> --
> My english is (very) rusted ,please , don''''t hesitate to correct me
> Thanks
>
> r=E9dacteur/mod=E9rateur xml sur developpez.com
>
>
> "jake319@g..." wrote:
>
> > 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=3D"1.0" encoding=3D"utf-8" ?>
> > <S Number=3D"21002" Name=3D"North" State=3D"Georgia" >
> >    <U DateLoaded=3D"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=3D"21002" Name=3D"North" State=3D"Georgia" DateLoaded=3D"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=3D"root">
> > 	<xsl:element name=3D"root" namespace=3D"http://tempuri.org/root.xsd">
> > 		<xsl:apply-templates/>
> > 	</xsl:element>
> > </xsl:template>
> >
> > <xsl:template match=3D"S">
> > 	<xsl:element name=3D"s" use-attribute-sets=3D"sAttributes" />
> > </xsl:template>
> >
> > <xsl:attribute-set name=3D"sAttributes">
> > 	<xsl:attribute name=3D"Number">
> > 		<xsl:value-of select=3D"@Number"/>
> > 	</xsl:attribute>
> > 	<xsl:attribute name=3D"Name">
> >    	        <xsl:value-of select=3D"@Name"/>
> > 	</xsl:attribute>
> > 	<xsl:attribute name=3D"DateLoaded">
> > 	        <xsl:value-of select=3D"u[@DateLoaded]"/>
> > 	</xsl:attribute>
> > 	<xsl:attribute name=3D"State" >
> >    	       <xsl:value-of select=3D"@State"/>
> > 	</xsl:attribute>
> > </xsl:attribute-set>
> >=20
> > Thanks for your help.
> > J
> >=20
> >



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