faqts : Computers : Internet : Web : XML : XSL[T] (in IE 5.x)

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 3 people (33%) answered Yes
Recently 1 of 3 people (33%) answered Yes

Entry

XML: XSL: Debug: Variable: XSL: How to debug XSL variables?

Sep 24th, 2003 15:22
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 25 September 2003 - 00:09 am ------------------

XML: XSL: Debug: Variable: XSL: How to possibly debug XSL variables?

Method: Use the <xsl:message> tag

or possibly also the

 <xsl:comment> tag.

---

e.g. put this in your XSL code:

    <xsl:message terminate="yes">
     <xsl:value-of select="."/>
    </xsl:message>

---

e.g.

1. Your XSL file:

<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version="1.0">

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

 <xsl:template match="MYBOOKS">
   <HTML>
    <HEAD>
     <TITLE>
       My book database
     </TITLE>
    </HEAD>
    <BODY>
     <H3> Overview book database </H3>
     <BR/>
     <BR/>
     <HR/>
     <HR/>

    <!-- debug here -->
    <xsl:message terminate="yes">
      <xsl:copy-of select="*"/>
    </xsl:message>

      <xsl:apply-templates/>

     <HR/>
    </BODY>
   </HTML>
 </xsl:template>

 <xsl:template match="BOOK">
  <FONT SIZE="3" COLOR="blue">
   <BR/> book:

    <xsl:apply-templates/>

  </FONT>
  <HR/>
 </xsl:template>

 <xsl:template match="AUTHOR">
  <BR/> author=
   <xsl:value-of select="."/>
 </xsl:template>

 <xsl:template match="TITLE">
  <BR/> title=
   <xsl:value-of select="."/>
  </xsl:template>

</xsl:stylesheet>


---

2. Your XML file:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE MYBOOKS SYSTEM "book.dtd">

<?xml-stylesheet type="text/xsl" href="dddbook.xsl"?>

<!-- library: (filenamemacro=book.xml)  -->

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MYBOOKS SYSTEM "book.dtd">
<?xml-stylesheet type="text/xsl" href="book.xsl"?>
<!-- library: (filenamemacro=book.xml)  -->
<MYBOOKS>

 <BOOK>

  <AUTHOR>
    Holzner, Steve
  </AUTHOR>

  <TITLE>
    Inside XML
  </TITLE>

 </BOOK>

 <BOOK>

  <AUTHOR>
    Knuth, Donald
  </AUTHOR>

  <TITLE>
    the art of computer programming
  </TITLE>

 </BOOK>

</MYBOOKS>

---

3. This will show:

Overview book database


-----------------------------------------------------------------------
---------

-----------------------------------------------------------------------
---------
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error 
and then click the Refresh button, or try again later.


-----------------------------------------------------------------------
---------

Holzner, Steve Inside XML Knuth, Donald the art of computer programming

---
---

Method: use the XMLSpy debugger

Download e.g. XMLSpy v2004 Enterprise trial version from
http://www.xmlspy.com

This program has a very good inbuilt debugger to further go step
by step through your XSL source code.

---
---

Internet: see also:

http://www-106.ibm.com/developerworks/xml/library/x-debugxs.html

About the xsl tag <xsl:message>
http://www.devguru.com/Technologies/xslt/quickref/xslt_element_message.
html

----------------------------------------------------------------------