Subject: RE: [xsl] Re: whats the best way to create and use values for lookup (key-value) such that you can loop through it with limits From: "SANWAL, ABHISHEK (HP-Houston)" <abhishek.sanwal@xxxxxx> Date: Mon, 15 Sep 2003 15:47:26 -0500 |
Wendell Dimitre I actually do need the control over the scope. I don't need strict control but since I will be "punching" in those values into <Section Specific Matches> of a Big XSL file where the Section calls all the other Smaller and functioning stylesheets with those values as parameters (with-param). Since there will be a number of such <SectionHeading Specific Matches> I would want "those punched" local values to be used. Of course, what Dimitre suggested was good. But at that point of time since document() was being used, I was thinking that this would only do global scope variables and wondering if there is a way to localize it. But, I think the following expression that you suggested makes me think that maybe I can use that expression to get the "local" values and use them there for the columns. (My thinking was flawed as I was still thinking in terms of standard programming languages..(done too much of it all for majority of my 25 years) local, global, private etc. ..whats the big deal about OOP. Off the topic Question: Are functional languages better than OOP languages and are there any Fnl languages that are OO ? ) Hopefully if they are in different <Sections > they should not conflict on names? I'll check it out./:) Another way, I saw somewhere (don't remember) was kind of like this: <xsl:variable name=ColValue select=..expression..> < if.... < if.. < when .. expr </xsl:variable> Do you think it would be possible to create such a thing where it would give it would give out a value based on "creatively" created expressions? Maybe this is just another way of doing what you and Dimitre suggested. I will look into this and get back on it. Thanks, Abhishek Sanwal HP - Houston Campus abhishek.sanwal@xxxxxx -----Original Message----- From: Wendell Piez [mailto:wapiez@xxxxxxxxxxxxxxxx] Sent: Monday, September 15, 2003 11:17 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Re: whats the best way to create and use values for lookup (key-value) such that you can loop through it with limits 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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Re: whats the best way to, Wendell Piez | Thread | RE: [xsl] Re: whats the best way to, David Carlisle |
[xsl] extracting preceding nodes wi, Matthew L. Avizinis | Date | Re: [xsl] XSLT to SVG Image not app, Roger I Martin PhD |
Month |