Subject: [xsl] modifying an XSLT Document at runtime From: "Sanjay Pandey/Towers Perrin" <pandeys@xxxxxxxxxx> Date: Thu, 6 Dec 2001 08:46:04 -0500 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: Namespace name from node?, Dimitre Novatchev | Thread | RE: [xsl] modifying an XSLT Documen, Chris Bayes |
Re: [xsl] transformNode() returning, Francis Norton | Date | Re: [xsl] transformNode() returning, Jibran Bisharat |
Month |