[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Debugging.... Conditionally including XML

Subject: Re: Debugging.... Conditionally including XML
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 13 Nov 2000 09:45:42 +0000
Re: Debugging.... Conditionally including XML
John,

> I would like to be able to do something like this in my XML file...
> <page>
>         <content>....</content>
>         if (debug = true)
>                 Include a debug data file, which would contain the data and
> item tags
>         else
>                 The data and item tags will be returned to me.
> </page>

Probably the best way to approach this is to have a parameter called
debugp that is by default 'false' and can be set to true when you call
the processor from the command line.

To set up the parameter:

<xsl:param name="debugp" select="'false'" />

How you pass the value for the parameter into the stylesheet is
dependent on the processor that you're using.  With Saxon, for
example, you'd use something like:

  saxon -a -o out.xml in.xml debugp=true

Within the stylesheet, I would then set up a variable that is true()
when $debugp is 'true' and false() when $debugp is 'false' - this is
just to make testing for whether you're in debug mode easier:

<xsl:variable name="debug" select="$debugp = 'true'" />

You can then conditionally add text when in debug mode using xsl:if or
xsl:choose/xsl:when that test on the value of $debug:

<xsl:if test="$debug">
  <!-- add some debugging text -->
</xsl:if>

<xsl:choose>
  <xsl:when test="$debug">
    <!-- text added when debugging -->
  </xsl:when>
  <xsl:otherwise>
    <!-- text added when not debugging -->
  </xsl:otherwise>
</xsl:choose>

To send the debugging information to the screen rather than into the
output file, you can use xsl:message within the debugging sections (or
outside them for messages that you always want to see).

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.