ASP Error: 70
Description: Permission denied
Source: Microsoft VBScript runtime error

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

Re: XSL Template Match using z:row attributes

Subject: Re: XSL Template Match using z:row attributes
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 14 Dec 2001 11:46:35 +0000
xsl match key z row
Hi Mike,

> I'm trying to build a heirarchy based on the @LEVEL attrbiute in my
> input XML.

Actually, it looks as though you're trying to build a hierarchy based
on the CATEGORYID and PARENTID attributes of your z:row elements?

To do this, create a key that indexes all the z:row elements based on
their PARENTID:

<xsl:key name="rows-by-parent" match="z:row" use="@PARENTID" />

That means that if you do:

  key('rows-by-parent', 1)

you get all the z:rows whose PARENTID attribute has a value of 1, i.e.
all those z:rows whose parent has a CATEGORYID of 1.

You can then create a template that generates the output for a
particular row: a div element with a level attribute equal to the
value of its LEVEL attribute:

<xsl:template match="z:row">
  <div level="{LEVEL}">
    ...
  </div>
</xsl:template>

With the div containing the value of its CATEGORYNAME attribute:

<xsl:template match="z:row">
  <div level="{LEVEL}">
    <xsl:value-of select="@CATEGORYNAME" />
    ...
  </div>
</xsl:template>

Followed by whatever you get when you apply templates to its
'children'. You can find its 'children' using the key you just set up,
with the current row's CATEGORYID as the second argument:

<xsl:template match="z:row">
  <div level="{LEVEL}">
    <xsl:value-of select="@CATEGORYNAME" />
    <xsl:apply-templates
         select="key('rows-by-parent', @CATEGORYID)" />
  </div>
</xsl:template>

To start the process off, you need to apply templates to the first row
in the hierarchy. That's the row whose PARENTID is 0. So you can use:

<xsl:template match="rs:data">
  <xsl:apply-templates select="key('rows-by-parent', 0)" />
</xsl:template>

I hope that helps,

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.