Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Showing node-level members of a global set

Reply
Thread Tools

Showing node-level members of a global set

 
 
ion
Guest
Posts: n/a
 
      06-02-2006
Hi! I'm struggling with doing this in an elegant way -- I'll get my
XSLT books out of storage this weekend, but for now I could use some
help.
<bedknob>
<broomstick>
<bippity>boppity</bippity>
</broomstick>
<broomstick>
<bippity>boppity</bippity>
<bippity>boo</bippity>
</broomstick>
</bedknob>
I'd like to get the complete list of bippities, then compare the
bippities of each broomstick to them, and make a mark for each present
member of the complete set of bippities in a particular broomstick,
like
<table>
<thead>
<tr>
<th>boppity
</th>
<th>boo
</th>
</tr>
</thead>
<tbody>
<tr>
<td>X
</td>
<td>
</td>
</tr>
<tr>
<td>X
</td>
<td>X
</td>
</tr>
</tbody>
</table>

OK. So, I use a Muenchian sort to get the unique list of bippities for
the thead element, but then to do the rows in the body, I have to go
through it again, and check each member against the set of present
values. I'm thinking of something like taking the intersection and
looking for count() = 2, but I'm having trouble making it happen.

Can you help me?

Ion

 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      06-03-2006
Hi,

On Fri, 02 Jun 2006 21:54:32 +0200, ion <> wrote:

> Hi! I'm struggling with doing this in an elegant wayI'd like to get the
> complete list of bippities, then compare the
> bippities of each broomstick to them, and make a mark for each present
> member of the complete set of bippities in a particular broomstick,
> like



I have no idea if this will conform to your idea of elegance (it uses
plain dumb for-each loops), but this solution seems to work:

<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml" indent="yes"/>

<xsl:key name="b" match="bippity" use="."/>
<xsl:variable name="bip"
select="//*[generate-id()=generate-id(key('b',.)[1])]"/>

<xsl:template match="bedknob">
<table>
<thead>
<tr>
<xsl:for-each select="$bip">
<th><xsl:value-of select="."/></th>
</xsl:for-each>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="broomstick"/>
</tbody>
</table>
</xsl:template>

<xsl:template match="broomstick">
<xsl:variable name="this" select="bippity"/>
<tr>
<xsl:for-each select="$bip">
<td>
<xsl:if test=".=$this">X</xsl:if>
</td>
</xsl:for-each>
</tr>
</xsl:template>

</xsl:stylesheet>


regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Veni, vidi, wiki (http://www.wikipedia.org)
 
Reply With Quote
 
 
 
 
ion
Guest
Posts: n/a
 
      06-05-2006
Thanks, Joris, that works great.
Ion

Joris Gillis wrote:
> Hi,
>
> On Fri, 02 Jun 2006 21:54:32 +0200, ion <> wrote:
>
> > Hi! I'm struggling with doing this in an elegant wayI'd like to get the
> > complete list of bippities, then compare the
> > bippities of each broomstick to them, and make a mark for each present
> > member of the complete set of bippities in a particular broomstick,
> > like

>
>
> I have no idea if this will conform to your idea of elegance (it uses
> plain dumb for-each loops), but this solution seems to work:
>
> <xsl:stylesheet version="1.0"
> xmlnssl="http://www.w3.org/1999/XSL/Transform">
> <xslutput method="xml" indent="yes"/>
>
> <xsl:key name="b" match="bippity" use="."/>
> <xsl:variable name="bip"
> select="//*[generate-id()=generate-id(key('b',.)[1])]"/>
>
> <xsl:template match="bedknob">
> <table>
> <thead>
> <tr>
> <xsl:for-each select="$bip">
> <th><xsl:value-of select="."/></th>
> </xsl:for-each>
> </tr>
> </thead>
> <tbody>
> <xsl:apply-templates select="broomstick"/>
> </tbody>
> </table>
> </xsl:template>
>
> <xsl:template match="broomstick">
> <xsl:variable name="this" select="bippity"/>
> <tr>
> <xsl:for-each select="$bip">
> <td>
> <xsl:if test=".=$this">X</xsl:if>
> </td>
> </xsl:for-each>
> </tr>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
> regards,
> --
> Joris Gillis (http://users.telenet.be/root-jg/me.html)
> Veni, vidi, wiki (http://www.wikipedia.org)


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 1 10-25-2006 06:50 PM
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 0 10-25-2006 01:04 PM
Difference between static final members and final static members(if any)? JFCM Java 4 02-07-2006 11:32 AM
Templates: Members Vs. non-members Dave C++ 3 08-10-2004 11:23 AM
Can nested class members access private members of nesting class? CoolPint C++ 8 12-14-2003 02:30 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57