Page 1 of 1

Bad practice naming variables

Posted: Tue May 09, 2017 11:37 am
by odeon
Hi,

oXygen 19 includes "bad practice naming variables" messages in the document checking options for XSLT. Something like

<xsl:variable name="part" select="@part"/>

will produce a warning: "Bad practice naming variables the same as elements and attributes from XPath expressions: [part]."

Now, this is a rather subjective rule. I can see why it's sometimes a good idea to avoid naming your variables the same as elements or attributes in the XPath, but there are also plenty of situations when it's actually a good idea. I'm currently working on an XSLT with lots of variables using this naming convention for a very good reason, and that's not about to change. It's not an option and not something I particularly want to discuss.

What I would like is a setting that allows me to turn off this kind of subjective coding style warnings. I can see that I can turn off document checking but that's certainly not what I want, I merely want something that allows me to turn off warnings that I think are subjective and, in my context, wrong. If there is a way to do this now, I was unable to find it.

Many thanks,

Ari Nordstrom

Re: Bad practice naming variables

Posted: Tue May 09, 2017 2:59 pm
by adrian
Hi,

It's not an actual setting, but you can edit the default XSLT validation scenario and remove the additional Schematron validation that reports those warnings.
Note that this removes all XSLT Code Quality Assurance checks that have been added in v19.0.

Steps:
1. Options > Preferences, Document Type Association, select XSLT, press Edit (confirm extending).
2. In the Document type editing dialog go to the Validation tab, edit the XSLT scenario.
3. In the Edit scenario dialog remove the second validation unit, the one with the schema ${baseFramework}/sch/xsltCustomRules.sch.
4. OK in all dialogs.

The alternative is to edit the file Oxygen/frameworks/xslt/sch/xsltCustomRules.sch and change/remove the Schematron rules that bother you.

Regards,
Adrian