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

Re: Selecting non-duplicate nodes

Subject: Re: Selecting non-duplicate nodes
From: "Mark" <mark@xxxxxxxxxxxx>
Date: Wed, 12 Oct 2011 11:14:02 -0700
Re:  Selecting non-duplicate nodes
Hi Michael,
At the moment, Brandon's solution appears to be working. If after examining the output from my full data set I discover it has problems, I'll give your solution a try. By the way, your code contains XPath expressions I have never seen, so I will look those up in order to broaden my XPath repertoire.


Thanks for your help,
Mark

-----Original Message----- From: Michael M|ller-Hillebrand
Sent: Wednesday, October 12, 2011 11:01 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: Selecting non-duplicate nodes


Am 12.10.2011 um 17:33 schrieb Mark:

My question now is: how can I change this stylesheet so that for the listed input, no <FormatButtons> in the output contains more than one copy of a <Format> with the same attribute name and value? That is, where the current output is, for example:

<FormatPage souvenir-sheet="365">
 <FormatButtons>
   <Formats se-tenant="365"/>
   <Formats se-tenant="365"/>
   <Formats coupon="367"/>
   <Formats coupon="368"/>
 </FormatButtons>
</FormatPage>

Mark,


If a node in your sample is a duplicate of another node can be retrieved from the attribute names and their values. So IMO the grouping key could be a serialization of them. In other words, we look at the source as if we were a text processor, like this:

<xsl:template match="FormatButtons">
 <xsl:copy>
   <xsl:for-each-group select="Formats"
       group-by="string-join(
         for $i in 1 to count(@*)
           return concat(name(@*[$i]), '=', @*[$i]), ' ')">
     <xsl:apply-templates select="."/>
   </xsl:for-each-group>
 </xsl:copy>
</xsl:template>

In XML the order of attributes is usually irrelevant, but the above solution does not ignore order. But it works with any number of attributes.

- Michael M|ller-Hillebrand

--
_______________________________________________________________
Michael M|ller-Hillebrand: Dokumentation Technology
Adobe Certified Expert, FrameMaker
Consulting and Training, FrameScript, XML/XSL, Unicode
Blog [de]: http://cap-studio.de/

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.