Subject: Re: [xsl] How to avoid careless mistakes when using XSLT modes? From: "Eliot Kimber ekimber@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 19 Apr 2019 19:06:51 -0000 |
I usually have a fallback template in each mode and during development or for debugging turn on a message indicating what it matched on. Useful for validating that you've handled all the elements that will need handling, especially when you're first building the handling for a new document type. With XSLT 3's new mode instruction and the ability to have a built-in default template for shallow-copy there's no need for a fallback in the context of identity transforms, so then you lose the opportunity to have this kind of fallback handling message, although of course you can start with the template and then remove it for debugging purposes. Cheers, E. -- Eliot Kimber http://contrext.com o;?On 4/19/19, 1:41 PM, "David Sewell dsewell@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: I just spent too much time completely puzzled about why a particular template was not producing correct/expected output before realizing that in many cases the template was not matching anything -- because some time ago I had added a mode to certain instances of <xsl:template> and <xsl:apply-templates> without being sure to adjust other templates in the stylesheet. Adding mode="#all" to my failing template fixed the problem. Obviously one could prevent many such problems by checking for the existence of @mode in a stylesheet before working with it. Remembering always to do that is the problem. Any other suggestions? (I guess one could make a habit of adding an <xsl:message> to the template matching the root to warn that the template is using modes.) David -- David Sewell Manager of Digital Initiatives The University of Virginia Press Email: dsewell@xxxxxxxxxxxx Tel: +1 434 924 9973 Web: http://www.upress.virginia.edu/rotunda
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to avoid careless mis, David Sewell dsewell | Thread | [xsl] Dynamically determining line , Larry Hayashi lhtree |
Re: [xsl] How to avoid careless mis, David Sewell dsewell | Date | [xsl] Dynamically determining line , Larry Hayashi lhtree |
Month |