XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Italo Giovani StefaniSubject: Creating duplicated KEY
Author: Italo Giovani Stefani
Date: 27 Oct 2006 10:46 AM
Originally Posted: 27 Oct 2006 10:44 AM
Hi, I have the following XSLT where I create anew element called 'action-declaration', with the name as key

<xsl:key name="keyAction" match="action-declaration" use="@name"/>

<xsl:if test="$actv-i and not(key('keyAction',$actv-i))">
<xsl:element name="action-declaration">
<xsl:attribute name="name">
<xsl:value-of select="$actv-i"/>
</xsl:attribute>
</xsl:element>
</xsl:if>

Thi add new action-declaration in a <actions> element. Everything goes well, if there already is an action with the same name the XSLT doesn't create another, but this code is inside a xsl:for-each where I get new actions names from another XML. If tehre is duplicated name in this 'list' the code duplicate the action name (the key).

Some advice??

Thanks.

Posttop
James DurningSubject: Creating duplicated KEY
Author: James Durning
Date: 27 Oct 2006 01:51 PM
Problem of uniqueness of new keys:
I suggest using a technique called Muenchian grouping: (http://www.jenitennison.com/xslt/grouping/muenchian.html) which allows you to get each of the unique values for the new action-declarations.

Would need to see your code to customize it, but it'd look someone like this:
<xsl:key name="newActions" match="newAction" use="@name"/>

<xsl:for-each select="newAction[count(. | key('newActions', @name)[1]) = 1]">
<xsl:if test="$actv-i and not(key('keyAction',$actv-i))">

In particular, the for-each loop and the creation of the variable $actv-i would affect the solution.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.