RE: [XSLT2] debugging XSLT apps; getting information about items and sequences

Perhaps what would best meet your requirements is something like

<xsl:message select="$parent">parent</xsl:message>

However, all attempts to define debugging and trace output suffer from the
same problems: the more the stylesheet is optimized, the less meaningful the
output is going to be.

Clearly, since both xsl:message and fn:trace() have the side-effect of
writing the value to some diagnostic stream, you don't want to use fn:trace
inside xsl:message, since you will then get the output twice. They are
alternatives, not facilities to be used in conjunction.

My personal view (my company's view, in fact) is that diagnostic
capabilities should be outside the scope of the specification: see
 http://lists.w3.org/Archives/Public/public-qt-comments/2003Jun/0091.html

Michael Kay

> -----Original Message-----
> From: Tobias Reif [mailto:tobiasreif@pinkjuice.com] 
> Sent: 11 June 2003 16:27
> To: public-qt-comments@w3.org
> Subject: [XSLT2] debugging XSLT apps; getting information 
> about items and sequences
> 
> 
> 
> Hi
> 
> While working on XSLT apps, I need to inspect some variables 
> and parameters.
> 
> I need to get the type information and the positions in the sequence 
> printed out (and possibly more info), not just the string value.
> 
> I currently use
> 
>    <xsl:message>
>      <xsl:copy-of select="trace($parent,'parent')"/>
>      <xsl:copy-of select="trace($children,'children')"/>
>    </xsl:message>
> 
> (sometimes wrapped inside <xsl:if test="$debug"/>)
> 
> => prints
> 
> parent [1]: xs:string: span
> children [1]: xs:string: div
> children [2]: xs:string: p
> children [3]: xs:string: span
> children [4]: xs:string: span
> spandivpspanspan
> 
> The above is useful, but in addition to what I want, I get the string 
> value of the sequences (last line). The latter is not really 
> useful in 
> my case, and not needed.
> 
> This
> 
>    <xsl:message>
>      <xsl:copy-of select="$parent"/>
>      <xsl:copy-of select="$children"/>
>    </xsl:message>
> 
> => prints
> 
> span
> spandivpspanspan
> 
> The above is way less informative, and not useful in my (and probably 
> other) scenario(s).
> 
> I guess I'd like to have something like this:
> 
>    <xsl:message>
>      <xsl:inspect select="$parent"/>
>      <xsl:inspect select="$children"/>
>    </xsl:message>
> 
> => would print
> 
> parent [1]: xs:string: span
> children [1]: xs:string: div
> children [2]: xs:string: p
> children [3]: xs:string: span
> children [4]: xs:string: span
> 
> xsl:inspect would simply return a string, and would not print 
> anything 
> by itself. This string can be stored in a variable, processed 
> further, 
> written to a run log, or simply printed out as in the above example.
> 
> Some of my requirements:
> 
> 1. I want to get information about a certain sequence at a certain 
> point, which may not be the same point where I use it.
> 
> 2. I need the information provided by trace(), but I want to 
> decide on 
> my own if I print this string or not. The function (eg a version of 
> trace()) or element I want should not print anything, but 
> only return a 
> string.
> 
> 3. I only want to see those values when I debug the XSLT.
> So I need to be able to enclose everything that prints out debug 
> messages in <xsl:if test="$debug"/>
> 
> 4. It should work in all conforming processors. I want a 
> solution, not a 
> workaround :)
> 
> Tobi
> 
> [the examples are run with Saxon 7.5.1]
> 
> -- 
> http://www.pinkjuice.com/
> 

Received on Thursday, 12 June 2003 12:53:57 UTC