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

Re: can you select name() of attributes?

Subject: Re: can you select name() of attributes?
From: "Ragulf Pickaxe" <jawxml@xxxxxxxxxxx>
Date: Tue, 27 Jul 2004 10:38:08 +0000
select name
Hi David,

I got somewhat the same solution, but then I run into a different problem, which is why I want to use it as a nodeset. The ones in the input document (let us say $ Doc1) must be in $Doc2, but if they are not in $Doc1, then the (default) value in $Doc2 should be used.


<xsl:variable name="Attr1" select="$Doc1/@*"/>
<xsl:variable name="Attr2" select="$Doc2/@*"/>

<xsl:for-each select="$Attr2">
<xsl:variable name="Attr" select="."/>
<xsl:if test="not($Attr1)">
<xsl:attribute name="{name($Attr)}"><xsl:value-of select="$Attr"/></xsl:attribute>
</xsl:if>
<xsl:for-each select="$Attr1[name()=name($Attr)]">
<xsl:choose>
<xsl:when test="name()=name($Attr)">
<xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="{name($Attr)}"><xsl:value-of select="$Attr"/></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>


This works if there are no attributes in $Doc1 (if-sentence takes care of that) but if some of the attributes are in $Doc1, then the attributes - by nature of being nested in two for-each loops - will be overwritten (same name), ending in the last iteration creating the output.

Is there something else I can do?

Unfortunately I do not have access to a version which uses XSLT2, and I do not know if MK's solution would work in my case anyway (same problem as above).

Thank you for your time
Ragulf Pickaxe :-)

_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail


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.