xsl-list
[Top] [All Lists]

Re: Variables and Values

2004-03-23 12:31:10
Julian,

At 01:24 PM 3/23/2004, you wrote:
On Tue, 23 Mar 2004 19:15:25 +0100, Andreas L. Delmelle wrote:
> Does this necessarily *have* to take place at the beginning?

Not necessarily, it's just where it sits in the document I am trying to
work replicate.

Ploughing through the archives, I am starting to realise that the XSLT
will not be able to do all that I want (since I cannot reset variables,
etc) so I think that the best thing for me is to break things down a
bit so that any programming style logic is handled in programming code
before I do the transformation.

Perhaps. Breaking down a problem into bits is generally a useful approach no matter what techniques or technologies you use.

But don't assume that because the XSLT won't do what you want in the way you expect it must be done, that it doesn't have its own effective way to accomplish it. Actually this is what Jeni was getting at...

As Jeni has pointed out in an answer to a related question..
> But as others have said, you can't update a variable in XSLT, and
> saying that you want to is usually a sign that you're approaching a
> problem in an inappropriate way.

Implicit here is the suggestion that when faced with this block, you try to find an appropriate way -- a way appropriate, that is, to both the goal you are trying to achieve, and to XSLT.

The reason we urge this is that the kind of problem you are facing is exactly where we have seen, time and again, both experienced and inexperienced programmers come to a fork in the road. They can either go back to techniques and technologies they know (generally procedural, imperative approaches of one kind or another), or they can go deeper into what David C calls "The XSL Way". Stretch your brain to accommodate the kind of technique that Andreas suggested, for example, and you find soon enough that XSLT provides alternatives to the techniques you know, that may require a little getting used to, but that are extremely powerful, flexible, and simple to use once you get the hang of it all.

So sure, if it's the path of least resistance you can certainly pre-process your data to provide your default value. But don't go away thinking that you *must* do this because it's intrinsically difficult in XSLT to provide a default value when none is available in the source. It's not.

Cheers,
Wendell


======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
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
======================================================================



<Prev in Thread] Current Thread [Next in Thread>