Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

XML Grouping Links to HTML table of contents output via XSLT

$
0
0

This currently outputs html at the top I've got it outputting links.. and which 'Network' it is in.. but I need to group the links in the top table of contents to be by network.. 

I'm using sharepoint 2010 and modifying a c#.net app that processes code, creates xml, using xslt to sent an email.. the core functionality already exists.. I'm trying to just get the xslt to generate the desired output.

I've been going through lots of examples about grouping with keys etc.. I'm not haveing any luck..

basically I just need to group this top list of links by Network..

so instead of :

Network 2          sdfgann2

Network 2          34563456

Network 2          5678rtyuj46578

Network 2          test

Network 2          asdf Network 2

Network 2          test

Network 1          test4

Network 1          test4

Network 1          test3

it would instead be something like this..

Network 2

sdfgann2

34563456

5678rtyuj46578

test

asdf Network 2

test

Network 1

test4

test4

test3

XML: 

<?xml version="1.0" encoding="utf-8"?>
<EDGEUserDTO xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <AlertNetworks>
    <EDGEAlertDTO>
      <AlertDTO>
        <EDGEListDTO>
          <ListName>Announcements</ListName>
          <ListURL>http://hou2spdev04:36250//network2/Lists/Announcements/AllItems.aspx</ListURL>
          <newItem>
            <EDGENewItemDTO>
              <ItemTitle>sdfgann2</ItemTitle>
              <ItemLink>http://hou2spdev04:36250/network2/Lists/Announcements/DispForm.aspx?ID=3</ItemLink>
              <ItemBody>&lt;div class="CAEB79D197D244A3B43F49B5D5F89F26"&gt;&lt;p&gt;sdfgann2?&lt;/p&gt;&lt;/div&gt;</ItemBody>
              <Modified>5/13/2014 1:13:02 PM</Modified>
              <ModifiedBy>domain\\user1</ModifiedBy>
              <CreatedBy>domain\\user1</CreatedBy>
              <AlertEventType>1</AlertEventType>
              <Subject>!18!Re:sdfgann2</Subject>
              <ReplyEmailAddress>test.email@testing.com</ReplyEmailAddress>
              <DisplayReplyButton>0</DisplayReplyButton>
            </EDGENewItemDTO>
            <EDGENewItemDTO>
              <ItemTitle>34563456</ItemTitle>
              <ItemLink>http://hou2spdev04:36250/network2/Lists/Announcements/DispForm.aspx?ID=4</ItemLink>
              <ItemBody>&lt;div class="54217EC614544A17B38A32F68C75F171"&gt;&lt;p&gt;3563456yurkryuk?&lt;/p&gt;&lt;/div&gt;</ItemBody>
              <Modified>5/13/2014 1:16:27 PM</Modified>
              <ModifiedBy>domain\\user1</ModifiedBy>
              <CreatedBy>domain\\user1</CreatedBy>
              <AlertEventType>1</AlertEventType>
              <Subject>!21!Re:34563456</Subject>
              <ReplyEmailAddress>test.email@testing.com</ReplyEmailAddress>
              <DisplayReplyButton>0</DisplayReplyButton>
            </EDGENewItemDTO>
            <EDGENewItemDTO>
              <ItemTitle>5678rtyuj46578</ItemTitle>
              <ItemLink>http://hou2spdev04:36250/network2/Lists/Announcements/DispForm.aspx?ID=5</ItemLink>
              <ItemBody>&lt;div class="D43E81F371C14F079F27DA261B407E8B"&gt;&lt;p&gt;fghjr658745678rhikj46?&lt;/p&gt;&lt;/div&gt;</ItemBody>
              <Modified>5/13/2014 1:16:34 PM</Modified>
              <ModifiedBy>domain\\user1</ModifiedBy>
              <CreatedBy>domain\\user1</CreatedBy>
              <AlertEventType>1</AlertEventType>
              <Subject>!22!Re:5678rtyuj46578</Subject>
              <ReplyEmailAddress>test.email@testing.com</ReplyEmailAddress>
              <DisplayReplyButton>0</DisplayReplyButton>
            </EDGENewItemDTO>
          </newItem>
        </EDGEListDTO>
        <EDGEListDTO>
          <ListName>Discussions</ListName>
          <ListURL>http://hou2spdev04:36250//network2/Lists/Discussions/AllItems.aspx</ListURL>
          <newItem>
            <EDGENewItemDTO>
              <ItemTitle>test</ItemTitle>
              <ItemLink>http://hou2spdev04:36250/network2/Lists/Discussions/DispForm.aspx?ID=10</ItemLink>
              <ItemBody>&lt;div class="A9149B24A685404B84442AEA2025576A"&gt;asdf&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</ItemBody>
              <Modified>5/13/2014 9:08:05 AM</Modified>
              <ModifiedBy>domain\\user1</ModifiedBy>
              <CreatedBy>domain\\user1</CreatedBy>
              <AlertEventType>1</AlertEventType>
              <Subject>!17!Re:test</Subject>
              <ReplyEmailAddress>test.email@testing.com</ReplyEmailAddress>
              <DisplayReplyButton>1</DisplayReplyButton>
            </EDGENewItemDTO>
            <EDGENewItemDTO>
              <ItemTitle>asdf Network 2</ItemTitle>
              <ItemLink>http://hou2spdev04:36250/network2/Lists/Discussions/DispForm.aspx?ID=11</ItemLink>
              <ItemBody>&lt;div class="9876897C178746FE83E05A829F6C5E25"&gt;&lt;div&gt;asdfasdfasdf&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</ItemBody>
              <Modified>5/13/2014 1:15:57 PM</Modified>
              <ModifiedBy>domain\\user1</ModifiedBy>
              <CreatedBy>domain\\user1</CreatedBy>
              <AlertEventType>1</AlertEventType>
              <Subject>!23!Re:asdf Network 2</Subject>
              <ReplyEmailAddress>test.email@testing.com</ReplyEmailAddress>
              <DisplayReplyButton>1</DisplayReplyButton>
            </EDGENewItemDTO>
            <EDGENewItemDTO>
              <ItemTitle>test</ItemTitle>
              <ItemLink>http://hou2spdev04:36250/network2/Lists/Discussions/DispForm.aspx?ID=12</ItemLink>
              <ItemBody>&lt;div class="802EFA247D1F497C881768D5EDAB9EC2"&gt;asdfasdfasdfasdf435345345&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</ItemBody>
              <Modified>5/13/2014 1:16:09 PM</Modified>
              <ModifiedBy>domain\\user1</ModifiedBy>
              <CreatedBy>domain\\user1</CreatedBy>
              <AlertEventType>1</AlertEventType>
              <Subject>!24!Re:test</Subject>
              <ReplyEmailAddress>test.email@testing.com</ReplyEmailAddress>
              <DisplayReplyButton>1</DisplayReplyButton>
            </EDGENewItemDTO>
          </newItem>
        </EDGEListDTO>
      </AlertDTO>
      <SiteName>Network 2</SiteName>
      <SiteURL>http://hou2spdev04:36250/network2</SiteURL>
      <AlertType>1</AlertType>
    </EDGEAlertDTO>
    <EDGEAlertDTO>
      <AlertDTO>
        <EDGEListDTO>
          <ListName>Discussions</ListName>
          <ListURL>http://hou2spdev04:36250//network1/Lists/Discussions/AllItems.aspx</ListURL>
          <newItem>
            <EDGENewItemDTO>
              <ItemTitle>test4</ItemTitle>
              <ItemLink>http://hou2spdev04:36250/network1/Lists/Discussions/DispForm.aspx?ID=260</ItemLink>
              <ItemBody>&lt;div class="AFF7A8D3197140D2BA98123202981961"&gt;&lt;div&gt;sdfg&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</ItemBody>
              <Modified>5/12/2014 3:21:47 PM</Modified>
              <ModifiedBy>domain\\user1</ModifiedBy>
              <CreatedBy>domain\\user1</CreatedBy>
              <AlertEventType>1</AlertEventType>
              <Subject>!15!Re:test4</Subject>
              <ReplyEmailAddress>test.email@testing.com</ReplyEmailAddress>
              <DisplayReplyButton>1</DisplayReplyButton>
            </EDGENewItemDTO>
            <EDGENewItemDTO>
              <ItemTitle>test4</ItemTitle>
              <ItemLink>http://hou2spdev04:36250/network1/Lists/Discussions/DispForm.aspx?ID=260</ItemLink>
              <ItemBody>&lt;div class="AFF7A8D3197140D2BA98123202981961"&gt;&lt;div&gt;sdfg&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</ItemBody>
              <Modified>5/12/2014 3:21:47 PM</Modified>
              <ModifiedBy>domain\\user1</ModifiedBy>
              <CreatedBy>domain\\user1</CreatedBy>
              <AlertEventType>1</AlertEventType>
              <Subject>!15!Re:test4</Subject>
              <ReplyEmailAddress>test.email@testing.com</ReplyEmailAddress>
              <DisplayReplyButton>1</DisplayReplyButton>
            </EDGENewItemDTO>
            <EDGENewItemDTO>
              <ItemTitle>test3</ItemTitle>
              <ItemLink>http://hou2spdev04:36250/network1/Lists/Discussions/DispForm.aspx?ID=261</ItemLink>
              <ItemBody>&lt;div class="7C6056C8C5134EDAACCA37CBFC805240"&gt;&lt;div&gt;w5w3456w&lt;br /&gt;&lt;br /&gt;w54362w436&lt;/div&gt;&lt;/div&gt;</ItemBody>
              <Modified>5/13/2014 1:16:57 PM</Modified>
              <ModifiedBy>domain\\user1</ModifiedBy>
              <CreatedBy>domain\\user1</CreatedBy>
              <AlertEventType>1</AlertEventType>
              <Subject>!19!Re:test3</Subject>
              <ReplyEmailAddress>test.email@testing.com</ReplyEmailAddress>
              <DisplayReplyButton>1</DisplayReplyButton>
            </EDGENewItemDTO>
          </newItem>
        </EDGEListDTO>
      </AlertDTO>
      <SiteName>Network 1</SiteName>
      <SiteURL>http://hou2spdev04:36250/network1</SiteURL>
      <AlertType>1</AlertType>
    </EDGEAlertDTO>
  </AlertNetworks>
