Python-Ref > Mimo python > XSLT > Debugging XSLT
 
 

^^->
Klíčová slova
Moduly
Knihovní funkce

Debugging XSLT

I bez speciálních nástrojů typu XSLT debuggeru lze XSLT debugovat. Stejně jako lze v Pythony použít print, v XSLT použijeme xsl:message.
Expand/Shrink
<examples>
  <example num="1">
    <title>Example 1</title>
    <text>This is example nr. 1. It shows how an example looks.</text>
  </example>

  <example num="2">
    <title>Example 2</title>
    <text>Another example. Imagine some ingenious text here...</text>
  </example>
</examples>
Zdroj: (xslt1-1.xslt)
  1   <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  2   
  3     <xsl:output indent="yes"/>
  4   
  5     <xsl:template match="examples">
  6       <xsl:apply-templates select="example"/>      
  7     </xsl:template>
  8   
  9     <xsl:template match="example">
 10       <xsl:apply-templates select="*"/>
 11     </xsl:template>
 12     
 13     <xsl:template match="title">
 14       <h1><xsl:apply-templates/></h1>
 15     </xsl:template>
 16   
 17     <xsl:template match="text">
 18       <xsl:message>DEBUG2: <xsl:value-of select="."/></xsl:message>
 19       <p><xsl:apply-templates/></p>
 20     </xsl:template>
 21   </xsl:stylesheet>
stdout:
<?xml version="1.0" encoding="UTF-8"?>
<h1>Example 1</h1>
<p>This is example nr. 1. It shows how an example looks.</p>
<h1>Example 2</h1>
<p>Another example. Imagine some ingenious text here...</p>
stderr:
DEBUG2: This is example nr. 1. It shows how an example looks.
DEBUG2: Another example. Imagine some ingenious text here...
Doba běhu: 364.2 ms