Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 25th, 2005, 09:36 AM
Registered User
 
Join Date: Aug 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default parsing XML with XSL.

I have a large XML that needs to be generated into HTMl table. The table will contain a small icon and subject that is clickable in each row.

so when each row is clicked, the details should be displayed in another frame. each row has some kind of message id.

the problem is that when it is p****d, it generates HTML table pretty quickly, but when I click one of the rows to view the detail, it holds until all icons are loaded. Once all icons for rows are completely loaded, the detail appears in another frame.

So I am just wondering if what is causing to hold the process.

here is the two different XML. the first one p****s XML for really long, but unexpectedly displays graphic quickly.

The second one p****s XML really fast, but loads graphic really slowly. I just want to know the difference.

the first XSL.

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

<xsl:for-each select="msgs/msg">
  <xsl:sort select="scol[@name = $SORTCOL_1]/@sortdata | @*[concat('@',name()) = $SORTCOL_1] | col[@name = $SORTCOL_1]" order="{$SORTORD_1}"/>
  <xsl:sort select="scol[@name = $SORTCOL_2]/@sortdata | @*[concat('@',name()) = $SORTCOL_2] | col[@name = $SORTCOL_2]" order="{$SORTORD_2}"/>
  <TR><xsl:attribute name="onClick"><xsl:value-of select="concat(concat('eventhandler.onRowClick(1,' ,@mid),');')"/></xsl:attribute> <xsl:attribute name="onDblClick"><xsl:value-of select="concat(concat('eventhandler.onRowClick(2,' ,@mid),');')"/></xsl:attribute> <xsl:attribute name="id"><xsl:value-of select="concat('M_',@mid)"/></xsl:attribute><xsl:choose><xsl:when test="@RD = '0'"><xsl:attribute name="class">rowunread</xsl:attribute></xsl:when><xsl:otherwise><xsl:attribute name="class">rowread</xsl:attribute></xsl:otherwise></xsl:choose>
    <TD valign="top"><xsl:choose><xsl:when test="@DL = 'I'"><IMG SRC="images/row_excl.gif" WIDTH="11" HEIGHT="16"/></xsl:when></xsl:choose></TD>
    <TD valign="top"><xsl:choose><xsl:when test="@RD = '0'"><IMG SRC="images/row_notread.gif" WIDTH="19" HEIGHT="16"/></xsl:when><xsl:otherwise><IMG SRC="images/row_read.gif" WIDTH="19" HEIGHT="16"/></xsl:otherwise></xsl:choose></TD>
    <TD valign="top"><xsl:value-of select="col[@name='Subject']"/></TD>
    <TD valign="top"><xsl:value-of select="scol[@name='Date']"/></TD>
  </TR>
  <TR><TD COLSPAN="5" HEIGHT="1" BGCOLOR="#E2E2E2"></TD></TR>

</xsl:for-each>

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

the second XSL.

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

<xsl:for-each select="msgs/msg">
  <xsl:sort select="scol[@name = $SORTCOL_1]/@sortdata | @*[concat('@',name()) = $SORTCOL_1] | col[@name = $SORTCOL_1]" order="{$SORTORD_1}"/>
  <xsl:sort select="scol[@name = $SORTCOL_2]/@sortdata | @*[concat('@',name()) = $SORTCOL_2] | col[@name = $SORTCOL_2]" order="{$SORTORD_2}"/>
  <TR><xsl:attribute name="id"><xsl:value-of select="concat('M_',@mid)"/></xsl:attribute> <xsl:choose><xsl:when test="@RD = '0'"><xsl:attribute name="class">rowunread</xsl:attribute></xsl:when><xsl:otherwise><xsl:attribute name="class">rowread</xsl:attribute></xsl:otherwise></xsl:choose>
    <TD valign="top"><xsl:choose><xsl:when test="@DL = 'I'"><IMG SRC="images/row_excl.gif" WIDTH="11" HEIGHT="16"/></xsl:when></xsl:choose></TD>
    <TD valign="top"><xsl:choose><xsl:when test="@RD = '0'"><IMG SRC="images/row_notread.gif" WIDTH="19" HEIGHT="16"/></xsl:when><xsl:otherwise><IMG SRC="images/row_read.gif" WIDTH="19" HEIGHT="16"/></xsl:otherwise></xsl:choose></TD>
    <TD valign="top"><xsl:value-of select="col[@name='From']"/></TD>
    <TD valign="top"><xsl:value-of select="col[@name='Subject']"/></TD>
    <TD valign="top"><xsl:value-of select="scol[@name='Date']"/></TD>
  </TR>
  <TR><TD COLSPAN="5" HEIGHT="1" BGCOLOR="#E2E2E2"></TD></TR>

</xsl:for-each>

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



the difference in these xsl is that "<TR>" tag. the first one concatenates string to build javascript function, but the second one doesn't have it. instead, I am using this function. so for the second XSL, after it p****s, this function is called. but this is not slow at all. I am assuming that the slowness for loading graphic might be associated with this function. i am not sure what is causing the slowness of loading graphic.

function initTable()
{
 var table = document.getElementById('MessageTable');
 if(table != 'undefined' && table != null)
 {
  var rows = table.getElementsByTagName("tr");
  var nRow = table.rows.length;
  if(nRow > 1)
  {
   for(var i=1;i<nRow;i++)
   {
    var msgId = rows[i].getAttribute('id');
    msgId = msgId.substring(msgId.indexOf("_")+1, msgId.length);
    rows[i].onclick = new Function("eventhandler.onRowClick(1, '" + msgId + "')");
    rows[i].ondblclick = new Function("eventhandler.onRowClick(2, '" + msgId + "')");
   }
  }
 }
}

I am not sure if my description is enough.

It would be very great if someone can solve this issue.








Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing the xml which is having vikkiefd XML 14 July 28th, 2008 05:21 AM
parsing xml kri_hegde XML 5 July 24th, 2007 11:37 AM
XML parsing denzil_cactus Perl 0 June 11th, 2007 02:34 AM
XML Parsing tgopal Javascript 2 July 27th, 2004 08:54 AM
XML Parsing tgopal .NET Web Services 1 June 15th, 2004 03:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.