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

Re: grouping probs

Subject: Re: grouping probs
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 16 Sep 2002 17:49:06 +0100
deep equal xslt
Hi Laura,

> The reason why i want to generalize is because i have around 100
> elements in my source XML , which have to be unique..as i described.

That's a monster markup language!

> so i cant actually go around naming each and every element.so i thot i shud 
> have a generalized way of doing this.
> Ok.. taking your advice, I want to try the XSLT2 way..as i agree that the 
> two pass method is quite tedious..
> I however have got no clue about XSLT2.. How do i start it? what jar files 
> do i need? I am using XALAN right now. and editor is XSelerator.

I *was* recommending XSLT 2.0 on the basis of wanting a less tedious
way of finding duplicate values than using the Muenchian method. I was
thinking that you could use xsl:for-each-group to identify the
distinct values for each element, but this would still require you to
specify the way in which you determined identity for each of your
element types, and with 100 element types I can see why you wouldn't
want to do that. However, you can use the deep-equal() function in
XPath 2.0 to do what you want...

The only processor that supports XSLT 2.0 right now is Saxon (version
7.2 currently). You can get it from http://saxon.sourceforge.net. I
am not sure whether it supports deep-equal() yet, but you could
try something like:

<xsl:template match="node() | @*">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()" />
  </xsl:copy>
</xsl:template>

<xsl:template match="*">
  <xsl:if test="not(preceding-sibling::*[deep-equal(., current())])">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()" />
    </xsl:copy>
  </xsl:if>
</xsl:template>

If you don't want to use Saxon or Saxon doesn't support deep-equal(),
the algorithm for the deep-equal() function is available at

  http://www.w3.org/TR/xquery-operators/#func-deep-equal

You should be able to create equivalent XSLT templates; if you need
help with that let us know.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.