At 2003-09-13 20:01 -0500, SANWAL, ABHISHEK (HP-Houston) wrote:
(ROUGH SKETCH):
<xsl:variable name="MatrixColWidths">
<xsl:
<xsl:variable name="'1'" select="100"/>
<xsl:variable name="'2'" select="200"/>
<xsl:variable name="'3'" select="300"/>
<xsl:variable name="'4'" select="400"/>
</xsl:variable>
The above is meaningless. A variable's scope is its following siblings and
their descendents. Also, variables must be named with proper XML names
(and may even be qualified in a namespace).
Or like this ( as shown on DPawsons FAQ as picked up from )
- http://www.biglist.com/lists/xsl-list/archives/200004/msg00714.html
(Also the example test.xsl and class.xsl don't seem to work for me.. to
even test it out.. anyone suggest any fixes so I can see how it works)
<xsl:variable name="MatrixColWidths">
<c colno="1" colw="100"/>
<c colno="2" colw="75"/>
<c codno="3" colw="80"/>
<c codno="4" colw="75"/>
</xsl:variable>
The above is fine in global scope, because one can use the document()
function to get at the fixed value.
so that I can pick up the values for the COLUMN WIDTHS for ANY and EVERY
"Matrix or Table" in that Section by iterating through that array or
whatever other structure/variable I can use (xsl or non-xsl namespace)
but LOCAL to the Section.
You *cannot* get at such a local run-time definition using XSLT 1.0. Using
a vendor-supplied node-set() function, or XSLT 2.0, you can access a
variable of node sets.
I don't really care how this is done as I am not sure if I can define
any such structure, keep it local as well as be able to ITERATE through
it to pull values.
Not in XSLT 1.0 ... you cannot define a result tree fragment in a template
and then access it with XPath. In XSLT 1.0 XPath will only access the
source node tree. You can have it access the global-scope result tree
fragments of a stylesheet by opening up the stylesheet *as* a source file,
by using the document() function.
Any genius solve this one ?? :)
I ve been trying to abstract this problem out to the list but have been
getting nowhere.
I get the feeling you are repeatedly trying to apply programming concepts
to a templating language. Certainly XSLT 1.0 is Turing complete, but there
are restrictions on data types and the use of XPath. XPath can *only* be
used on the source node tree. The only way around this is to use a vendor
extension or use XSLT 2.0.
Please don't try to treat XSLT 1.0 as a general-purpose programming
language, or you will, indeed, get nowhere.
As I said in my last post, the idea in XSLT 1.0 is to revisit the source
node tree any time you need a value. In your column width calculations,
you will be doing some calculation to evaluate each of your widths ... just
redo those calculations when you need the values again.
There are *no* array-like data types in XSLT 1.0 or XPath 1.0 ... so you
will have to follow the language to get what you want.
I hope this helps to make these principles clear to you.
.......................... Ken
--
Next public European delivery: 3-day XSLT/2-day XSL-FO 2003-09-22
Next public US delivery: 3-day XSLT/2-day XSL-FO 2003-10-13
Instructor-led on-site corporate, government & user group training
for XSLT and XSL-FO world-wide: please contact us for the details
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6 Definitive XSLT and XPath
ISBN 0-13-140374-5 Definitive XSL-FO
ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners: http://XMLGuild.info
Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list