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

RE: RE: RE: RE: Need to use generate-id() or other met

Subject: RE: RE: RE: RE: Need to use generate-id() or other method?
From: cknell@xxxxxxxxxx
Date: Fri, 25 Apr 2003 11:03:20 -0500
.met files
> -----Original Message-----
> From:     "Kathy Burke" <Kathy_Burke@xxxxxxxxx>
> Subject:  RE: RE: RE:  Need to use generate-id() 
> or other method?

I've looked over your template. If I understand what you are doing with it, it looks like you want to identify each step with a multi-level number. A step may be decomposed into smaller steps with the smaller steps being numbered as part of the hierarchy. That is to say, there may exist a "step 1" which is composed of sub-steps 1.1, 1.2, 1.3, etc. And this pattern may continued down through an arbitrary number of levels.

The step elements in the XML file have no unique indentifiers, that's why you are using the <xsl:number> element to output a unique number for each step.

Each step is expressed as a single row in the output HTML table. Sub-steps are visually represented by altering the width of the cell based on the number of ancestors the step represented in the cell has. Sub-steps are produced by calling the step template recursively.

If these things are true, I recommend that you modify your template this way.:

Instead of outputting the number created by the <xsl:number> element directly, I suggest that you capture it to a variable. You can then place it in the table division with an <xsl:value-of select="$var" />. You will further want to add an <xsl:parameter> element to the step template which will receive the value of $var when the template is called recursively. That way you can concatenate the value of $var from the calling template with the value of the variable generated with each recursive call to produce a unique "id" attribute for each button.

I took a simple hierarchical menu XML file I have and made an XSLT along the lines I've suggested which will produce HTML to demonstrate the technique. My output consists of nested <div> elements rather than nested tables, but the differences should be minor.

XML file
================================================================
<?xml version="1.0" encoding="UTF-8" ?>
<menu>
   <item title="ABC">
      <item uri="http://www.domain.com#books">Library Home</item>
      <item uri="">Phone Directories</item>
      <item uri="">Acquisition Policy</item>
      <item uri="">Publications</item>
      <item uri="">Directives</item>
      <item uri="">HQ Offices</item>
      <item uri="">Links Library</item>
      <item uri="">Policy</item>
      <item uri="">Program Documents</item>
   </item>
   <item type="menu" title="DEF">
      <item uri="http://www.domain.com#books">Library Home</item>
      <item uri="">Phone Directories</item>
      <item uri="">Acquisition Policy</item>
      <item uri="">Publications</item>
      <item uri="">Directives</item>
      <item uri="">HQ Offices</item>
      <item uri="">Links Library</item>
      <item uri="">Policy</item>
      <item uri="">Program Documents</item>
      <item title="Warner Bros.">
         <item uri="">Foghorn Leghorn</item>
         <item title="Elmer Fudd">
            <item uri="">Ride of the Valkyries</item>
            <item uri="">Il Trovatore</item>
         </item>
         <item uri="">Daffy Duck</item>
      </item>
   </item>
   <item uri="">Bugs Bunny</item>
</menu>

XSLT file
================================================================
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="html" indent="yes" encoding="UTF-8" />
   <xsl:strip-space elements="*" />

   <xsl:template match="/menu">
      <div id="menu">
         <xsl:apply-templates />
      </div>
   </xsl:template>

   <xsl:template match="item">
      <xsl:param name="parent-id" select="''" />
      <xsl:variable name="id">
         <xsl:number level="multiple" count="item" format="1.1"/>
      </xsl:variable>
      <div id="{$parent-id}{substring($id, 1, string-length($id)-1)}">
         <xsl:apply-templates>
            <xsl:with-param name="parent-id" select="$id" />
         </xsl:apply-templates>
      </div>
   </xsl:template>

</xsl:stylesheet>

-- 
Charles Knell
cknell@xxxxxxxxxx - email


 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.