</EDGEUserDTO>

Current XSLT:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
  <xsl:template match="/">
    <html style="margin: 0; padding: 0;">
      <body style="margin: 0; padding: 0;">
        <table cellpadding="0" cellspacing="0" style="width: 100%;">
          <xsl:call-template name="Header"/>
<table cellpadding="0" cellspacing="0" style="width: 100%;">
          <xsl:apply-templates select="//AlertNetworks"/>
</table>
<table cellpadding="0" cellspacing="0" style="width: 100%;">
          <xsl:apply-templates select="//EDGEUserDTO"/>
</table>
          <xsl:call-template name="Footer"/>
        </table>

      </body>
    </html>
  </xsl:template>

  <xsl:template match ="AlertNetworks">
    <tr>
 <td> 
  
<xsl:apply-templates select="//ItemTitle"/>

 </td>
    </tr>
  </xsl:template>

<xsl:template match ="ItemTitle">
    <tr>
 <td> 
<xsl:value-of select="../../../../../SiteName"/>
</td><td>
  <a style="text-decoration: none;color: #007788; font-family: Arial, Helvetica, sans-serif" target="_blank">
                <xsl:attribute name="href">
                  #<xsl:value-of select="../ItemTitle"/>
                </xsl:attribute>
                <xsl:value-of select="../ItemTitle"/>
              </a>
 </td>
    </tr>
  </xsl:template>

 
  <xsl:template match ="EDGEUserDTO">
    <tr>
 <td> 
  <xsl:apply-templates select="//EDGEAlertDTO"/>
 </td>
    </tr>
  </xsl:template>

  <xsl:template match ="EDGEAlertDTO">
    <tr>
      <td id="content-header" style="height: 65px; background-color: #ffffff">
        <table cellpadding="0" cellspacing="0" style="width: 100%; background: #fff5d8">
          <tr>
            <td>
              <table cellpadding="0" cellspacing="0" style="width: 100%; background: #fff5d8">
                <tr>
                  <td style="height: 45px; width: 50%; text-align: left; vertical-align: middle">
                    <a style="text-decoration: none;color: #007788; font-size: 1.1em; font-family: Arial, Helvetica, sans-serif" target="_blank">
                      <xsl:attribute name="href" >
                        <xsl:value-of select="SiteURL"/>
                      </xsl:attribute>
                      <xsl:value-of select="SiteName"/>
                    </a>
                  </td>
                  <td style="height: 45px; width: 50%; text-align: right; vertical-align: middle">
                    <a style="text-decoration: none;color: #007788; font-size: 1.0em; font-family: Arial, Helvetica, sans-serif" target="_blank">
                      <xsl:attribute name="href" >
                        <xsl:value-of select="SiteURL"/>/_layouts/MySubs.aspx
                      </xsl:attribute>
                      Modify my alert settings
                    </a>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
          <xsl:apply-templates select="AlertDTO/EDGEListDTO"/>
        </table>
      </td>
    </tr>

  </xsl:template>

  <xsl:template match ="EDGEListDTO">
    <tr>
      <td>
        <a style="text-decoration: none;color: #007788; font-weight: bold; font-size: 1.5em; font-family: Arial, Helvetica, sans-serif" target="_blank">
          <xsl:attribute name="href" >
            <xsl:value-of select="ListURL"/>
          </xsl:attribute>
          <xsl:value-of select="ListName"/>
        </a>
      </td>
    </tr>
    <xsl:apply-templates select="newItem/EDGENewItemDTO"/>

    <tr>
      <td style="height: 100px; background-color: #ffffff"></td>
    </tr>
  </xsl:template>

  <xsl:template match ="EDGENewItemDTO">

    <xsl:if test="DisplayReplyButton>0">
      <td style="height: 45px; width: 50%; text-align: right; vertical-align: middle">

        <a target="_blank" style="display: inline-block; color: #FFF; background-color: #007788; font-size: 1.1em; font-family: Arial, Helvetica, sans-serif; text-decoration: none; padding: 5px 15px;">
          <xsl:attribute name="href" >
            mailto:<xsl:value-of select="ReplyEmailAddress"/>?Subject=<xsl:value-of select="Subject"/>
          </xsl:attribute>
          <span style="padding-right: 10px; display: inline-block; bottom: -2px">
            <img id="button" src="cid:edgereplytoDiscussion" style="border:0px" />
          </span>
          Mobile Reply
        </a>
      </td>
    </xsl:if>
    <tr>
      <td style="height: 5px; background-color: #ffffff"></td>
    </tr>
    <tr>
      <td id="content-header" style="background-color: #ffffff">
        <table cellpadding="0" cellspacing="0" style="width: 100%; background: #ededed; color: #000;">
          <tr>
            <td style="width: 18%; text-align: left; vertical-align: top; padding: 5px; font-weight: bold; font-family: Arial, Helvetica, sans-serif">
              <xsl:choose>
                <xsl:when test="DisplayReplyButton>0">
                  Subject:
                </xsl:when>
                <xsl:otherwise>
                  Title:
                </xsl:otherwise>
              </xsl:choose>
            </td>
            <td style="text-align: left; vertical-align: top; padding: 5px">

              <a style="text-decoration: none;color: #007788; font-family: Arial, Helvetica, sans-serif" target="_blank">
                <xsl:attribute name="name">
                  <xsl:value-of select="ItemTitle"/>
                </xsl:attribute>
                <xsl:attribute name="href">
                  <xsl:value-of select="ItemLink"/>
                </xsl:attribute>
                <xsl:value-of select="ItemTitle"/>
              </a>
            </td>
            <xsl:if test="AlertEventType = 1">
              <td style="width: 8%; text-align: center; vertical-align: middle; padding: 5px; background: #48b8e7; color: #ffffff; font-weight: bold; font-family: Arial, Helvetica, sans-serif">NEW</td>
            </xsl:if>
            <xsl:if test="AlertEventType = 2">
              <td style="width: 8%; text-align: center; vertical-align: middle; padding: 5px; background: #fdcf41; color: #ffffff; font-weight: bold; font-family: Arial, Helvetica, sans-serif">EDITED</td>
            </xsl:if>

            <!-- background: #48b8e7 = NEW, background: #fdcf41 = EDITED, background: #ed1b23 = DELETED  -->
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td style="height: 5px; background-color: #ffffff"></td>
    </tr>
    <tr>
      <td id="content-header" style="background-color: #ffffff">
        <table cellpadding="0" cellspacing="0" style="width: 100%; color: #000;">
          <tr>
            <td style="width: 18%; text-align: left; vertical-align: top; padding: 5px; font-weight: bold; font-family: Arial, Helvetica, sans-serif">Body:</td>
            <td style="width: 82%; text-align: left; vertical-align: top; padding: 5px; font-family: Arial, Helvetica, sans-serif">

              <xsl:value-of disable-output-escaping="yes" select="ItemBody"/>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td style="height: 5px; background-color: #ffffff"></td>
    </tr>
    <tr>
      <td id="content-header" style="background-color: #ffffff">
        <table cellpadding="0" cellspacing="0" style="width: 100%; background: #ededed; color: #000;">
          <tr>
            <td style="width: 18%; text-align: left; vertical-align: top; padding: 5px; font-weight: bold; font-family: Arial, Helvetica, sans-serif">Modified:</td>
            <td style="width: 82%; text-align: left; vertical-align: top; padding: 5px; font-family: Arial, Helvetica, sans-serif">
              <xsl:value-of select="Modified"/>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td style="height: 5px; background-color: #ffffff"></td>
    </tr>

    <tr>
      <td id="content-header" style="background-color: #ffffff">
        <table cellpadding="0" cellspacing="0" style="width: 100%; background: #ededed; color: #000;">
          <tr>
            <td style="width: 18%; text-align: left; vertical-align: top; padding: 5px; font-weight: bold; font-family: Arial, Helvetica, sans-serif">Modified By:</td>
            <td style="width: 82 text-align: left; vertical-align: top; padding: 5px; font-family: Arial, Helvetica, sans-serif">
              <xsl:value-of select="ModifiedBy"/>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td style="height: 50px; background-color: #ffffff"></td>
    </tr>
    <tr>
      <td id="header-bar-2" style="height: 2px; background-color: #3c3c3c"></td>
    </tr>
  </xsl:template>

  <xsl:template name ="Header">
    <tr>
      <td></td>
    </tr>
    <tr>
      <td id="top" style="height: 40px; background-color: #ffffff; text-align: right">
        <a href="http://www.fmctechnologies.com" target="_blank">
          <img id="logo" src="cid:companylogo" style="height: 40px; width: 230px; border: none" />
        </a>
      </td>
    </tr>
    <tr>
      <td id="header-bar-1" style="height: 5px; background-color: #3c3c3c"></td>
    </tr>
    <tr>
      <td id="header" style="height: 73px; background-color: #f7f7f7">
        <a href="http://inside.km.net.fmcti.com" target="_blank">
          <img id="edge-logo" src="cid:edgelogo" style="height: 73px; width: 209px; border: none" />
        </a>
      </td>
    </tr>
    <tr>
      <td id="header-bar-2" style="height: 5px; background-color: #3c3c3c"></td>
    </tr>

  </xsl:template>

  <xsl:template name="Footer">

  </xsl:template>

</xsl:stylesheet>


Ve1


Viewing all articles
Browse latest Browse all 935

Trending Articles