[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Suggested guidelines for using local types. (was Re: Enlightenmentvia avoiding the T-word)
- From: Jonathan Borden <firstname.lastname@example.org>
- To: "Fuchs, Matthew" <email@example.com>, firstname.lastname@example.org
- Date: Mon, 27 Aug 2001 15:58:25 -0400
> As I thought Rick made abundantly clear, if you put globals and locals in
> the same namespace, then you need to worry about aliasing issues.
So you are saying that if you are using an element in different contexts,
the template needs to be context aware ... ok so far.
> suppose (as in this case) there is a global element "name" and a
> (structurally different) local element "name" defined inside the global
> element "person".
Perhaps the complexity is produced by your introduction of these concepts
"global" and "local" element. To me, every element has context, and I am not
sure I need to make a distinction between "local" and "global" elements.
Unless its the document element every "x:name" element is the child of
> What happens to the document with the following fragment?
> Well, the first x:name is appropriately handed to the global template.
> x:person is handed to the right template. Then x:name is handed to ...
> _wrong_ template.
Not in my XSLT it doesn't! Your "x:person" template ought not blindly
<apply-templates> in such a situation. Indeed if your concept of "local
element" is intended to have real meaning then I really would expect the
template to process the "local" x:name element itself, i.e. locally.
It matches the template intended for the global x:name -
> and the script promptly crashes. The only way to make this work is to
> explicitly add a template for the scoped "name":
and you can also do it this way, so there at least a couple solutions to
this so-called problem without needing to introduce multiple namespaces.
> And this must be systematically done for _every_ local name if you want to
> escape the fragility Rick describes, even if you wnat them to have the
> default handling. Not very robust.
Shrug. I've never had to resort to namespaces to sort out similar issues in
programs. e.g. C++.
> Now suppose the "name" local to "person" is not in a namespace. Then the
> fragment is:
> and we run that against the first script:
> <template match="*|/">
> ...some default behavior...
> <template match="x:name">...
> <template match="x:person">
> The global "name" now matches against the right template. The "person"
> template matches against the right template. And the _local_ "name"
> match the template for the global "name" because (tada!) it's not in the
> right namespace. Therefore it defaults to matching the default template -
> just the behavior Rick wants (I think).
Again, if the template does not blindly call <apply-templates> this isn't an