I have the following template which slashes apostrophes:
<xsl:template name="replace">
<xsl:param name="pText"/>
<xsl:param name="pTarget" select='"'"'/>
<xsl:param name="pReplacement" select='"\'"'/>
<xsl:if test="$pText">
<xsl:value-of select='substring-before(concat($pText,$pTarget),$pTarget)'/>
<xsl:if test='contains($pText, $pTarget)'>
<xsl:value-of select="$pReplacement"/>
</xsl:if>
<xsl:call-template name="replace">
<xsl:with-param name="pText" select='substring-after($pText, $pTarget)'/>
<xsl:with-param name="pTarget" select="$pTarget"/>
<xsl:with-param name="pReplacement" select="$pReplacement"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
And then I have the following template which produces share code
<xsl:template name="pageshare">
<xsl:param name="url"/>
<xsl:param name="text"/>
<xsl:call-template name="replace"><xsl:with-param name="pText" select="$text"/></xsl:call-template>
<div class="extpageshare">
<div class="social_icon gplus" onclick="shareSocial('google','{$text}','{$url}')"></div>
<div class="social_icon twitter" onclick="shareSocial('twitter','{$text}','{$url}')"></div>
<div class="social_icon facebook" onclick="shareSocial('facebookshare','{$text}','{$url}')"></div>
<div class="social_icon pinterest" onclick="shareSocial('pinterest','{$text}','{$url}')"></div>
<div class="social_icon email" onclick="shareSocial('email','{$text}','{$url}')"></div>
</div>
</xsl:template>
I'm trying to apply the slashes function in the $text parameter so it can be escaped. I tried calling it in the share code dialog but I dont think Im doing it correctly.
Thanks for the help.
It is difficult to answer your question without having a Minimal, Complete, and Verifiable example to work with. I guess you want to do:
<xsl:template name="pageshare">
<xsl:param name="url"/>
<xsl:param name="text"/>
<xsl:variable name="escaped-text">
<xsl:call-template name="replace">
<xsl:with-param name="pText" select="$text"/>
</xsl:call-template>
</xsl:variable>
<div class="extpageshare">
<div class="social_icon gplus" onclick="shareSocial('google','{$escaped-text}','{$url}')"></div>
<div class="social_icon twitter" onclick="shareSocial('twitter','{$escaped-text}','{$url}')"></div>
<div class="social_icon facebook" onclick="shareSocial('facebookshare','{$escaped-text}','{$url}')"></div>
<div class="social_icon pinterest" onclick="shareSocial('pinterest','{$escaped-text}','{$url}')"></div>
<div class="social_icon email" onclick="shareSocial('email','{$escaped-text}','{$url}')"></div>
</div>
</xsl:template>
Related
I am trying to customize the way the items from an RSS feed is displayed in my RSS viewer web part. I would like to prevent the web part from showing everything after the ellipses (...). For example the text below is the description from my test RSS Viewer Page using the Google News RSS feed:
New Hampshire Visit Offers Glimpse Into Possible Walker, Bush Rivalry
NPR
The two likely Republican presidential front-runners, Wisconsin Gov. Scott Walker and former Florida Gov. Jeb Bush, visited New Hampshire this weekend. Though neither has officially declared their candidacy, The Boston Globe's James Pindell says they're ...
Here's what Jeb is saying when people ask him about the Bush dynastyBusinessinsider India
No longer under the radar, Jeb Bush to tour the state Capitol on ThursdayAtlanta Journal Constitution (blog)
Scott Walker PAC: Jeb Bush is not the only one who can raise moneyCNN International
New Hampshire Public Radio -Petoskey News-Review
all 82 news articles »
I would like to remove everything after the "..." and hence the page would then display :
New Hampshire Visit Offers Glimpse Into Possible Walker, Bush Rivalry NPR The two likely Republican presidential front-runners, Wisconsin Gov. Scott Walker and former Florida Gov. Jeb Bush, visited New Hampshire this weekend. Though neither has officially declared their candidacy, The Boston Globe's James Pindell says they're ...
I haven't really worked with XSLT or XML in the past and hence this is proving quite difficult for me. I have asked a similar question on SharePoint StackExchange but no response yet so I thought I would post on here as well.Thanks for any help.
Edit
Below is the code:
<%# Register TagPrefix="WpNs0" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>
<%-- _lcid="1033" _version="14.0.7006" _dal="1" --%>
<%-- _LocalBinding --%>
<%# Page language="C#" MasterPageFile="~masterurl/default.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" meta:webpartpageexpansion="full" meta:progid="SharePoint.WebPartPage.Document" %>
<%# Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%# Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%# Import Namespace="Microsoft.SharePoint" %> <%# Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%# Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
<SharePoint:ListItemProperty Property="BaseName" maxlength="40" runat="server"/>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">
<WebPartPages:WebPartZone runat="server" title="loc:TitleBar" id="TitleBar" AllowLayoutChange="false" AllowPersonalization="false"><ZoneTemplate>
<WebPartPages:TitleBarWebPart runat="server" AllowEdit="True" AllowConnect="True" ConnectionID="00000000-0000-0000-0000-000000000000" Title="Web Part Page Title Bar" IsIncluded="True" Dir="Default" IsVisible="True" AllowMinimize="False" ExportControlledProperties="True" ZoneID="TitleBar" ID="g_ebad7959_96e5_4485_b67a_ff43ff07343b" HeaderTitle="BlogTestPage" AllowClose="False" FrameState="Normal" ExportMode="All" AllowRemove="False" AllowHide="True" SuppressWebPartChrome="False" DetailLink="" ChromeType="None" HelpLink="" MissingAssembly="Cannot import this Web Part." PartImageSmall="" HelpMode="Modeless" FrameType="None" AllowZoneChange="True" PartOrder="2" Description="" PartImageLarge="" IsIncludedFilter="" __MarkupType="vsattributemarkup" __WebPartId="{EBAD7959-96E5-4485-B67A-FF43FF07343B}" WebPart="true" Height="" Width=""></WebPartPages:TitleBarWebPart>
</ZoneTemplate></WebPartPages:WebPartZone>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderTitleAreaClass" runat="server">
<style type="text/css">
Div.ms-titleareaframe {
height: 100%;
}
.ms-pagetitleareaframe table {
background: none;
}
</style>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">
<meta name="GENERATOR" content="Microsoft SharePoint" />
<meta name="ProgId" content="SharePoint.WebPartPage.Document" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="CollaborationServer" content="SharePoint Team Web Site" />
<script type="text/javascript">
// <![CDATA[
var navBarHelpOverrideKey = "WSSEndUser";
// ]]>
</script>
<SharePoint:UIVersionedContent ID="WebPartPageHideQLStyles" UIVersion="4" runat="server">
<ContentTemplate>
<style type="text/css">
body #s4-leftpanel {
display:none;
}
.s4-ca {
margin-left:0px;
}
</style>
</ContentTemplate>
</SharePoint:UIVersionedContent>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderSearchArea" runat="server">
<SharePoint:DelegateControl runat="server"
ControlId="SmallSearchInputBox"/>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderLeftActions" runat="server">
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageDescription" runat="server">
<SharePoint:ProjectProperty Property="Description" runat="server"/>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderBodyRightMargin" runat="server">
<div height="100%" class="ms-pagemargin"><img src="/_layouts/images/blank.gif" width="10" height="1" alt="" /></div>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageImage" runat="server"></asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderNavSpacer" runat="server"></asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderLeftNavBar" runat="server"></asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr>
<td id="_invisibleIfEmpty" name="_invisibleIfEmpty" valign="top" width="100%">
<WebPartPages:WebPartZone runat="server" Title="loc:FullPage" ID="FullPage" FrameType="TitleBarOnly"><ZoneTemplate>
<WpNs0:RSSAggregatorWebPart runat="server" Description="Displays an RSS feed." ListDisplayName="" ImportErrorMessage="Cannot import this web part." PartOrder="2" HelpLink="" AllowRemove="True" IsVisible="True" AllowHide="True" UseSQLDataSourcePaging="True" ExportControlledProperties="True" IsIncludedFilter="" DataSourceID="" Title="RSS Viewer" ViewFlag="0" NoDefaultStyle="" AllowConnect="True" CacheXslTimeOut="600" FrameState="Normal" PageSize="-1" PartImageLarge="" AsyncRefresh="False" ExportMode="All" Dir="Default" DetailLink="" ShowWithSampleData="False" ListId="00000000-0000-0000-0000-000000000000" FrameType="Default" PartImageSmall="" IsIncluded="True" SuppressWebPartChrome="False" AllowEdit="True" EnableOriginalValue="False" AutoRefresh="False" AutoRefreshInterval="60" AllowMinimize="True" ViewContentTypeId="" InitialAsyncDataFetch="False" ExpandFeed="True" MissingAssembly="Cannot import this web part." HelpMode="Modeless" FeedUrl="http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&output=rss" ListUrl="" ID="g_fd7ba5cc_29e7_4892_9305_3857422aa65a" ConnectionID="00000000-0000-0000-0000-000000000000" AllowZoneChange="True" ManualRefresh="False" __MarkupType="vsattributemarkup" __WebPartId="{FD7BA5CC-29E7-4892-9305-3857422AA65A}" __AllowXSLTEditing="true" WebPart="true" Height="" Width=""><ParameterBindings>
<ParameterBinding Name="RequestUrl" Location="WPProperty[FeedUrl]"/>
</ParameterBindings>
<DataFields>
</DataFields>
<Xsl>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema"
version="1.0" exclude-result-prefixes="xsl ddwrt msxsl rssaggwrt"
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
xmlns:rssaggwrt="http://schemas.microsoft.com/WebParts/v3/rssagg/runtime"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:rssFeed="urn:schemas-microsoft-com:sharepoint:RSSAggregatorWebPart"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:rss1="http://purl.org/rss/1.0/" xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:atom2="http://purl.org/atom/ns#" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:param name="rss_FeedLimit">5</xsl:param>
<xsl:param name="rss_ExpandFeed">false</xsl:param>
<xsl:param name="rss_LCID">1033</xsl:param>
<xsl:param name="rss_WebPartID">RSS_Viewer_WebPart</xsl:param>
<xsl:param name="rss_alignValue">left</xsl:param>
<xsl:param name="rss_IsDesignMode">True</xsl:param>
<xsl:template match="rss" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:rssFeed="urn:schemas-microsoft-com:sharepoint:RSSAggregatorWebPart" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rss1="http://purl.org/rss/1.0/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:atom2="http://purl.org/atom/ns#">
<xsl:call-template name="RSSMainTemplate"/>
</xsl:template>
<xsl:template match="rdf:RDF">
<xsl:call-template name="RDFMainTemplate"/>
</xsl:template>
<xsl:template match="atom:feed">
<xsl:call-template name="ATOMMainTemplate"/>
</xsl:template>
<xsl:template match="atom2:feed">
<xsl:call-template name="ATOM2MainTemplate"/>
</xsl:template>
<xsl:template name="RSSMainTemplate">
<xsl:variable name="Rows" select="channel/item"/>
<xsl:variable name="RowCount" select="count($Rows)"/>
<div class="slm-layout-main" >
<div class="groupheader item medium">
<a href="{ddwrt:EnsureAllowedProtocol(string(channel/link))}">
<xsl:value-of select="channel/title"/>
</a>
</div>
<xsl:call-template name="RSSMainTemplate.body">
<xsl:with-param name="Rows" select="$Rows"/>
<xsl:with-param name="RowCount" select="count($Rows)"/>
</xsl:call-template>
</div>
</xsl:template>
<xsl:template name="RSSMainTemplate.body">
<xsl:param name="Rows"/>
<xsl:param name="RowCount"/>
<xsl:for-each select="$Rows">
<xsl:variable name="CurPosition" select="position()" />
<xsl:variable name="RssFeedLink" select="$rss_WebPartID" />
<xsl:variable name="CurrentElement" select="concat($RssFeedLink,$CurPosition)" />
<xsl:if test="($CurPosition <= $rss_FeedLimit)">
<div class="item link-item" >
<a href="{concat("javascript:ToggleItemDescription('",$CurrentElement,"')")}" >
<xsl:value-of select="title"/>
</a>
<xsl:if test="$rss_ExpandFeed = true()">
<xsl:call-template name="RSSMainTemplate.description">
<xsl:with-param name="DescriptionStyle" select="string('display:block;')"/>
<xsl:with-param name="CurrentElement" select="$CurrentElement"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$rss_ExpandFeed = false()">
<xsl:call-template name="RSSMainTemplate.description">
<xsl:with-param name="DescriptionStyle" select="string('display:none;')"/>
<xsl:with-param name="CurrentElement" select="$CurrentElement"/>
</xsl:call-template>
</xsl:if>
</div>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="RSSMainTemplate.description">
<xsl:param name="DescriptionStyle"/>
<xsl:param name="CurrentElement"/>
<div id="{$CurrentElement}" class="description" align="{$rss_alignValue}" style="{$DescriptionStyle} text-align:{$rss_alignValue};">
<xsl:choose>
<!-- some RSS2.0 contain pubDate tag, some others dc:date -->
<xsl:when test="string-length(pubDate) > 0">
<xsl:variable name="pubDateLength" select="string-length(pubDate) - 3" />
<xsl:value-of select="ddwrt:FormatDate(substring(pubDate,0,$pubDateLength),number($rss_LCID),3)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="ddwrt:FormatDate(string(dc:date),number($rss_LCID),3)"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="string-length(description) > 0">
<xsl:variable name="SafeHtml">
<xsl:call-template name="GetSafeHtml">
<xsl:with-param name="Html" select="description"/>
</xsl:call-template>
</xsl:variable>
- <xsl:value-of select="$SafeHtml" disable-output-escaping="yes"/>
</xsl:if>
<div class="description">
More...
</div>
</div>
</xsl:template>
<xsl:template name="RDFMainTemplate" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:variable name="Rows" select="rss1:item"/>
<xsl:variable name="RowCount" select="count($Rows)"/>
<div class="slm-layout-main" >
<div class="groupheader item medium">
<a href="{ddwrt:EnsureAllowedProtocol(string(rss1:channel/rss1:link))}">
<xsl:value-of select="rss1:channel/rss1:title"/>
</a>
</div>
<xsl:call-template name="RDFMainTemplate.body">
<xsl:with-param name="Rows" select="$Rows"/>
<xsl:with-param name="RowCount" select="count($Rows)"/>
</xsl:call-template>
</div>
</xsl:template>
<xsl:template name="RDFMainTemplate.body" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:param name="Rows"/>
<xsl:param name="RowCount"/>
<xsl:for-each select="$Rows">
<xsl:variable name="CurPosition" select="position()" />
<xsl:variable name="RssFeedLink" select="$rss_WebPartID" />
<xsl:variable name="CurrentElement" select="concat($RssFeedLink,$CurPosition)" />
<xsl:if test="($CurPosition <= $rss_FeedLimit)">
<div class="item link-item" >
<a href="{concat("javascript:ToggleItemDescription('",$CurrentElement,"')")}" >
<xsl:value-of select="rss1:title"/>
</a>
<xsl:if test="$rss_ExpandFeed = true()">
<xsl:call-template name="RDFMainTemplate.description">
<xsl:with-param name="DescriptionStyle" select="string('display:block;')"/>
<xsl:with-param name="CurrentElement" select="$CurrentElement"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$rss_ExpandFeed = false()">
<xsl:call-template name="RDFMainTemplate.description">
<xsl:with-param name="DescriptionStyle" select="string('display:none;')"/>
<xsl:with-param name="CurrentElement" select="$CurrentElement"/>
</xsl:call-template>
</xsl:if>
</div>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="RDFMainTemplate.description" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:param name="DescriptionStyle"/>
<xsl:param name="CurrentElement"/>
<div id="{$CurrentElement}" class="description" align="{$rss_alignValue}" style="{$DescriptionStyle} text-align:{$rss_alignValue};">
<xsl:value-of select="ddwrt:FormatDate(string(dc:date),number($rss_LCID),3)"/>
<xsl:if test="string-length(rss1:description) > 0">
<xsl:variable name="SafeHtml">
<xsl:call-template name="GetSafeHtml">
<xsl:with-param name="Html" select="rss1:description"/>
</xsl:call-template>
</xsl:variable>
- <xsl:value-of select="$SafeHtml" disable-output-escaping="yes"/>
</xsl:if>
<div class="description">
More...
</div>
</div>
</xsl:template>
<xsl:template name="ATOMMainTemplate" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:variable name="Rows" select="atom:entry"/>
<xsl:variable name="RowCount" select="count($Rows)"/>
<div class="slm-layout-main" >
<div class="groupheader item medium">
<a href="{ddwrt:EnsureAllowedProtocol(string(atom:link/#href))}">
<xsl:value-of select="atom:title"/>
</a>
</div>
<xsl:call-template name="ATOMMainTemplate.body">
<xsl:with-param name="Rows" select="$Rows"/>
<xsl:with-param name="RowCount" select="count($Rows)"/>
</xsl:call-template>
</div>
</xsl:template>
<xsl:template name="ATOMMainTemplate.body" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:param name="Rows"/>
<xsl:param name="RowCount"/>
<xsl:for-each select="$Rows">
<xsl:variable name="CurPosition" select="position()" />
<xsl:variable name="RssFeedLink" select="$rss_WebPartID" />
<xsl:variable name="CurrentElement" select="concat($RssFeedLink,$CurPosition)" />
<xsl:if test="($CurPosition <= $rss_FeedLimit)">
<div class="item link-item" >
<a href="{concat("javascript:ToggleItemDescription('",$CurrentElement,"')")}" >
<xsl:value-of select="atom:title"/>
</a>
<xsl:if test="$rss_ExpandFeed = true()">
<xsl:call-template name="ATOMMainTemplate.description">
<xsl:with-param name="DescriptionStyle" select="string('display:block;')"/>
<xsl:with-param name="CurrentElement" select="$CurrentElement"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$rss_ExpandFeed = false()">
<xsl:call-template name="ATOMMainTemplate.description">
<xsl:with-param name="DescriptionStyle" select="string('display:none;')"/>
<xsl:with-param name="CurrentElement" select="$CurrentElement"/>
</xsl:call-template>
</xsl:if>
</div>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="ATOMMainTemplate.description" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:param name="DescriptionStyle"/>
<xsl:param name="CurrentElement"/>
<div id="{$CurrentElement}" class="description" align="{$rss_alignValue}" style="{$DescriptionStyle} text-align:{$rss_alignValue};">
<xsl:value-of select="ddwrt:FormatDate(string(atom:updated),number($rss_LCID),3)"/>
<xsl:choose>
<xsl:when test="string-length(atom:summary) > 0">
<xsl:variable name="SafeHtml">
<xsl:call-template name="GetSafeHtml">
<xsl:with-param name="Html" select="atom:summary"/>
</xsl:call-template>
</xsl:variable>
- <xsl:value-of select="$SafeHtml" disable-output-escaping="yes"/>
</xsl:when>
<xsl:when test="string-length(atom:content) > 0">
<xsl:variable name="SafeHtml">
<xsl:call-template name="GetSafeHtml">
<xsl:with-param name="Html" select="atom:content"/>
</xsl:call-template>
</xsl:variable>
- <xsl:value-of select="$SafeHtml" disable-output-escaping="yes"/>
</xsl:when>
</xsl:choose>
<div class="description">
More...
</div>
</div>
</xsl:template>
<xsl:template name="ATOM2MainTemplate" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:variable name="Rows" select="atom2:entry"/>
<xsl:variable name="RowCount" select="count($Rows)"/>
<div class="slm-layout-main" >
<div class="groupheader item medium">
<a href="{ddwrt:EnsureAllowedProtocol(string(atom2:link/#href))}">
<xsl:value-of select="atom2:title"/>
</a>
</div>
<xsl:call-template name="ATOM2MainTemplate.body">
<xsl:with-param name="Rows" select="$Rows"/>
<xsl:with-param name="RowCount" select="count($Rows)"/>
</xsl:call-template>
</div>
</xsl:template>
<xsl:template name="ATOM2MainTemplate.body" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:param name="Rows"/>
<xsl:param name="RowCount"/>
<xsl:for-each select="$Rows">
<xsl:variable name="CurPosition" select="position()" />
<xsl:variable name="RssFeedLink" select="$rss_WebPartID" />
<xsl:variable name="CurrentElement" select="concat($RssFeedLink,$CurPosition)" />
<xsl:if test="($CurPosition <= $rss_FeedLimit)">
<div class="item link-item" >
<a href="{concat("javascript:ToggleItemDescription('",$CurrentElement,"')")}" >
<xsl:value-of select="atom2:title"/>
</a>
<xsl:if test="$rss_ExpandFeed = true()">
<xsl:call-template name="ATOM2MainTemplate.description">
<xsl:with-param name="DescriptionStyle" select="string('display:block;')"/>
<xsl:with-param name="CurrentElement" select="$CurrentElement"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$rss_ExpandFeed = false()">
<xsl:call-template name="ATOM2MainTemplate.description">
<xsl:with-param name="DescriptionStyle" select="string('display:none;')"/>
<xsl:with-param name="CurrentElement" select="$CurrentElement"/>
</xsl:call-template>
</xsl:if>
</div>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="ATOM2MainTemplate.description" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:param name="DescriptionStyle"/>
<xsl:param name="CurrentElement"/>
<div id="{$CurrentElement}" class="description" align="{$rss_alignValue}" style="{$DescriptionStyle} text-align:{$rss_alignValue};">
<xsl:value-of select="ddwrt:FormatDate(string(atom2:updated),number($rss_LCID),3)"/>
<xsl:choose>
<xsl:when test="string-length(atom2:summary) > 0">
<xsl:variable name="SafeHtml">
<xsl:call-template name="GetSafeHtml">
<xsl:with-param name="Html" select="atom2:summary"/>
</xsl:call-template>
</xsl:variable>
- <xsl:value-of select="$SafeHtml" disable-output-escaping="yes"/>
</xsl:when>
<xsl:when test="string-length(atom2:content) > 0">
<xsl:variable name="SafeHtml">
<xsl:call-template name="GetSafeHtml">
<xsl:with-param name="Html" select="atom2:content"/>
</xsl:call-template>
</xsl:variable>
- <xsl:value-of select="$SafeHtml" disable-output-escaping="yes"/>
</xsl:when>
</xsl:choose>
<div class="description">
More...
</div>
</div>
</xsl:template>
<xsl:template name="GetSafeHtml">
<xsl:param name="Html"/>
<xsl:choose>
<xsl:when test="$rss_IsDesignMode = 'True'">
<xsl:value-of select="$Html"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="rssaggwrt:MakeSafe($Html)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
</Xsl>
<DataSources>
<SharePoint:XmlUrlDataSource runat="server" HttpMethod="GET" SelectCommand="" AuthType="None" XPath=""><DataFileParameters><WebPartPages:DataFormParameter ParameterKey="RequestUrl" PropertyName="ParameterValues" Name="RequestUrl"></WebPartPages:DataFormParameter>
</DataFileParameters>
</SharePoint:XmlUrlDataSource>
</DataSources>
</WpNs0:RSSAggregatorWebPart>
</ZoneTemplate></WebPartPages:WebPartZone> </td>
</tr>
<script type="text/javascript" language="javascript">if(typeof(MSOLayout_MakeInvisibleIfEmpty) == "function") {MSOLayout_MakeInvisibleIfEmpty();}</script>
</table>
</asp:Content>
i've the below xslt
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ntw="Number2Word.uri" exclude-result-prefixes="ntw">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head>
<xsl:text disable-output-escaping="yes"><![CDATA[</meta>]]></xsl:text>
<link rel="stylesheet" href="C:\Documents and Settings\u0138039\Desktop\Per\NEW.css" type="text/css"></link>
</head>
<body>
<section class="tr_chapter">
<div class="chapter">
<xsl:apply-templates/>
</div>
</section>
</body>
</html>
</xsl:template>
<xsl:template match="case">
<xsl:apply-templates select="case.head"/>
</xsl:template>
<xsl:template match="case.head">
<div class="section-sect0">
<div class="para">
<xsl:value-of select="./party.line/party[#role='Plaintiff']"/>
</div>
</div>
<div class="section-sect0">
<div class="para">
<xsl:text disable-output-escaping="yes">V</xsl:text>
</div>
</div>
<div class="section-sect0">
<div class="para">
<xsl:value-of select="./party.line/party[#role='Defendant']"/>
</div>
</div>
<xsl:apply-templates select="case.ref.no.group | judge.line"/>
</xsl:template>
<xsl:template match="para">
<div class="para">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="case.ref.no.group">
<div class="section-sect3">
<span class="font-style-bold">Court of Appeal</span>
<xsl:text> - </xsl:text>
<xsl:value-of select="case.ref.no[1]/prefix" />
<xsl:text> Nos. </xsl:text>
<xsl:for-each select="case.ref.no">
<xsl:value-of select="number" />
<xsl:text>-</xsl:text>
<xsl:value-of select="year" />
<xsl:if test="not(position() = 2)">
</xsl:if>
</xsl:for-each>
</div>
</xsl:template>
<xsl:template match="judge.line">
<div class="section-sect3">
<xsl:for-each select="judge">
<xsl:value-of select="name"/>
<xsl:if test="not(position() = last())">
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text> JC</xsl:text>
</div>
<xsl:apply-templates select="following-sibling::date.group"></xsl:apply-templates>
</xsl:template>
<xsl:template match="date.group">
<div class="section-sect4">
<div class="para">
<xsl:value-of select="./date.line/date"/>
</div>
</div>
<xsl:apply-templates select="//catchwords.group"/>
</xsl:template>
<xsl:template match="catchwords.group">
<div class="y">
<xsl:for-each select="catchwords/catchword">
<xsl:choose>
<xsl:when test="#level=1"><br/>
<span class="font-style-bolditalic">
<xsl:value-of select="."/>
</span>
<xsl:text disable-output-escaping="yes">-</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select=".">
<xsl:value-of select="."></xsl:value-of>
<xsl:if test="not(position() = last()-1)">
<xsl:text disable-output-escaping="yes"> – </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</div>
<xsl:apply-templates select="//headnotes"/>
</xsl:template>
<xsl:template match="headnotes/para">
<xsl:choose>
<xsl:when test="position()=1">
<div class="x">
<xsl:apply-templates></xsl:apply-templates>
</div>
</xsl:when>
<xsl:otherwise>
<div class="m">
<xsl:apply-templates/>
</div>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="para.group"/>
</xsl:template>
<xsl:template match="para.group">
<div class="section-sect1">
<xsl:value-of select="./heading"/>
</div>
<xsl:for-each select="./para">
<xsl:apply-templates select="node()[not(self::label)]"/>
</xsl:for-each>
<xsl:apply-templates select="//counsel.group"/>
</xsl:template>
<xsl:template name="orderedlist" match="list">
<ol class="eng-orderedlist orderedlist">
<xsl:apply-templates select="list.item/label"/>
</ol>
</xsl:template>
<xsl:template name="orderitempara" match="list.item/label">
<li class="item">
<div class="para">
<span class="item-num">
<xsl:choose>
<xsl:when test="following-sibling::case.considered">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</span>
<xsl:apply-templates select="parent::list.item"/>
</div>
</li>
</xsl:template>
<xsl:template match="list.item">
<xsl:variable name="a">
<xsl:value-of select="./label"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="./label">
<xsl:apply-templates select="child::node()[not(self::label|case.ref)]"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="counsel.group" name="j">
<div class="ital">
<xsl:for-each select="./counsel.line">
<div class="para">
<xsl:value-of select="."/>
</div>
</xsl:for-each>
<xsl:text disable-output-escaping="yes">Judgment received: December 4, 2008</xsl:text>
</div>
<xsl:apply-templates select="//ref.group"/>
</xsl:template>
<xsl:template match="ref.group/leg.mentioned">
<div class="section-sect1">
<xsl:text>Legislation mentioned in the judgment</xsl:text>
</div>
<xsl:for-each select="./leg.ref">
<div class="para">
<xsl:value-of select="./citetitle"/>
<xsl:text>, </xsl:text>
<xsl:for-each select="./leg.ptr.group/leg.ptr">
<xsl:value-of select="."/>
<xsl:if test="not(position() = last())">
<xsl:text disable-output-escaping="yes">, </xsl:text>
</xsl:if>
</xsl:for-each>
</div>
</xsl:for-each>
<xsl:text>Cases cited in the judgment</xsl:text>
<xsl:for-each select="//citetitle">
<xsl:if test="parent::case.ref/#annotation">
<div class="ital">
<div class="para">
<xsl:value-of select="."/>
<xsl:value-of select="//citecitation"/>
<xsl:value-of select="parent::case.ref/#court"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="parent::case.ref/#annotation"/>
<xsl:text>)</xsl:text>
</div>
</div>
</xsl:if>
</xsl:for-each>
<xsl:apply-templates select="//judgment"/>
</xsl:template>
<xsl:template match="judgment">
<div class="section-sect1">
<xsl:value-of select="./judge.block/heading/judgename"/>
</div>
<xsl:for-each select="./judge.block/para">
<div class="para">
<span class="new">
<xsl:value-of select="./label"></xsl:value-of>
</span>
<xsl:value-of select="./text()"/>
</div>
<xsl:apply-templates select="./list"/>
</xsl:for-each>
<xsl:for-each select="./judge.block/para.group">
<xsl:if test="./heading">
<div class="section-sect1">
<xsl:value-of select="./heading/text()"/>
</div>
</xsl:if>
<xsl:for-each select="para">
<div class="para">
<span class="new">
<xsl:value-of select="./label"></xsl:value-of>
</span>
<xsl:apply-templates select="child::node()[not(self::label)]"/>
</div>
<xsl:apply-templates select="./list"/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template match="emphasis">
<xsl:choose>
<xsl:when test="citetitle">
<span class="font-style-italic">
<xsl:apply-templates select="./list.item"/>
</span>
</xsl:when>
<xsl:when test="./#type">
<xsl:variable name="fontStyle">
<xsl:value-of select="concat('font-style-',#type)"/>
</xsl:variable>
<span class="{$fontStyle}">
<xsl:apply-templates/>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
when i apply this on my below part of my xml it is giving me a stackoverflow error.
<?xml version="1.0" encoding="UTF-8"?>
<case>
<counsel.group>
<counsel.line>Azar Irwan b Moh Arifin (AG’s Chambers) for Public Prosecutor</counsel.line>
<counsel.line>SK Pari (Pari & Co) for first accused</counsel.line></counsel.group>
<ref.group>
<leg.mentioned>
<leg.ref country="India">
<citetitle type="leg" legtype="ord">Indian Penal Code</citetitle>
<leg.ptr.group>
<leg.ptr provision="s" print="yes">302</leg.ptr>
</leg.ptr.group>
</leg.ref>
<leg.ref country="Malaysia">
<citetitle type="leg" legtype="ord">Criminal Procedure Code</citetitle>
<leg.ptr.group>
<leg.ptr provision="ss" print="yes">112</leg.ptr>
<leg.ptr provision="s" print="no">112</leg.ptr>
</leg.ptr.group>
</leg.ref>
<leg.ref country="Malaysia">
<citetitle type="leg" legtype="ord">Penal Code</citetitle>
<leg.ptr.group>
<leg.ptr provision="ss" print="yes">109</leg.ptr>
<leg.ptr provision="s" print="no">299</leg.ptr>
</leg.ptr.group>
</leg.ref>
</leg.mentioned></ref.group>
</case>
please let me know how do i resolve this error and what are the steps to be followed so that in future i don't encounter this error.
Thanks
Your XSLT contains an infinite loop. Your para.group template contains this:
<xsl:apply-templates select="//counsel.group"/>
And then the template for counsel.group has this:
<xsl:apply-templates select="//ref.group"/>
The template for ref.group has this:
<xsl:apply-templates select="//judgment"/>
The template for judgment has this:
<xsl:for-each select="para">
...
<xsl:apply-templates select="child::node()[not(self::label)]"/>
...
</xsl:for-each>
Which cascades down to apply templates on a para.group and then you're back at the beginning. This process goes around in circles until the stack overflows. I think you need to rethink your XSLT to figure out how to prevent infinite recursion.
i have the below xslt.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ntw="Number2Word.uri" exclude-result-prefixes="ntw">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head>
<xsl:text disable-output-escaping="yes"><![CDATA[</meta>]]></xsl:text>
<link rel="stylesheet" href="C:\Documents and Settings\u0138039\Desktop\Per\NEW.css" type="text/css"></link>
</head>
<body>
<section class="tr_chapter">
<div class="chapter">
<xsl:apply-templates/>
</div>
</section>
</body>
</html>
</xsl:template>
<xsl:template match="case">
<xsl:apply-templates select="case.head"/>
</xsl:template>
<xsl:template match="case.head">
<div class="section-sect0">
<div class="para">
<xsl:value-of select="./party.line/party[#role='Plaintiff']"/>
</div>
</div>
<div class="section-sect0">
<div class="para">
<xsl:text disable-output-escaping="yes">V</xsl:text>
</div>
</div>
<div class="section-sect0">
<div class="para">
<xsl:value-of select="./party.line/party[#role='Defendant']"/>
</div>
</div>
<xsl:apply-templates select="case.ref.no.group | judge.line"/>
</xsl:template>
<xsl:template match="para">
<div class="para">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="case.ref.no.group">
<div class="section-sect3">
<span class="font-style-bold">Court of Appeal</span>
<xsl:text> - </xsl:text>
<xsl:value-of select="case.ref.no[1]/prefix" />
<xsl:text> Nos. </xsl:text>
<xsl:for-each select="case.ref.no">
<xsl:value-of select="number" />
<xsl:text>-</xsl:text>
<xsl:value-of select="year" />
<xsl:if test="not(position() = 2)">
</xsl:if>
</xsl:for-each>
</div>
</xsl:template>
<xsl:template match="judge.line">
<div class="section-sect3">
<xsl:for-each select="judge">
<xsl:value-of select="name"/>
<xsl:if test="not(position() = last())">
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text> JC</xsl:text>
</div>
<xsl:apply-templates select="following-sibling::date.group"></xsl:apply-templates>
</xsl:template>
<xsl:template match="date.group">
<div class="section-sect4">
<div class="para">
<xsl:value-of select="./date.line/date"/>
</div>
</div>
<xsl:apply-templates select="//catchwords.group"/>
</xsl:template>
<xsl:template match="catchwords.group">
<div class="y">
<xsl:for-each select="catchwords/catchword">
<xsl:choose>
<xsl:when test="#level=1"><br/>
<span class="font-style-bolditalic">
<xsl:value-of select="."/>
</span>
<xsl:text disable-output-escaping="yes">-</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select=".">
<xsl:value-of select="."></xsl:value-of>
<xsl:if test="not(position() = last()-1)">
<xsl:text disable-output-escaping="yes"> – </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</div>
<xsl:apply-templates select="//headnotes"/>
</xsl:template>
<xsl:template match="headnotes/para">
<xsl:choose>
<xsl:when test="position()=1">
<div class="x">
<xsl:apply-templates></xsl:apply-templates>
</div>
</xsl:when>
<xsl:otherwise>
<div class="m">
<xsl:apply-templates/>
</div>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="para.group"/>
</xsl:template>
<xsl:template match="para.group">
<div class="section-sect1">
<xsl:value-of select="./heading"/>
</div>
<xsl:for-each select="./para">
<xsl:apply-templates select="node()[not(self::label)]"/>
</xsl:for-each>
<xsl:apply-templates select="//counsel.group"/>
</xsl:template>
<xsl:template name="orderedlist" match="list">
<ol class="eng-orderedlist orderedlist">
<xsl:apply-templates select="list.item/label"/>
</ol>
</xsl:template>
<xsl:template name="orderitempara" match="list.item/label">
<li class="item">
<div class="para">
<span class="item-num">
<xsl:choose>
<xsl:when test="following-sibling::case.considered">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</span>
<xsl:apply-templates select="parent::list.item"/>
</div>
</li>
</xsl:template>
<xsl:template match="list.item">
<xsl:variable name="a">
<xsl:value-of select="./label"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="./label">
<xsl:apply-templates select="child::node()[not(self::label|case.ref)]"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="counsel.group" name="j">
<div class="ital">
<xsl:for-each select="./counsel.line">
<div class="para">
<xsl:value-of select="."/>
</div>
</xsl:for-each>
<xsl:text disable-output-escaping="yes">Judgment received: December 4, 2008</xsl:text>
</div>
<xsl:apply-templates select="//ref.group"/>
</xsl:template>
<xsl:template match="ref.group/leg.mentioned">
<div class="section-sect1">
<xsl:text>Legislation mentioned in the judgment</xsl:text>
</div>
<xsl:for-each select="./leg.ref">
<div class="nomar">
<xsl:value-of select="./#country"/>
</div>
<div class="para">
<xsl:value-of select="./citetitle"/>
<xsl:text>, </xsl:text>
<xsl:for-each select="./leg.ptr.group/leg.ptr">
<xsl:value-of select="."/>
<xsl:if test="not(position() = last())">
<xsl:text disable-output-escaping="yes">, </xsl:text>
</xsl:if>
</xsl:for-each>
</div>
</xsl:for-each>
<div class="section-sect1">
<xsl:text>Cases cited in the judgment</xsl:text>
</div>
<xsl:apply-templates select="//case.considered"/>
<div class="section-sec1">
<xsl:apply-templates select="//other.mentioned"/>
</div>
</xsl:template>
<xsl:template match="case.considered">
<xsl:for-each select=".">
<xsl:if test="./case.ref">
<div class="para">
<span class="font-style-italic">
<xsl:value-of select="./case.ref/citetitle[#full]"/></span>
<xsl:text> </xsl:text>
<xsl:value-of select="./case.ref/citecitation/#full"/>
</div>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="other.mentioned/other.ref">
<div class="para">
<xsl:value-of select="./author"/>
<xsl:text>, </xsl:text>
<span class="font-style-italic">
<xsl:value-of select="./book.title"/>
</span>
<xsl:text>, </xsl:text>
<xsl:value-of select="ed_vol"/>
<xsl:value-of select="./ref_grp/reference/pageno"/>
</div>
<xsl:apply-templates select="//judgment"/>
</xsl:template>
<xsl:template match="judgment">
<div class="section-sect1">
<xsl:value-of select="./judge.block/heading"/>
</div>
<!--<xsl:for-each select="./judge.block/para.group">
--><!--<div class="para">
<span class="new">
<xsl:value-of select="./label"></xsl:value-of>
</span>
<xsl:value-of select="./text()"/>
</div>
<xsl:apply-templates select="./list"/>--><!--
<xsl:apply-templates/>
</xsl:for-each>-->
<xsl:apply-templates select="./judge.block/para.group"/>
</xsl:template>
<xsl:template match="judge.block/para.group">
<div class="section-sect1">
<xsl:apply-templates select="./heading"/>
</div>
<xsl:for-each select="./para">
<div class="para">
<span class="new">
<xsl:value-of select="./label"/></span>
<xsl:apply-templates select="./text()"/>
</div>
<xsl:if test="./block.quote">
<xsl:for-each select="./block.quote/para.group">
<div class="ali-itl">
<xsl:value-of select="./heading"/>
</div>
<xsl:for-each select="./para.group">
<div class="ali-itl">
<xsl:value-of select="./heading"/>
</div>
<div class="extract">
<div class="para">
<xsl:apply-templates select="./para"/>
</div></div>
</xsl:for-each>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="./para.group">
<xsl:if test="./para.group">
<xsl:choose>
<xsl:when test="not(./para)">
<div class="ital">
<xsl:apply-templates select="./heading"/>
</div></xsl:when>
<xsl:otherwise>
<div class="ali-itl">
<xsl:value-of select="./heading"/>
</div>
<div class="para">
<span class="new">
<xsl:value-of select="./para/label"/>
</span>
<xsl:value-of select="./para/text()"/>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
<xsl:if test="./block.quote">
<xsl:for-each select="./block.quote/para.group">
<div class="ali-itl">
<xsl:value-of select="./heading"/>
</div>
<xsl:for-each select="./para.group">
<div class="ali-itl">
<xsl:value-of select="./heading"/>
</div>
<div class="extract">
<div class="para">
<div class="new">
<xsl:value-of select="./para/label"/>
</div>
<xsl:apply-templates select="./para/text()"/>
</div></div>
</xsl:for-each>
</xsl:for-each>
</xsl:if>
</xsl:template>
<xsl:template match="emphasis">
<xsl:choose>
<xsl:when test="citetitle">
<span class="font-style-italic">
<xsl:apply-templates select="./list.item"/>
</span>
</xsl:when>
<xsl:when test="./#type">
<xsl:variable name="fontStyle">
<xsl:value-of select="concat('font-style-',#type)"/>
</xsl:variable>
<span class="{$fontStyle}">
<xsl:apply-templates/>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
and when i use it on my xml, the output is skipping the content in between(for example i am able to see content with number[12] and then it is directly jumping to content in number [16] and the content in between is skipped). the xml can be found in the following link.
XML Doc. please let me know where am i going wrong.
Thanks
It is really hard to tell from the information you gave, but I think your problem comes from the fact that the "para" elements with the "labels" 13-15 actually lie within a nested second para.group element within the first one.
Your template probably only matches "para" elements directly within "para.group" elements, but not nested "para.group" elements.
As an outsider, it's basically impossible to tell without investing way too much time in analyzing the huge input you gave, which is probably why you didn't receive another answer up until now.
I am using xslt and I want to implement sorting on my href link.
below is the xslt part where I need to implement sorting.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tlink="urn:TridionLinking" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:utils="urn:XSLTExtensions" exclude-result-prefixes="xsl xlink tlink msxsl utils">
<xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="yes" />
<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Title: View All the Destinations XHTML
Description: Render view all the destinations control
Author: Manoj Singh
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
<xsl:include href="dynamic_linking.xslt"/>
<!-- Translations are still loaded here because of XHTML content, research a way around that -->
<xsl:key name="kCityById" match="city" use="#id"/>
<xsl:variable name="vLocations" select="document(concat($publicationPath, /list/resources/#location))/list"/>
<xsl:variable name="destination" select="/list"/>
<xsl:param name="publicationPath"/>
<xsl:param name="pubURL"/>
<xsl:param name="pageURL"/>
<xsl:param name="region"/>
<xsl:param name="country"/>
<!-- offset controls the starting position of the results to show -->
<xsl:param name="offset">0</xsl:param>
<!-- blockSize controls how many results to show on a single page -->
<xsl:param name="blockSize" select="15" />
<!-- Amount of page links to show by default -->
<xsl:param name="pagesShown">20</xsl:param>
<xsl:variable name="totalHits" select="count(/list/destination[contains(concat($pubURL,#url),substring-before($pageURL,'/index.aspx'))])" />
<xsl:template name="calcStart">
<xsl:choose>
<xsl:when test="$offset = 0">1</xsl:when>
<xsl:otherwise>
<xsl:value-of select="($offset * $blockSize) + 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="calcEnd">
<xsl:choose>
<xsl:when test="(($offset + 1) * $blockSize) > $totalHits">
<xsl:value-of select="$totalHits"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="($offset + 1) * $blockSize"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="pageNavigation">
<xsl:param name="pageCount"/>
<xsl:param name="currPage"/>
<xsl:param name="showPages">
<xsl:choose>
<xsl:when test="$pagesShown > $pageCount">
<xsl:value-of select="$pageCount"/>
</xsl:when>
<xsl:when test="($pagesShown mod 2) = 0">
<xsl:value-of select="$pagesShown"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$pagesShown + 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="currEntry" select="1"/>
<xsl:param name="offset">
<xsl:choose>
<xsl:when test="($currPage < $showPages) or ($pageCount = 1)">0</xsl:when>
<xsl:when test="$currPage > ($pageCount - $showPages + 1)">
<xsl:value-of select="$pageCount - $showPages"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$currPage - ($showPages div 2) - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:param>
<!-- Header Processing -->
<xsl:if test="$currEntry = 1">
<xsl:if test="($pageCount > $showPages) and ($currPage >= $showPages)">
<li>... </li>
</xsl:if>
</xsl:if>
<xsl:if test="not ($currEntry > $showPages)">
<li>
<xsl:choose>
<xsl:when test="($currEntry + $offset) = $currPage">
<strong class="thisPage">
<xsl:value-of select="$currEntry + $offset"/>
</strong>
</xsl:when>
<xsl:otherwise>
<a href="{utils:GetHashedUrl(concat($pageURL,'?offset=',$currEntry + $offset - 1,'&blockSize=',$blockSize,'&pagesShown=',$pagesShown))}">
<xsl:value-of select="$currEntry + $offset"/>
</a>
</xsl:otherwise>
</xsl:choose>
</li>
<xsl:if test="not ($currEntry >= $showPages)">
<li class="separatorLine">|</li>
</xsl:if>
<xsl:call-template name="pageNavigation">
<xsl:with-param name="pageCount" select="$pageCount"/>
<xsl:with-param name="currPage" select="$currPage"/>
<xsl:with-param name="showPages" select="$showPages"/>
<xsl:with-param name="currEntry" select="$currEntry + 1"/>
<xsl:with-param name="offset" select="$offset"/>
</xsl:call-template>
</xsl:if>
<!-- Footer Processing -->
<xsl:if test="$currEntry = 1">
<xsl:if test="($pageCount > $showPages) and (($pageCount - $currPage + 1) >= $showPages)">
<li> ...</li>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template name="displayPageNavigation">
<div class="continueBar">
<div class="continueBarLeft">
<xsl:variable name="displayStart">
<xsl:call-template name="calcStart"/>
</xsl:variable>
<xsl:variable name="displayEnd">
<xsl:call-template name="calcEnd"/>
</xsl:variable>
<strong>
<xsl:value-of select="utils:TextFormatted('DisplayingDestinations2Arg', concat($displayStart, '-', $displayEnd), $totalHits)"/>
</strong>
</div>
<div class="continueBarRight">
<ul class="paginationLinks">
<!-- Show a back button when available -->
<xsl:choose>
<xsl:when test="$offset > 0">
<li class="noBorder first">
<a class="iconButtonBackBar" href="{$pageURL}?offset={$offset - 1}&blockSize={$blockSize}&pagesShown={$pagesShown}">
<xsl:text disable-output-escaping="yes"> </xsl:text>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<li class="noBorder first">
<span class="iconButtonBackBarOff">
<xsl:text disable-output-escaping="yes"> </xsl:text>
</span>
</li>
</xsl:otherwise>
</xsl:choose>
<!-- Output the page navigation links -->
<xsl:call-template name="pageNavigation">
<xsl:with-param name="pageCount">
<xsl:choose>
<xsl:when test="$blockSize >= $totalHits">1</xsl:when>
<xsl:when test="($totalHits mod $blockSize) != 0">
<xsl:value-of select="ceiling($totalHits div $blockSize)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$totalHits div $blockSize"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="currPage" select="$offset + 1"/>
</xsl:call-template>
<!-- Show a next button when available -->
<xsl:choose>
<xsl:when test="(($offset + 1) * $blockSize) > $totalHits">
<li class="last">
<span class="iconButtonForwardBarOff">
<xsl:text disable-output-escaping="yes"> </xsl:text>
</span>
</li>
</xsl:when>
<xsl:otherwise>
<li class="last">
<a class="iconButtonForwardBar" href="{$pageURL}?offset={$offset + 1}&blockSize={$blockSize}&pagesShown={$pagesShown}">
<xsl:text disable-output-escaping="yes"> </xsl:text>
</a>
</li>
</xsl:otherwise>
</xsl:choose>
</ul>
</div>
<div class="clearBoth">
<xsl:comment/>
</div>
</div>
</xsl:template>
<!-- root match -->
<xsl:template match="/list">
<!--<xsl:value-of select="$publicationPath"/>-->
<div class="brownBarContainer">
<div class="brownBar">
All Destinations
</div>
</div>
<table width="100%" cellspacing="0" cellpadding="0" border="0" class="displayTable">
<tbody>
<tr>
<th scope="col" class="first sortSelected">
<div class="thPadding">
<xsl:element name="a">
<xsl:attribute name="href"></xsl:attribute>
<xsl:attribute name="class">iconDownSortArrow</xsl:attribute>
</xsl:element>Destination
</div>
</th>
<th scope="col" class="sortHover">
<div class="thPadding">
<xsl:element name="a">
<xsl:attribute name="href"></xsl:attribute>
<xsl:attribute name="class">iconSortArrowOff</xsl:attribute>
</xsl:element>Country
</div>
</th>
<th scope="col" class="sortHover">
<div class="thPadding">
<xsl:element name="a">
<xsl:attribute name="href"></xsl:attribute>
<xsl:attribute name="class">iconSortArrowOff</xsl:attribute>
</xsl:element>Region
</div>
</th>
</tr>
<xsl:choose>
<xsl:when test="$region='' and $country=''">
<xsl:apply-templates select="destination">
<xsl:sort select="#title" order="ascending" />
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$country!=''">
<xsl:apply-templates select="destination[city/#id=$vLocations/region/country[#id=$country]/city/#id]">
<xsl:sort select="#title" order="ascending" />
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$region!=''">
<xsl:apply-templates select="destination[city/#id=$vLocations/region[#id=$region]/country/city/#id]">
<xsl:sort select="#title" order="ascending" />
</xsl:apply-templates>
</xsl:when>
</xsl:choose>
</tbody>
</table>
<div class="horRuleWhite">
<hr/>
</div>
<xsl:call-template name="displayPageNavigation" />
</xsl:template>
<xsl:template match="text()"/>
<xsl:template match="destination">
<xsl:variable name="vReverseURL">
<xsl:call-template name="reverse">
<xsl:with-param name="string" select="#url"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="vCountryURL">
<xsl:call-template name="reverse">
<xsl:with-param name="string" select="substring-after($vReverseURL,'/')"/>
</xsl:call-template>
<xsl:text>/index.aspx</xsl:text>
</xsl:variable>
<xsl:variable name="vRegionURL">
<xsl:call-template name="reverse">
<xsl:with-param name="string" select="substring-after(substring-after($vReverseURL,'/'),'/')"/>
</xsl:call-template>
<xsl:text>/index.aspx</xsl:text>
</xsl:variable>
<xsl:variable name="current" select="."/>
<xsl:for-each select="$vLocations">
<tr>
<td class="detail first">
<a class="arrowSmallFront" href="{$current/#url}">
<xsl:value-of select="$current/#title"/>
</a>
</td>
<td class="detail noLeftBorder">
<a class="arrowSmallFront" href="{$vCountryURL}">
<xsl:value-of select="key('kCityById',$current/city/#id)/../#name"/>
</a>
</td>
<td class="detail noLeftBorder">
<a class="arrowSmallFront" href="{$vRegionURL}">
<xsl:value-of select="key('kCityById',$current/city/#id)/../../#name"/>
</a>
</td>
</tr>
</xsl:for-each>
</xsl:template>
<xsl:template name="reverse">
<xsl:param name="string" select="''"/>
<xsl:if test="$string != ''">
<xsl:call-template name="reverse">
<xsl:with-param name="string" select="substring($string,2)"/>
</xsl:call-template>
<xsl:value-of select="substring($string,1,1)"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Now everything is working fine, however I want to implement sorting on the href link in above xslt.
<tr>
<th scope="col" class="first sortSelected">
<div class="thPadding">
<xsl:element name="a">
<xsl:attribute name="href"></xsl:attribute>
<xsl:attribute name="class">iconDownSortArrow</xsl:attribute>
</xsl:element>Destination
</div>
</th>
<th scope="col" class="sortHover">
<div class="thPadding">
<xsl:element name="a">
<xsl:attribute name="href"></xsl:attribute>
<xsl:attribute name="class">iconSortArrowOff</xsl:attribute>
</xsl:element>Country
</div>
</th>
<th scope="col" class="sortHover">
<div class="thPadding">
<xsl:element name="a">
<xsl:attribute name="href"></xsl:attribute>
<xsl:attribute name="class">iconSortArrowOff</xsl:attribute>
</xsl:element>Region
</div>
</th>
</tr>
1) Destinations.xml
<?xml version="1.0"?>
<list type="Destinations">
<resources location="include/xml/locations.xml">
<publication>481</publication>
</resources>
<destination id="594051" title="Sydney" url="/asiapacific/australia/sydney.aspx" >
<city id="192409" />
</destination>
<destination id="594088" title="Brisbane" url="/asiapacific/australia/brisbane.aspx" >
<city id="192397" />
</destination>
<destination id="594579" title="Dubai" url="/middleeast/uae/dubai.aspx" >
<city id="192855" />
</destination>
<destination id="594580" title="Abu Dhabi" url="/middleeast/uae/abudhabi.aspx" >
<city id="192851" />
</destination>
</list>
2) Locations.xml
<?xml version="1.0"?>
<list type="Locations">
<region id="192393" code="ASIA" name="Asia & the Pacific" shortname="Asia & the Pacific">
<country id="192395" code="AU" name="Australia" shortname="Australia">
<city id="192397" code="BNE" name="Brisbane" shortname="Brisbane">
<airport id="192399" code="BNE" name="Brisbane International Airport" shortname="Brisbane"></airport>
</city>
<city id="192409" code="SYD" name="Sydney" shortname="Sydney">
<airport id="192411" code="SYD" name="Kingsford Smith Airport" shortname="Sydney"></airport>
</city>
</country>
</region>
<region id="192847" code="MEAF" name="The Middle East & Africa" shortname="The Middle East & Africa">
<country id="192849" code="AE" name="United Arab Emirates" shortname="United Arab Emirates">
<city id="192851" code="AUH" name="Abu Dhabi" shortname="Abu Dhabi">
<airport id="192853" code="AUH" name="Abu Dhabi" shortname="Abu Dhabi"></airport>
</city>
<city id="192855" code="DXB" name="Dubai" shortname="Dubai">
<airport id="192857" code="DXB" name="Dubai International Airport" shortname="Dubai"></airport>
</city>
</country>
</region>
</list>
Please suggest!
Thanks.
Before each close tag </xsl:apply-templates> you need to include an <xsl:sort>, e.g.
<xsl:when test="$region='' and $country=''">
<xsl:apply-templates select="destination">
<xsl:sort select="#href" />
</xsl:apply-templates>
</xsl:when>
The above code assumes that #href is an attribute of the destination element, but that's just a guess, since you haven't told us where #href appears in the input. Unless I missed something.
If you need further help please post a sample of your input XML.
On second reading, I wonder if you mean that you want to sort based on which of the three a elements is clicked on? Please clarify, and edit your question to include a sample of your input XML.
OK, based on your comment it's clear that you want to sort based on whichever column the user clicked on last.
To expand on what Alejandro was saying, interactive behavior is outside the scope of XSLT. If you want XSLT to sort based on varying columns, you need to pass that column to the XSLT as an initial parameter. If the XSLT is running on the server, the whole page will reload when you change the sort order of the table. Do you want that?
For instant sorting you could call the XSLT within js on the client, but that's a bit hairy. Usually for interactive sorting, people just sort directly in javascript. Here are some tutorials and implementations:
http://www.javascripttoolbox.com/lib/table/
http://neil.fraser.name/software/tablesort/
http://dynamictable.com/
I have the following XSLT:
<xsl:template match="/">
<div id="dokumentliste">
<xsl:variable name="alleNyheder" select="$currentPage//node" />
<xsl:for-each select="$alleNyheder">
<xsl:sort data-type="text" select="#createDate" order="descending" />
<xsl:if test="./data[#alias='manchet'] != ''">
<div class="newsitem">
<h2>
<xsl:value-of select="./data[#alias='title']"/>
</h2>
<xsl:if test="./data[#alias = 'manchet'] != ''">
<div class="nyhedContent">
<p>
<span class="dokumentListeDato">
<xsl:choose>
<xsl:when test="./data[#alias='date'] != ''">
<xsl:value-of select="umbraco.library:FormatDateTime(./data[#alias='date'], 'dd. MMMM yyyy')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="umbraco.library:FormatDateTime(./#createDate, 'dd. MMMM yyyy')"/>
</xsl:otherwise>
</xsl:choose>
</span>
<xsl:value-of select="./data[#alias = 'manchet']"/>
</p>
</div>
</xsl:if>
<div class="dokumentListe_laes_mere">
<a href="{umbraco.library:NiceUrl(#id)}">
Læs mere<img src="/frontend/images/macro/macro_laes_mere.png" alt="Læs mere"/>
</a>
</div>
</div>
<!-- End newsitem -->
</xsl:if>
</xsl:for-each>
</div>
</xsl:template>
I am making a newslist, and would like to make some sort of pagination. Almost the same one as seen on Google. You know "the usual one".
But I can't figure out how to do this.
The number of newsitems on each page isn't that important, but lets say 10 on each page. When the 10 first newsitems are shown, I would like the pagination to show up. With the "Next" and "Previous" buttons to the right and the left of the numbers.
Is it possible to make this, and have I explained my problem good enough? I use the Umbraco CMS by the way :)
Thank you very much.
-Kim
Something like this:
I've left some code in there for dealing with images in your listing too :-)
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:variable name="recordsPerPage" select="2"/>
<xsl:variable name="pageNumber">
<xsl:choose>
<!-- first page -->
<xsl:when test="umbraco.library:RequestQueryString('page') <= 0 or string(umbraco.library:RequestQueryString('page')) = '' or string(umbraco.library:RequestQueryString('page')) = 'NaN'">0</xsl:when>
<!-- what was passed in -->
<xsl:otherwise>
<xsl:value-of select="umbraco.library:RequestQueryString('page')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="numberOfRecords" select="count($currentPage/node)"/>
<!-- The fun starts here -->
<xsl:call-template name="pagination">
<xsl:with-param name="pageNumber" select="$pageNumber"/>
<xsl:with-param name="recordsPerPage" select="$recordsPerPage" />
<xsl:with-param name="numberOfRecords" select="$numberOfRecords" />
</xsl:call-template>
<ul class="listing self-clear">
<xsl:for-each select="$currentPage/node [string(data [#alias='umbracoNaviHide']) != '1']">
<xsl:sort order="descending" select="data[#alias='releasedOn']"></xsl:sort>
<xsl:if test="position() > $recordsPerPage * number($pageNumber) and position() <= number($recordsPerPage * number($pageNumber) + $recordsPerPage )">
<li>
<xsl:attribute name="class">
<xsl:if test="data[#alias='image'] = ''">
no-img
</xsl:if>
<xsl:if test="position() = $recordsPerPage * (number($pageNumber) + 1)">
last
</xsl:if>
</xsl:attribute>
<h3>
<a href="{umbraco.library:NiceUrl(#id)}">
<xsl:value-of select="#nodeName"/>
</a>
</h3>
<xsl:if test="data[#alias='image'] != ''">
<img src="{data[#alias='image']}" class="drop-shadow" />
</xsl:if>
<p class="date"><xsl:value-of select="umbraco.library:LongDate(data[#alias='releasedOn'])"/></p>
<xsl:value-of select="data[#alias='abstract']" disable-output-escaping="yes"/>
Read More
</li>
</xsl:if>
</xsl:for-each>
</ul>
<xsl:call-template name="pagination">
<xsl:with-param name="pageNumber" select="$pageNumber"/>
<xsl:with-param name="recordsPerPage" select="$recordsPerPage" />
<xsl:with-param name="numberOfRecords" select="$numberOfRecords" />
</xsl:call-template>
</xsl:template>
<xsl:template name="pagination">
<xsl:param name="pageNumber"/>
<xsl:param name="recordsPerPage"/>
<xsl:param name="numberOfRecords"/>
<div class="pagination">
<div class="wrapper">
<xsl:if test="(($pageNumber +1 ) * $recordsPerPage) < ($numberOfRecords)">
Next
</xsl:if>
<xsl:if test="$pageNumber > 0">
Prev
</xsl:if>
<span class="page-nos">
Page
<xsl:call-template name="for.loop">
<xsl:with-param name="i">1</xsl:with-param>
<xsl:with-param name="page" select="$pageNumber +1"></xsl:with-param>
<xsl:with-param name="count" select="ceiling(count($currentPage/node)div $recordsPerPage)"></xsl:with-param>
</xsl:call-template>
</span>
</div>
</div>
</xsl:template>
<xsl:template name="for.loop">
<xsl:param name="i"/>
<xsl:param name="count"/>
<xsl:param name="page"/>
<xsl:if test="$i <= $count">
<span>
<xsl:if test="$page != $i">
<a href="{umbraco.library:NiceUrl($currentPage/#id)}?page={$i - 1}" >
<xsl:value-of select="$i" />
</a>
</xsl:if>
<xsl:if test="$page = $i">
<xsl:value-of select="$i" />
</xsl:if>
</span>
</xsl:if>
<xsl:if test="$i <= $count">
<xsl:call-template name="for.loop">
<xsl:with-param name="i">
<xsl:value-of select="$i + 1"/>
</xsl:with-param>
<xsl:with-param name="count">
<xsl:value-of select="$count"/>
</xsl:with-param>
<xsl:with-param name="page">
<xsl:value-of select="$page"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
I figured this one out now. I can see that you have just copy/pasted the pagination that where made by Tim Geyssens here: http://www.nibble.be/?p=11
And the code is also kind'a good, but I changed some of it to get it working. I don't know if I should just accept my own answer as the right one, the answer from Myster as the right one or if I can delete this post?