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

Stylesheet lists values [Was Re: Stylesheet listing element

Subject: Stylesheet lists values [Was Re: Stylesheet listing elements and attributes]
From: Miloslav Nic <nicmila@xxxxxxxxx>
Date: Wed, 29 Nov 2000 11:44:37 +0100
stylesheet lists
 <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
version =
"1.0" > 
   <xsl:output method="text"/>

   <xsl:key name="elements" match="*" use="name()"/>
   <xsl:key name="attributes" match="@*"
use="concat(name(parent::*),':::',name())"/>
   <xsl:key name="allSameAttributes" match="@*" use="name(parent::*)"/>


   <xsl:template match = "*" > 
     <xsl:if test="generate-id() = generate-id(key('elements',name()))">
       <xsl:text>&#xA;</xsl:text>
       <xsl:value-of select="name()"/>
       <xsl:apply-templates select="key('allSameAttributes',name())"/>
     </xsl:if>
     <xsl:apply-templates/>
   </xsl:template> 

   <xsl:template match="@*">

     <xsl:if test="generate-id() =
generate-id(key('attributes',concat(name(parent::*),':::',name())))">
       <xsl:text>&#xA;     </xsl:text>
       <xsl:value-of select="name()"/>
       <xsl:text>: </xsl:text>
       <xsl:apply-templates
select="key('attributes',concat(name(parent::*),':::',name()))"
mode="values"/>
     </xsl:if>
   </xsl:template>

   <xsl:template match="@*" mode="values">
     <xsl:variable name="sameValues" 
       select="key('attributes',concat(name(parent::*),':::',name()))[.
= current()]" />

       <xsl:if test="generate-id() = generate-id($sameValues)">
	 <xsl:value-of select="."/>
	 <xsl:text>(</xsl:text>
	 <xsl:value-of select="count($sameValues)"/>
	 <xsl:text>) </xsl:text>
       </xsl:if>

   </xsl:template>

   <xsl:template match="text()"/>
 </xsl:stylesheet> 



Sebastian Rahtz wrote:
> 
> Miloslav Nic writes:
>  > Inspired by your mail:
> 
> thanks, very interesting; you worked along similar lines to my (failing)
> stylesheet. BUT
> 
>  a) it does not work with Saxon. I *only* get the list of elements,
>     no list of attributes. curiously, Xalan does give me the
>     attributes, so either Saxon or Xalan has a bug understanding
> 
>      <xsl:key name="allSameAttributes" match="@*" use="name(parent::*)"/>
> 
>    which, I agree, ought to work. Perhaps Mike Kay could comment on that?
> 
>  b) how about a list of the different values for each
>  attribute... what I really want to see is something like
> 
>    p
>     rend: green (2), left (1)
>     type: warning (3)
>    note
>     place: margin (10), foot (12)
>    xptr
>     type: transclude (43)
>     url: www.tug.org (1), www.microsoft.com (1)
> 
> where the numbers are the counts for each occurrence of that value for
> that attribute for that element.
> 
> sebastian
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

-- 
******************************************
<firstName> Miloslav </firstName>    
<surname>   Nic      </surname>     

<mail>    nicmila@xxxxxxxxx    </mail>   
<support> http://www.zvon.org  </support>
<zvonMailingList> 
    http://www.zvon.org/index.php?nav_id=4 
</zvonMailingList>


 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.