![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - RE: XSL to Combine attributes from two nodes [Thread Next] Re: XSL to Combine attributes from two nodesTo: 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 > > | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
