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.
ProgrammingXMLASP.NET

Avatar of undefined
Last Comment
Gertone (Geert Bormans)

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Gertone (Geert Bormans)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Gertone (Geert Bormans)

atljarman

ASKER
Gertone, could you provide a sample for one of the listings?
Gertone (Geert Bormans)

That is exactly what I thought the XSLT does
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
atljarman

ASKER
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
atljarman

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
atljarman

ASKER
Many thanks Gertone!
Gertone (Geert Bormans)

welcome
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.