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

modifying an XSLT Document at runtime

Subject: modifying an XSLT Document at runtime
From: "Sanjay Pandey/Towers Perrin" <pandeys@xxxxxxxxxx>
Date: Thu, 6 Dec 2001 08:46:04 -0500
th onclick
Hi List,

I have a XML as below ("ErrorMessages.xml")
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="formatErrors.xsl" media="screen"?>
<ErrorMessages xmlns:xs="http://www.w3.org/2001/Schema">
     <errorMessage>
          <description>desc1</description>
          <errorType>1</errorType>
          <fieldName>field1</fieldName>
     </errorMessage>
     <errorMessage>
          <description>desc2</description>
          <errorType>2</errorType>
          <fieldName>field2</fieldName>
     </errorMessage>
     <errorMessage>
          <description>desc3</description>
          <errorType>3</errorType>
          <fieldName>field3</fieldName>
     </errorMessage>
</ErrorMessages>


And XSL is as below ("formatErrors.xsl")
<?xml version="1.0"?>
<!-- <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">  -->
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- <xsl:output method="html"/>  -->

     <!-- Get error message data   -->
     <xsl:template match="/">
     <html>
     <head>
          <title>Error Messages</title>
     <script>
          <xsl:comment>
               <![CDATA[
                    var xslStylesheet=null;
                    var xmlSource = null;
                    var attribNode = null;

                    function sort(field)
                    {
                         attribNode.value = field;

ErrorMessages.innerHTML=xmlSource.documentElement.transformNode(xslStylesheet);
                    }
               ]]>
          </xsl:comment>
     </script>

     <script for="window" event="onload">>
          <xsl:comment>
               <![CDATA[
                    xslStylesheet=document.XSLDocument;
                    xmlSource = document.XMLDocument;
<!--                xmlSource.load("ErrorMessages.xml");  -->
                    attribNode = document.XSLDocument.selectSingleNode
("xsl:sort/@select");
                    sort('errorType');
               ]]>
          </xsl:comment>
     </script>
     </head>

     <body>
          <div id="ErrorMessages"></div>
     </body>
     </html>
     </xsl:template>
     <xsl:template match="ErrorMessages">

        <table border ="0" frame="border" cellspacing ="0" width="100%">
        <thead title="Alt-click sorts in descending order.">
        <tr style="background:brown;color:red;font-size:10pt">
          <th onclick="sort('errorType')" width="20%" style="cursor:hand;">
               <div>errorType</div>
          </th>
          <th onclick="sort('fieldName')" width="20%" style="cursor:hand;">
               <div>fieldName</div>
          </th>
          <th onclick="sort('description')" width="20%" style
="cursor:hand;">
               <div>description</div>
          </th>
        </tr>
        </thead>
        <tbody id="ErrorMessages_body">
          <xsl:for-each select ="//errorMessage">
          <xsl:sort select ="errorType"/>
          <tr>

               <td>      <xsl:value-of select ="errorType"/> </td>
               <td>      <xsl:value-of select ="fieldName"/> </td>
               <td>      <xsl:value-of select ="description"/> </td>

             </tr>
          </xsl:for-each>
          </tbody>
     </table>
     </xsl:template>
</xsl:stylesheet>

I am unable to get it working. When I open the XML in IE5.5, I get syntax
error in line 21 (which appears to be one in XSL with "attribNode.value =
field". This example I am trying is supposed to format my ErrorMessage XML
file so that I have SORT facility while viewing the ErrorMessages.

I have taken most of it from Chapter 9 of Professional XML (wrox).

What is wrong here? Any help would be highly appreciated.

Thanks,
Sanjay


 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.