Re: [xsl] How to never make mistakes when coding?

Subject: Re: [xsl] How to never make mistakes when coding?
From: "G. Ken Holman g.ken.holman@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 1 Mar 2025 20:15:14 -0000
At 01/03/2025 19:44 +0000, Michael Kay michaelkay90@xxxxxxxxx wrote:
At 01/03/2025 14:50 +0000, Roger L Costello costello@xxxxxxxxx wrote:
Have you thought about these types of questions? What answers did you come up with?

XSLT 2.0 introduced stronger type-checking as a response to this requirement, but it's an optional feature

This is what has helped me write better code. Mistake free? Of course not. But better.


And so that it isn't optional for me, I enforce as= on each and every parameter in every included or imported fragment of every stylesheet I write for production use. I just make it one of the many stylesheet writing rules that I enforce using my XSLStyle methodology:

https://cranesoftwrights.github.io/resources/index.htm#xslstyle

To enforce using them, my push pipelines run the stylesheet checker and will fail the pipeline if any of the rules are violated.

Rules include documentation, such as embedding documentation for each and every top-level element, and each and every parameter. This helps me revisit my choice of as= being the most appropriate choice for how I'm going to use the information.

Some may think documentation is a pain. After many years I am well in the practice of adding documentation. Again, the act of putting your intentions into words helps to confirm the coding as not going off the rails.

We have therefore also put a lot of effort into the Saxon product over the years to try and help you discover errors in your code even when it's syntactically correct but semantically wrong, for example writing `true` when you meant `true()`.

For which I am very, very thankful, Mike. The tool is tremendous. I used profiling for the first time the other day and uncovered work that needs to be done that never would I have found on my own.


But mistakes? I'm going to continue making them. My ego doesn't get bruised when I mess up. But a good craftsman uses good tools to make fewer mistakes.

. . . . . . Ken


-- Contact info, blog, articles, etc. http://www.CraneSoftwrights.com/s/ | Check our site for free XML, XSLT, XSL-FO and UBL developer resources | Streaming hands-on XSLT/XPath 2 training class @US$125 (5 hours free) | Essays (UBL, XML, etc.) http://www.linkedin.com/today/author/gkholman |

Current Thread