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

Re: unique elements from different sourcefile

Subject: Re: unique elements from different sourcefile
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 03 Jan 2002 10:04:19 -0500
xslt unique elements
At 2002-01-03 14:31 +0100, Thomas Winkler wrote:
i'm really having a hard time figuring this little problem. because of
simplicity and performance i used the muench method for finding unique
elements and whatever else i needed. but this one just doesn't work for

I think because you need local scope for grouping.

all i want is getting all possible children of a specific element. since
the content model of some elements can be very complicated (such as
"head"), most xpath axis don't work.

I see you are looking for unique descendents of each element ... I see that as a grouping within scope problem as well as the other post today (is it me, or does everything look like a nail today?).

i think i have to use at least two for loops,

No, I think you just have to scope your grouping within the apex of what you need to be grouped.

what do my xsl:key and xsl:for-each(s) have to look like. i tried many
things, i just don't want to write here.

I wouldn't use keys here, I again see this as a "grouping with variables" problem.

I hope the code below helps.

.................... Ken

U:\utemp\winkler>type winkler.xml <dtd> <element name="head" content-type="element"> <content-model-expanded> <sequence-group> <or-group occurrence="*"> <element-name name="meta"/> <element-name name="link"/> <element-name name="object"/> </or-group> <or-group> <sequence-group> <element-name name="title"/> <or-group occurrence="*"> <element-name name="meta"/> <element-name name="link"/> <element-name name="object"/> </or-group> <sequence-group occurrence="?"> <element-name name="base"/> <or-group occurrence="*"> <element-name name="meta"/> <element-name name="link"/> <element-name name="object"/> </or-group> </sequence-group> </sequence-group> <sequence-group> <element-name name="base"/> <or-group occurrence="*"> <element-name name="meta"/> <element-name name="link"/> <element-name name="object"/> </or-group> <sequence-group> <element-name name="title"/> <or-group occurrence="*"> <element-name name="meta"/> <element-name name="link"/> <element-name name="object"/> </or-group> </sequence-group> </sequence-group> </or-group> </sequence-group> </content-model-expanded> </element> </dtd>

U:\utemp\winkler>type winkler.xsl
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

<xsl:output indent="yes"/>

<xsl:template match="/*">
  <xsl:for-each select="element">
    <xsl:sort name="@name"/>
    <element name="{@name}">
      <xsl:variable name="all-children" select=".//element-name"/>
      <xsl:for-each select="$all-children">
        <xsl:sort name="@name"/>
        <xsl:if test="generate-id(.)=
          <child-element name="{@name}"/>


U:\utemp\winkler>xt winkler.xml winkler.xsl
<?xml version="1.0" encoding="utf-8"?>
<element name="head">
<child-element name="meta"/>
<child-element name="link"/>
<child-element name="object"/>
<child-element name="title"/>
<child-element name="base"/>

-- Training Blitz: 3-days XSLT/XPath, 2-days XSLFO - Feb 18-22, 2002

G. Ken Holman                mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.         http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
ISBN 0-13-065196-6                        Definitive XSLT & XPath
ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
ISBN 1-894049-07-1               Practical Formatting Using XSLFO
XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed),
articles, training(instructor-live,Internet-live,web/CD,licensed)
Next public training:   2002-01-10,11,16,18,02-11,12,13,15,18,21,
-                                03-11,14,15,18,19,04-08,09,10,12

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

Current Thread


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.
First Name
Last Name
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.