Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XSLT file creation - what'm I doing wrong here?
Message
 
 
General information
Forum:
ASP.NET
Category:
XML
Miscellaneous
Thread ID:
00837776
Message ID:
00837950
Views:
26
Guys -- although double slashes will work (and yes the slashes need to be forward not back), it is extremely bad form to use them like this.

Here's what you've told the processor:

** Look at every branch of the tree for this node. Process it anyplace, and every time, it's found. ***

You can imagine the kind of performance nightmare this would create if you used it on a large document <s>.

Also, your format appears to be relying on the default template behavior. In this case, you don't actually need something to refer to the root, it's irrelevant. The default behavior would do an automatic apply-template to everything it found actual matches for, and apply default behavior to all children where not counter-instructed.

Therefore you would only need:
<xsl:template match="ErrorDetail">
Default for the root would be to apply templates and would hit this one as a child of root, I think.

If you wanted to make sure you only hit ErrorDetail nodes that were one level below the root, meaning the processor will do less work, you could do this:
<xsl:template match="/*/ErrorDetail">
But if I were you, I wouldn't want the headers in between the rows <s>. So the proper answer is probably to apply one template to the root and then use one apply-templates to get at your details.

This will give you both more efficient behavior *and* something closer to what you are trying to achieve (I think) in the way of presentation.

Something like this for starters, I will just re-arrange slightly and show you how to separate out the logic:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="/">
  <head>
    <title>Amex Commercial Error Log</title>
  </head>
 <body>
 <TABLE id="Table1" height="588" cellSpacing="1" cellPadding="1" width="971" border="1">
    <TR>
    <TD width="249" bgColor="#003399" height="27">
      <P><FONT face="Tahoma" color="#ffffff"><STRONG>Time</STRONG></FONT></P>
    </TD>
    <TD width="213" bgColor="#003399" height="27">
      <P><FONT face="Tahoma" color="#ffffff"><STRONG>Message</STRONG></FONT></P>
    </TD>
    <TD width="142" bgColor="#003399" height="27">
      <P><FONT face="Tahoma" color="#ffffff"><STRONG>Error Type</STRONG></FONT></P>
    </TD>
    <TD width="259" bgColor="#003399" height="27">
      <P><FONT face="Tahoma" color="#ffffff"><STRONG>Module</STRONG></FONT></P>
    </TD>
    <TD bgColor="#003399" height="27">
      <P><FONT face="Tahoma" color="#ffffff"><STRONG>Call Stack</STRONG></FONT></P>
    </TD>
    </TR>
    <xsl:apply-templates />
  </TABLE>
  </body>

</xsl:template>

<xsl:template match="ErrorDetail">
  <TR>
    <TD width="249" height="103"><xsl:value-of select="Time"/></TD>
    <TD width="213" height="103"><xsl:value-of select="Message"/></TD>
    <TD width="142" height="103"><xsl:value-of select="Type"/></TD>
    <TD width="259" height="103"><xsl:value-of select="Site"/></TD>
    <TD height="103"><xsl:value-of select="Trace"/></TD>
  </TR>
</xsl:template>

</xsl:stylesheet>
-----------
Obviously, this isn't what I'm after (not surprising as this is my first attempt at writing an XSLT file ).
-------------

Well, you're in luck, because I've spent the last four years doing them really intensively <g>. Ask any questions you have -- this stuff is something I thoroughly enjoy.

I should also explain the result you got. Because there were no template matches, and because you were relying on the default template behavior, you *got* the default template behavior, which is to output the text contents of nodes.

>L<
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform