RE: [xsl] Naming styles

Subject: RE: [xsl] Naming styles
From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx>
Date: Fri, 20 Aug 2004 15:22:54 +0100
> Are there any naming conventions in XSL/XSLT?
>
> In Java we have thos conventions, like class names begin with
> a capital letter, methods and properties with lower letters, etc...
>
> Is there any "best practices " for XSL, for naming vars,
> global vars, functions, etc.?

If you've ever seen any of Demitre Novatchev's code you'll know he tends
to use VB like naming convention s such as vFoo and pFoo for variables
and parameters etc., but personally I'm not so keen on these.

The filename isn't as important in XSLT as it is in java.  Templates
tend to have matches rather than names, and so take care of themselves.
All that's left are variables, parameters and keys, for which camel case
normally suffices.

I would welcome some conventions though, especially when it comes to
formatting/indenting Xpath 2.0 in xslt:

<xsl:template match="foo">
  <xsl:value-of select="if ($x castable as hatsize)
                            then $x cast as hatsize
                            else if ($x castable as IQ)
                            then $x cast as IQ
                            else $x cast as xs:string"/>
</xsl:template>

(hopefully the indentations will make it through)

Having attributes break across a single like has always felt wrong
really, but the more exposure I have to it the more readable it becomes.
In the first instance though, this looked a complete mess.

cheers
andrew

Current Thread