Subject: Re: [xsl] implements-prefix vs implements-namespace From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Tue, 6 Mar 2001 10:45:00 +0000 |
Hi Clark, > For those new to the thread, xsl:script has an attribute called > implements-prefix, which informs the xslt processor that the script > is bound to the namespace associated with the prefix. The problem > occurs when importing, i.e., when the prefix to namespace > relationship is not 1-1. In this currently very rare case, the > interaction and behavior is definately non-obvious. With the > intoduction of xsl:script this case will no longer be rare, and will > unfortunately not get any more obvious. Replacing implements-prefix > with implements-namespace would solve this conceptual problem. What are you referring to when you say that the prefix to namespace relationship is not 1-1? Within any particular document (given that you only define one prefix per namespace) then the mapping is 1-1 - the mappings in the stylesheets that you import have absolutely no effect on the mappings in the stylesheet you're working on. I agree with your point that the mysterious workings of namespaces are difficult to understand, but personally, I think that anyone who uses XSLT at more than a basic level has to get their heads around namespaces anyway. I grant you that it is impossible for those of us who have got our heads round them to fully grasp the problems encountered by those of us who haven't. > 1. The "-prefixes" is used in less frequently used > features, like exclude-element. Thus your average > stylesheet writer may not have encountered this > particular construct, nor had to learn about it. You're confusing extension-element-prefixes and exclude-result-prefixes (there's no such thing as exclude-element-prefixes). Which demonstrates your point ;) When people start using xsl:script then they're going to want to use exclude-result-prefixes (or possibly extension-element-prefixes) for the namespace that they're using because otherwise that namespace will be present in their result document. I think it's very unlikely that it will be changed to exclude-result-namespace, so people using xsl:script will have to use prefixes, and understand how imports interact with them, at some point anyway. I think it will cause more confusion to have prefixes being used in exclude-result-prefixes and namespaces being used in implements-namespace being used on xsl:script that it would to have them both use prefixes. > 2. Commonly, without the use of import, "namespace" and > "prefix" are most often in 1-1 correspondence. Thus > the stylesheet user, even if they use these uncommon > constructs can be happily ignorant of the distinction. And can happily remain so. Whether you import anything or not, the mappings remain unchanged. If you are in control of the imported stylesheet and you want to avoid confusion, then you can use the same prefixes in the imported stylesheet as elsewhere. This is a situation you objected to previously, but in the vast majority of cases it will work just fine. The only time when any level of complexity is introduced is if you have a clash between the namespace prefixes you're using in your stylesheet and those that were used in the imported stylesheet. The namespace mappings give you the flexibility to introduce a different prefix for the same namespace and use that prefix in your stylesheet. Or you can change one of the other mappings in your stylesheet to get rid of the conflict - it's up to you. Within the one stylesheet, only one mapping is visible. > HOWEVER, with xsl:script and with the desire for modularity, your > _average_ stylesheet user will now be exposed to both "-prefixes", > and they will be using import, so they no longer be happily > ignorant. I think they can be happily ignorant a while longer. We can simplify by saying that the prefixes in the imported and importing stylesheet should be the same. > I feel this change more than merits a re-consideration of the > "-prefixes" position. It is definately non-trivial and most xslt > users will have the choice of: > > a) grappling with the distinction and this less-than-obvious > way of thinking (just to save a few keystrokes); OR > b) don't bother modulizing their stylesheets into > import modules (giving up). It's not just a matter of keystrokes, it's also about avoiding introducing errors. We want to see stylesheets where there are at least three different xsl:script elements for the same functions. If each of those has to have the entire namespace URI written on it then the chance of a typo creeping in somewhere gets fairly high, and we all know how annoyingly non-obvious those kinds of bugs can be. Very probably I'm just lazy. Or perhaps I should move to that really funky visual XSLT development environment. > P.S. There is one other argument for "namespace" instead > of "prefix", currently one cannot specify prefixes > using XSLT. This will exacerbate the situation unless > this ability is moved into XSLT 1.1 along with xsl:script. You can specify prefixes in XSLT in just the same way as you can in any XML vocabulary - using the namespace declaration. If you're talking about *generating* code with particular namespace prefixes, I don't think that it's a problem - you either rely on the built-in copying of namespace nodes or you copy them so you get the prefix you want. It's not an insurmountable problem. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Re: implements-prefix vs , Michael Kay | Thread | RE: [xsl] FW: Coordination of <scri, DPawson |
Re: [xsl] Seeking XPATH, Jeni Tennison | Date | Re: [xsl] Re: implements-prefix vs , Jeni Tennison |
Month |