[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: variable question
Bruce,
You can't do this. A parallel thread is also on the topic of using XPaths dynamically like this, and how it can't be done in XSLT 1.0. The XPath "//$bibkey" doesn't make any sense to the processor, since an XPath step (the part between the slashes, or after the '//' abbreviation in this case) can't be a variable reference, but must be a combination of axis, node test and (optional) predicates. This is because there can be no guarantee that a variable reference will resolve to anything useful. Here it doesn't even resolve to a string, much less to the string "db:biblioref/@linkend", since the variable hasn't been bound to that string, but rather to the node-set retrieved by that string in the context of the variable declaration (which happens to be an empty node set in this case, since your document has no db:biblioref/@linkend navigating from the root, which is the context of the declaration). An analogy might be if you got a bill from the electric company, but instead of putting a payment in the envelope and sending it back, you put in a note that said "mail this back and I'll send a check to put in this envelope". Sorry, the electric company can't credit your account on that basis. (Just as the electric company has to cash your check before they can be paid, the stylesheet engine has to compile your stylesheet before it can be executed. Your variable reference doesn't give it the information it needs to compile, just as your IOU can't be cashed as if it were a check -- even if you happen to be good for the money.) In XSLT 1.0 the only way to do this would be by using a stylesheet to generate your stylesheet. Maybe Mike or Jeni or someone can suggest an easier way to do this in XSLT 2.0. Cheers, Wendell At 11:25 AM 11/10/2004, you wrote: Why does my below __variable not seems to work, while if I use the same xpath expression in place of it, it does? How can I fix this to use the variable? I just want to localize in one place the configuration for where to find the data (in the below case, on the file system, in a directory called "bib-data", where each reference is in an individual file named with the value of the citation ID). ====================================================================== 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 ======================================================================
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|