Link to home
Start Free TrialLog in
Avatar of atljarman
atljarman

asked on

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

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
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of atljarman
atljarman

ASKER

Gertone, could you provide a sample for one of the listings?
That is exactly what I thought the XSLT does
Gertone,

I was checking from my wireless device, and didn't see that you provided a suggestion to try.  I will work with what you sent and let you know.  My apologies for not seeing it previously.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Many thanks Gertone!