troubleshooting Question

XSL to create custom email message body in ASP .Net 2.0

Avatar of atljarman
atljarman asked on
ProgrammingXMLASP.NET
8 Comments2 Solutions343 ViewsLast Modified:
Hi,

I have an XML file that stores file names and folders for files.  These will be used to created a job request to move the file from one server to another.  I would like a header to give the IT staff an idea which folder they should look and move to/from.  I also want to make it so the header only appears if there is a value that matches that header type (e.g., count > 0).  I currently have an XSL that sorts and lists the file, but I would like to group them as follows:

Please move these to the live server:

Main folder:
List of files

Images folder:
List of files

Documents folders:
List of files

Images\site folder:
List of files


Please remove these to the live server:

Main folder:
List of files

Images folder:
List of files

Documents folders:
List of files

Images\site folder:
List of files


Here is the XSL:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<head>

</head>
<body>
<b>Total number of files to be migrated to live server:</b>

<xsl:if test="count(//item) > 0">
&#xa0;
<xsl:value-of select="count(//item)"/>&#xa0;
</xsl:if>


<table>
<tr><th scope="col">Location:</th><th scope="col">File name:</th></tr>
    <xsl:apply-templates/>
</table>



</body>
</html>


</xsl:template>




  <xsl:template match="file">
    <xsl:apply-templates>
      <xsl:sort select="l"/>
      <xsl:sort select="f"/>
    </xsl:apply-templates>
  </xsl:template>
  <xsl:template match="item">
     <tr>
      <td>
          <xsl:apply-templates select="l"/>
      </td>
      <td>
          <xsl:apply-templates select="f"/>
      </td>
     </tr>
  </xsl:template>
</xsl:stylesheet>



Here is the XML:


<?xml version="1.0" standalone="yes"?>
<file>
  <item>
    <l>main</l>
    <f>allimages.aspx</f>
    <a>add</a>
  </item>
  <item>
    <l>main</l>
    <f>allimages.aspx</f>
    <a>remove</a>
  </item>
  <item>
    <l>main</l>
    <f>contactus.aspx</f>
    <a>remove</a>
  </item>
  <item>
    <l>main</l>
    <f>all_news.aspx</f>
    <a>remove</a>
  </item>
  <item>
    <l>images</l>
    <f>1.gif</f>
    <a>add</a>
  </item>
  <item>
    <l>images</l>
    <f>10.gif</f>
    <a>remove</a>
  </item>
  <item>
    <l>documents</l>
    <f>ComCorpCareers508.pdf</f>
    <a>add</a>
  </item>
  <item>
    <l>documents</l>
    <f>MentorMenteeApplication.pdf</f>
    <a>remove</a>
  </item>
  <item>
    <l>images</l>
    <f>arrow_3.gif</f>
    <a>remove</a>
  </item>
  <item>
    <l>images</l>
    <f>crumbArrow.jpg</f>
    <a>add</a>
  </item>
  <item>
    <l>images</l>
    <f>crumbArrow.gif</f>
    <a>add</a>
  </item>
</file>

Here is the current HTML output as displayed by ie9:

Total number of files to be migrated to live server:   11  
Location: File name:
documents ComCorpCareers508.pdf
documents MentorMenteeApplication.pdf
images 1.gif
images 10.gif
images arrow_3.gif
images crumbArrow.gif
images crumbArrow.jpg
main all_news.aspx
main allimages.aspx
main allimages.aspx
main contactus.aspx

*Note: I haven't added the add/remove field to the output yet.
ASKER CERTIFIED SOLUTION
Gertone (Geert Bormans)
Information Architect
Join our community to see this answer!
Unlock 2 Answers and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros