Tools






Example: XSLT Creating HTML Href’s

I’ve been doing a bit of XSL stuff lately and thought I’d put together a sample for my future reference and that may be of value to all of us XSLT-ers making a living in the internets.

Consider the following XML:

<FdcSearchTabsCollection Count="2">
  <SearchTab Label="Industry" SortOrder=”00” Label=”Industries” SearchConstraints="contenttype:Industry" TabID="831b2a74-98c4-4453-8061-86e2fdb22c63"/>
  <SearchTab Label="Practices" SortOrder=”01” Label=”Practices” SearchConstraints="contenttype:PracticeGroups" TabID="678e206b-6996-421f-9765-b0558fe1a9c0"/>
</FdcSearchTabsCollection>

The following XSL snippet will generate a sorted list of hrefs tabs:

<xsl:template match="FdcSearchTabsCollection" xml:space="preserve">
   
    <!– The "all" tab –>
    <a href="javascript:ViewTab(‘All’)">View all</a>
   
    <!– Each individual tab –>
    <!– Iterate through all the Tabs and display the correct  links. –>
    <xsl:for-each select="SearchTab">
      <xsl:sort select="@SortOrder"/>

      …
      <a href="javascript:ViewTab(‘{@TabID}’)"><xsl:value-of select="@Label"/></a>
    </xsl:for-each>

    <br/> 
   

   </xsl:template>

Here’s what it looks like in SharePoint:

SNAGHTML78aa2cb

 

 

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>