Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with xsl:sort using IE5.5 for XSLT

Status
Not open for further replies.

pcorreia

Programmer
Feb 22, 2002
301
US
Sorry if this is a long post, but I wanted to include all the necessary code! Thanks in advance for any help...

I'm having problems getting the
Code:
<xsl:sort/>
element to do what I want it to. I'm trying to use XSLT to transform an XML employee list into XHTML. The structure of my XML document is like this:

Code:
<?xml version=&quot;1.0&quot; ?>
<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;employees_xsl.cfm&quot;?>

<employees count=&quot;&quot;> 
   <SGroup id=&quot;&quot; name=&quot;&quot;>
      <employee>
         <id></id>
         <FName></FName>
         <LName></LName>
         <Extension></Extension>
      </employee>
   </SGroup>
</employees>

(Data has been removed due to its sensitive nature). There are multiple
Code:
<employee>
elements per
Code:
<SGroup>
element, and multiple
Code:
<SGroup>
elements in the
Code:
<employees>
element. The XSL template I am trying to use looks like this:

Code:
<?xml version=&quot;1.0&quot;?>
<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;[URL unfurl="true"]http://www.w3.org/TR/WD-xsl&quot;>[/URL]
   <xsl:template match=&quot;/&quot;>
      <html>
      <xsl:apply-templates/>
      </html>
   </xsl:template>
   <xsl:template match=&quot;employees&quot;>
      <head>
         <title>Active Employees</title>
         <link rel=&quot;STYLESHEET&quot; type=&quot;text/css&quot; href=&quot;employees.css&quot; />
         <script type=&quot;text/javascript&quot; src=&quot;employees_js.js&quot;></script>
      </head>
      <body>
         <table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;3&quot;>
            <col width=&quot;30&quot; />
            <col width=&quot;200&quot; />
            <col width=&quot;50&quot; align=&quot;center&quot; />
            <col width=&quot;100&quot; />
            <thead>
               <tr>
                  <td></td>
                  <td>Employee Name</td>
                  <td>EmpID</td>
                  <td>Extension</td>
               </tr>
            </thead>
            <xsl:apply-templates select=&quot;SGroup&quot;>
               <!-- <xsl:sort select=&quot;@name&quot;/> -->
            </xsl:apply-templates>
         </table>
      </body>
   </xsl:template>
   <xsl:template match=&quot;SGroup&quot;>
      <tbody>
         <tr class=&quot;SGroup&quot;>
            <td colspan=&quot;4&quot;><a class=&quot;showSGroup&quot;><xsl:attribute name=&quot;href&quot;>javascript:show(<xsl:value-of select=&quot;@id&quot;/>);</xsl:attribute><span class=&quot;showSGroup&quot;>4</span><xsl:value-of select=&quot;@name&quot;/></a></td>
         </tr>
         <tr>
            <td colspan=&quot;4&quot;>
               <table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;3&quot; class=&quot;SGroupMembers&quot; style=&quot;display:none;&quot;><xsl:attribute name=&quot;id&quot;>tbl<xsl:value-of select=&quot;@id&quot;/></xsl:attribute>
                  <col width=&quot;27&quot; />
                  <col width=&quot;200&quot; />
                  <col width=&quot;50&quot; align=&quot;center&quot; />
                  <col width=&quot;97&quot; />
                  <xsl:apply-templates select=&quot;employee&quot;>
                     <!-- <xsl:sort select=&quot;LName&quot;/> -->
                  </xsl:apply-templates>
               </table>
            </td>
         </tr>
      </tbody>
   </xsl:template>
   <xsl:template match=&quot;employee&quot;>
      <tr>
         <td></td>
         <td><xsl:value-of select=&quot;LName&quot;/>, <xsl:value-of select=&quot;FName&quot;/></td>
         <td><xsl:value-of select=&quot;id&quot;/></td>
         <td><xsl:value-of select=&quot;Extension&quot;/></td>
      </tr>
   </xsl:template>
</xsl:stylesheet>

You can see that there are two places where
Code:
<xsl:sort>
elements have been commented out. If I uncomment the first of those elements, I get the following error message from Internet Explorer (with actual data where this example says DATA_REMOVED):

Unspecified error Line 183, Position 15
Code:
   <Extension>DATA_REMOVED</Extension>
