xsl-list
[Top] [All Lists]

RE: debugging techniques [was:qualitative decline of xsl-li st questions]

2002-12-04 04:27:16
Nicely Michael :-)
Some of these rather 'non' obvious!

  Use <xsl:comment><xsl:value-of
select="system-property('xsl:vendor')"/></xsl:comment> so you 
are in no
doubt about which XSLT processor you are using

Like it. E.g. I developed it under Saxon and it fails to work under
X some time later.


  If you want to leave debug lines in the stylesheet that can be
switched on and off at will, make them into extension elements:

  <xsl:stylesheet xmlns:debug="debug.uri"
    extension-element-prefixes="debug">
  ...

      <debug:debug x="{$x}" y="{$y}"><xsl:fallback/></debug:debug>

  The <debug:debug> element will be ignored, but values will be output
if "debug" is removed from the "extension-element-prefixes" attribute.

I don't understand this. I believe you, but how do I switch it on/off
please?
My simpler one (more work, I know)

<xsl:param name="debug" select="0"/>

then

<xsl:if test="$debug &gt; 2">
  dump the debug stuff,
  higher number, more dumped - stolen with glee from Norm's uri resolver
</xsl:if>







  To see what's in a temporary tree (or result tree fragment), copy it
to the output:

  <debug tree="$x">
    <xsl:copy-of select="$x"/>
  </debug>

I haven't a clue what this is doing, or why the processor should treat an
attribute 
as ... whatever?




  To add tracing to all template rules, add a debug module:

  <xsl:import href="real-stylesheet.xsl"/>
  <xsl:template match="*">
    <xsl:message>Processing <xsl:value-of
select="name()"/></xsl:message>
    <xsl:apply-imports/>
    <xsl:message>Finished processing <xsl:value-of
select="name()"/></xsl:message>
  </xsl:template>

  (You can also use xsl:comment instead of xsl:message)

Sneaky! I like that.

A richer method (less typing again I see!) than mine.
I re-write that default each time, but add one more level, dumping
<xsl:value-of  select="name(..)"/>/<xsl:value-of  select="name()"/>

which tells me that doc/section hasn't been 'styled' (yet), hence
prompts me to provide the missing template.



One more in this area.
  When you have forgotten the namespace prefix? e.g.
trying to match on 'section' instead of 'myns:section' ?

try

<xsl:template match="theTopLevelElement"> ***
    <xsl:apply-templates/>
</xsl:template>

<xsl:template match="theNext-to-TopLevelElement"> +++
    <xsl:apply-templates/>
</xsl:template>

It will show you where its 'blocking'.
  No, I never forget either  :------ooooooo






  To deal with character-encoding problems: use a hex editor!

Recommendations please?
 Win32 and Linux anyone?
 I actually prefer to view in a more readable format, but now that
my only Unicode editor has gone commercial I'm missing a 'real' view.

Mike Brown?

  If you don't understand the error messages from your XSLT processor
(or if you are beginning to suspect that it has a bug), run the
transformation through another XSLT processor to see if it sheds any
light on the matter.

Again I can't see how this is going to tell me anything other than
'its well formed XML' ?




Thanks Mike. Very useful.

Regards DaveP

- 

NOTICE: The information contained in this email and any attachments is 
confidential and may be legally privileged. If you are not the 
intended recipient you are hereby notified that you must not use, 
disclose, distribute, copy, print or rely on this email's content. If 
you are not the intended recipient, please notify the sender 
immediately and then delete the email and any attachments from your 
system.

RNIB has made strenuous efforts to ensure that emails and any 
attachments generated by its staff are free from viruses. However, it 
cannot accept any responsibility for any viruses which are 
transmitted. We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email 
and any attachments are those of the author and do not necessarily 
represent those of RNIB.

RNIB Registered Charity Number: 226227

Website: http://www.rnib.org.uk 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>
  • RE: debugging techniques [was:qualitative decline of xsl-li st questions], DPawson <=