So, if you're dealing with XML namespaces, like so:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:html="http://www.w3.org/TR/xhtml1/strict"
>
<html:shunk>
<xsl:wuggawugga>
<html:stuff/>
</xsl:wuggawugga>
<xsl:mukluk/>
<html:wugga/>
<xsl:mukluk/>
</html:shunk>
</xsl:stylesheet>
...then you can just make one of the namespaces the default so that you can omit the prefix for it, like so:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns ="http://www.w3.org/TR/xhtml1/strict"
>
<shunk>
<xsl:wuggawugga>
<stuff/>
</xsl:wuggawugga>
<xsl:mukluk/>
<wugga/>
<xsl:mukluk/>
</shunk>
</xsl:stylesheet>
or:
<stylesheet version="1.0"
xmlns ="http://www.w3.org/1999/XSL/Transform"
xmlns:html="http://www.w3.org/TR/xhtml1/strict"
>
<html:shunk>
<wuggawugga>
<html:stuff/>
</wuggawugga>
<mukluk/>
<html:wugga/>
<mukluk/>
</html:shunk>
</stylesheet>
... where presumably you will have the default namespace be whichever one is most common in your document.
Of course, this is well-understood among all advanced superbeings of pure XML energy.
But what is less appreciated is that, for the nondefault namespaces, it may be a good idea to use a short and/or easy to type namespace prefix.
In other words, consider that this:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns ="http://www.w3.org/TR/xhtml1/strict"
>
<shunk>
<xsl:wuggawugga>
<stuff/>
</xsl:wuggawugga>
<xsl:mukluk/>
<wugga/>
<xsl:mukluk/>
</shunk>
</xsl:stylesheet>
is the same as this, but just more concise:
<Q:stylesheet version="1.0"
xmlns:Q="http://www.w3.org/1999/XSL/Transform"
xmlns ="http://www.w3.org/TR/xhtml1/strict"
>
<shunk>
<Q:wuggawugga>
<stuff/>
</Q:wuggawugga>
<Q:mukluk/>
<wugga/>
<Q:mukluk/>
</shunk>
</Q:stylesheet>
The only difference is that the latter uses "Q" as the namespace prefix instead of "xsl". For the parse, it's the namespace name ("http://www.w3.org/1999/XSL/Transform") that matters, not the prefix ("xsl"/"Q").
I use "Q" because it's right next to ":" on my keyboard. It could just as easily be "_" or "x" or "é" or "φ" or "乒" or whatever "letter" you like. (Although clearly this could be abused, just like with short variable names in programs.)
Here ends your soul-shattering revelation for the day.
Hmmm.... (Score:2)
Whilst there's nothing technically wrong with doing that, it will certainly cause people who read it to do a double take. As an example, imagine if you're reading some mod_perl code and the author has decided to use
$QUERYinstead of the usual$r. It's legitimate to do so, but certainly not idiomatic.Of course, if you're the only one who's going to see it, do as you will!
-Dom