--------------^
I get a similar error when I uncomment the second
Code:
<xsl:sort>
element. I'm using Internet Explorer 5.5 SP2 to view this document. Any help you could lend would be greatly appreciated!

Sincerely,
Patrick Correia, Web Designer
Clough, Harbour & Associates, LLP
pcorreia@_NOSPAM_cha-llp.com
 
Try this namespace in your XSLT stylesheet and see if it makes any difference:

<?xml version=&quot;1.0&quot;?>
<xsl:stylesheet xmlns:xsl=&quot; version=&quot;1.0&quot;>
<xsl:eek:utput method=&quot;xml&quot; indent=&quot;yes&quot;/>

or

<?xml version=&quot;1.0&quot;?>
<xsl:stylesheet xmlns:xsl=&quot; version=&quot;1.0&quot;>
<xsl:eek:utput method=&quot;xml&quot; doctype-system=&quot; doctype-public=&quot;.//W3C//DTD XSHML 1.0 Transitional//EN&quot; indent=&quot;yes&quot;/>
 
Thanks for the suggestion. IE carped about the semicolons in those statements, so I took them out.

What happened was interesting. The errors stopped, but now IE is outputting the
Code:
javascript:show()
from about halfway down the stylesheet above into the document instead of using it as the href property for the
Code:
<a>
tag.

What I end up with is all the heading information, then the javascript:show() statement, then the span containing the &quot;4&quot; (this is a right arrow in the Webdings font), then a comma (which comes from way down on the stylesheet, where I output FName and LName), and that's it. Nothing is repeated. Am I using some xsl tags that are not allowed in the namespace you suggested, or whose syntax is different in that namespace?

It might be easier to debug this problem if there was a way I could actually see the transformed document that results from the processing of my xml and xsl documents... anyone know a way to do this in IE? When I &quot;view source&quot;, I see the xml source document.
 
With respect to my earlier post about viewing the result of XSL tranformations, I found that Microsoft has a tool that plugs into IE to do just that. Here's a link to that tool:


As a result of using that tool, I can see there are serious problems resulting from the namespace change. Here is the XSLT output after using the new namespace. You can clearly see that many of the xsl tags are not being parsed:

Code:
<TABLE cellSpacing=0 cellPadding=3 border=0>
<COLGROUP>
<COL width=30>
<COL width=200>
<COL align=middle width=50>
<COL width=100>
<THEAD>
<TR>
<TD></TD>
<TD>Employee Name</TD>
<TD>EmpID</TD>
<TD>Extension</TD></TR></THEAD><XSL:APPLY-TEMPLATES select=&quot;SGroup&quot;><XSL:SORT select=&quot;@name&quot; /></XSL:APPLY-TEMPLATES>
<TBODY></TBODY></TABLE></XSL:TEMPLATE><XSL:TEMPLATE match=&quot;SGroup&quot;><TBODY><TR class=SGroup><TD colspan=&quot;4&quot;><A class=showSGroup><XSL:ATTRIBUTE name=&quot;href&quot;>javascript:show(<XSL:VALUE-OF select=&quot;@id&quot; />);</XSL:ATTRIBUTE><SPAN class=showSGroup>4</SPAN><XSL:VALUE-OF select=&quot;@name&quot; /></A></TD> </TR><TR><TD colspan=&quot;4&quot;>
<TABLE class=SGroupMembers style=&quot;DISPLAY: none&quot; cellSpacing=0 cellPadding=3 border=0><XSL:ATTRIBUTE name=&quot;id&quot;>tbl<XSL:VALUE-OF select=&quot;@id&quot; /></XSL:ATTRIBUTE> 
<COLGROUP>
<COL width=27>
<COL width=200>
<COL align=middle width=50>
<COL width=97><XSL:APPLY-TEMPLATES select=&quot;employee&quot;><XSL:SORT select=&quot;LName&quot; /></XSL:APPLY-TEMPLATES>
<TBODY></TBODY></TABLE></TD></TR></TBODY></XSL:TEMPLATE><XSL:TEMPLATE match=&quot;employee&quot;><TR><TD></TD><TD><XSL:VALUE-OF select=&quot;LName&quot; />, <XSL:VALUE-OF select=&quot;FName&quot; /></TD><TD><XSL:VALUE-OF select=&quot;id&quot; /></TD><TD><XSL:VALUE-OF select=&quot;Extension&quot; /></TD></TR></XSL:TEMPLATE></XSL:STYLESHEET>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top