Re: [xsl] translate to XML using XSL into an HTML table

Subject: Re: [xsl] translate to XML using XSL into an HTML table
From: "Abel Braaksma (online)" <abel.online@xxxxxxxxx>
Date: Mon, 6 Aug 2007 21:54:38 +0200 (CEST)
> Abel,
>
> thank you so much for your helpful explanation. I
> tried and tried your example and could not get it to
> compile.
> Will you kindly help?
>

Yes, I would, but then you'll have to tell me what the problem is.
What do you mean with you "can't compile it"? If you receive an
error, what is it? What code did you use (my code was done by hand
in the mail program, I haven't checked it for errors, sorry, and
likely there are some typos when one doesn't have a syntax checker,
man am I spoiled with these ;). And, just as important, what input
did you use? If there is no error, and you have no output, the most
obvious reason is an XPath typo (meaning: you select nodes that are
not there, resulting in no output).

To continue on the latter: as a hint, it is very useful while
debugging to replace xsl:apply-templates with xsl:copy-of (and the
same select statement of course). xsl:copy-of will show you an exact
copy of the input if you would select something indeed (or nothing
otherwise). Start with the very first XPath and then work your way
down your templates.

If you are unsure a template is called, or you expect it to output
something, you can add an extra statement on the beginning of the
template (like <xsl:text>Template XXX called</xsl:text>). If that
outputs the text, you know at least that the template is called and
you can go from there.

If that doesn't help, you can try to do a most-generic match. This
match will be called when no other match is found. This is basically
the same as when you find yourself facing an output with only text
instead of elements: the default match of any XSLT stylesheet is
that texts are output as text. To check this, you can add the
following:

<xsl:template match="node() |@*" priority="-1">
   <xsl:text>OOPS I should NOT have been invoked!!!</xsl:text>
   <xsl:copy-of select="." />
   <xsl:apply-templates select="node() | @*" />
</xsl:template>

if this about doubles the output with a lot of "OOPS" texts, you
know you have 'missing nodes'. If this is on purpose so, it is ok,
if not, you should check the other templates for XPath errors in the
patterns.

There's a lot more you can do of course to track down your problem.
But first and foremost, after you tried a couple of my suggestions,
when you make an inquiry to this list, state clearly what error you
have, what goes in, what goes out, what you expect etc. The error is
like a picture: it says more than a thousand words ;)

Cheers,
-- Abel Braaksma

Current Thread