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

Re: Data structure in XSLT?

Subject: Re: Data structure in XSLT?
From: Charles Chan <charles_cynthia@xxxxxxxxx>
Date: Wed, 24 Apr 2002 09:50:25 -0700 (PDT)
xslt data structure
Wow! You opened my eyes!

Thanks,
Charles


--- Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> wrote:
> Charles,
> 
> You can't use a hash map (the data model doesn't
> include such a thing) but 
> you can use a key, which is almost the same thing
> (or can be made to work 
> that way anyway):
> 
> <xsl:key name="competencies-by-category"
> match="competency" 
> use="substring-before(Competency/@id, ':')"/>
> 
> The value of the key for each Competency is thus
> "programming_language", 
> "application_server" etc.
> 
> Then:
> 
> <xsl:template match="Competency">
>    <xsl:variable name="this-category"
> select="substring-before(@id, ':')"/>
>    <xsl:if
> test="count(.|key('competencies-by-category', 
> $this-category)[1])=1">
>    <!-- the test uses an idiom to test node
> identity, throwing away Competency
>         elements after the first in every category
> -->
>      <xsl:value-of
> select="$this-category"/>:
<xsl:text/>
>      <xsl:for-each
> select="key('competencies-by-category',
> $this-category)">
>      <!-- now we go get all the Competency elements
> in this category and 
> list em -->
>        <xsl:if test="position()!=1">
>           <!-- no comma before the first -->
>           <xsl:text>, </xsl:text>
>        </xsl:if>
>        <xsl:value-of select="substring-after(@id,
> ':')"/>
>      </xsl:for-each>
>    </xsl:if>
> </xsl:template>
> 
> The code assumes that you never have more than one
> ':' in an @id. Also, 
> de-duplicating is left as an exercise.
> 
> Cheers,
> Wendell
> 
> At 01:17 PM 4/23/2002, you wrote:
> >Hi, is there anyway to build some data structure in
> >XSLT? I have a sample input file that looks like
> this:
> >
> ><Qualifications>
> >   <Competency name="Java">
> >     <Competency id="programming_language:java"/>
> >   </Competency>
> >   <Competency name="C++">
> >     <Competency id="programming_language:cpp"/>
> >   </Competency>
> >   <Competency name="C#">
> >     <Competency id="programming_language:csharp"/>
> >   </Competency>
> >   <Competency name="WebLogic">
> >     <Competency id="application_server:weblogic"/>
> >   </Competency>
> >   <Competency name="WebSphere">
> >     <Competency
> id="application_server:websphere"/>
> >   </Competency>
> ></Qualifications>
> >
> >The output I want is:
> >
> >programming_language:
> >Java, C++, C#
> >
> >application_server:
> >WebLogic, WebSphere
> >
> >The Competency elements can be in any order. I was
> >thinking it would be nice if I have the luxury to
> use
> >a hash map or something like that.
> >
> >Any idea?
> >
> >Thanks
> >Charles
> 
> 
>
======================================================================
> Wendell Piez                           
> mailto:wapiez@xxxxxxxxxxxxxxxx
> Mulberry Technologies, Inc.               
> http://www.mulberrytech.com
> 17 West Jefferson Street                    Direct
> Phone: 301/315-9635
> Suite 207                                         
> Phone: 301/315-9631
> Rockville, MD  20850                                
> Fax: 301/315-8285
>
----------------------------------------------------------------------
>    Mulberry Technologies: A Consultancy Specializing
> in SGML and XML
>
======================================================================
> 
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.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.