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

RE: Re: whats the best way to create and use values fo

Subject: RE: Re: whats the best way to create and use values for lookup (key-value) such that you can loop through it with limits
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 15 Sep 2003 12:17:06 -0400
hard code value
Abhishek,

For reasons explained by Ken, I don't think your solution will work the way you are describing; but I'm not sure you need the control over the scope of variables you say you require.....

At 08:58 PM 9/13/2003, you wrote:
Now my document has various chapters which have various sections where a
given section can have any number of matrices (matrix) and/or
paragraphs.

Now in the XSL for this I need to be able to HARD-CODE certain values
INTO A SECTION  that are to be used by all INNER TEMPLATES (namely,
Matrix, Paragraph, Items, SubItems etc.) ( But are NOT accessible to
other section matches

By this, do you mean hard-code these values into your source document, or into your stylesheet?


If into your source document, then each section would contain a particular set of nodes providing the parameters you want. So a section could look like:

<section SectionHeading='MySectionSomething1'>
<table-params>
  <col which="MC1Width">30</col>
  <col which="MC2Width">40</col>
  <col which="MC3Width">25</col>
  <col which="MC4Width">50</col>
  <col which="MC5Width">70</col>
</table-params>

Then in your stylesheet, the values are accessible from any template, given an XPath. So inside a table, you could always retrieve ancestor::section[1]/table-params/col[@which=$colName] ... or you can first bind ancestor::section/table-params/col to a variable colSpecs and then ask for $colSpecs[@which=$colName]....

If you want these values to be in the stylesheet, then use the lookup table technique Dimitre demonstrated....

<my:table-specs>
  <section SectionHeading='MySectionSomething1'>
    <col which="MC1Width">30</col>
    <col which="MC2Width">40</col>
    <col which="MC3Width">25</col>
    <col which="MC4Width">50</col>
    <col which="MC5Width">70</col>
  </section>
  <section SectionHeading='MySectionSomething2'>
    ....
  </section>
</my:table-specs>

Binding my:table-specs to a variable

<xsl:variable name="table-specs" select="document('')/*/my:table-specs"/>

You can always say

$table-specs[@SectionHeading=current()/ancestor::Section[@SectionHeading]/col[@which=$colName]

I hope that helps. Many times "parameterizing" something in XSLT doesn't actually require formal parameters or variables -- it's just retrieving node values (but those values have to be in a tree somewhere, or calculable).

Cheers,
Wendell


====================================================================== 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



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.