Sharepoint Xpath Contains Issue - sharepoint

I wonder if anyone out there could help.
I'm new to Xpath & SharePoint 2010 but so far I have been getting along, but this little problem is causing me a big head ache!
What i'm trying to do is show the value in a field if there is not another value with a similar name in the same column in a SharePoint list (hopefully that makes sense).
I have the following select which works if you hard code the value to compare against
<xsl:value-of select="$thisNode/#Txt_x0020_Doc_x0020_Ref[contains(.,'Test')]"/> This will displays all values that have test in this case.
What i'm after is to compare the current selected Txt_x0020_Doc_x0020_Ref column against all other results in the Txt_x0020_Doc_x0020_Ref columns
If someone could point me in the right direction that would be amazing!
*Update #Ian Here is the entire contents of the page in share point designer.
What I want it to do is remove the duplicate naming values and show the top value only i.e.
Current list
Test 1
Test 1
Hello 1
Robert 1
What I want
Test 1
Hello 1
Robert 1
Just to give a bit more information on the purpose of the SharePoint list. It is a form library that stores inputted forms, all the forms are submitted so every version is kept, The purpose of the view below is to show the latest version of the form only, then I will have another view which will show the other versions.
Please find the complete code from sharepoint designer below:
<code>
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
<SharePoint:ListProperty Property="TitleOrFolder" runat="server"/> -
<SharePoint:ListProperty Property="CurrentViewTitle" runat="server"/></asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">
<SharePoint:ListProperty Property="TitleBreadcrumb" runat="server"/>
<SharePoint:UIVersionedContent UIVersion="4" runat="server">
<ContentTemplate>
<span class="ms-ltviewselectormenuheader" runat="server">
<SharePoint:ListTitleViewSelectorMenu AlignToParent="true" id="LTViewSelectorMenu" runat="server" />
</span>
</ContentTemplate>
</SharePoint:UIVersionedContent>
</asp:Content>
<asp:content contentplaceholderid="PlaceHolderAdditionalPageHead" runat="server">
<SharePoint:RssLink runat="server"/>
</asp:content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageImage" runat="server">
<SharePoint:ViewIcon Width="145" Height="54" runat="server"/></asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderLeftActions" runat="server">
<SharePoint:RecentChangesMenu runat="server" id="RecentChanges"/>
<SharePoint:ModifySettingsLink runat="server"/>
</asp:Content>
<asp:Content ContentPlaceHolderId ="PlaceHolderBodyLeftBorder" runat="server">
<div height="100%" class="ms-pagemargin"><img src="/_layouts/images/blank.gif" width='6' height='1' alt="" /></div>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<WebPartPages:WebPartZone runat="server" FrameType="None" ID="Main" Title="loc:Main"><ZoneTemplate>
<WebPartPages:XsltListViewWebPart runat="server" Description="" PartOrder="2" Default="TRUE" HelpLink="" AllowRemove="True" IsVisible="True" AllowHide="True" UseSQLDataSourcePaging="True" ExportControlledProperties="False" IsIncludedFilter="" DataSourceID="" Title="Demand Management" ViewFlag="5" AllowConnect="True" DisplayName="Main View" PageType="PAGE_DEFAULTVIEW" FrameState="Normal" PageSize="-1" PartImageLarge="" AsyncRefresh="False" ExportMode="NonSensitiveData" Dir="Default" DetailLink="/Strategy-and-Architecture/Business-Account-Managers/Demand Management" ShowWithSampleData="False" ListId="cafbbdc7-079d-4ae1-bf40-4a695834e510" ListName="{CAFBBDC7-079D-4AE1-BF40-4A695834E510}" FrameType="Default" PartImageSmall="" IsIncluded="True" SuppressWebPartChrome="False" AllowEdit="True" ViewGuid="{1766D7BE-7DC0-4277-8418-EBA815716C60}" AutoRefresh="False" AutoRefreshInterval="60" AllowMinimize="True" WebId="00000000-0000-0000-0000-000000000000" ViewContentTypeId="0x" InitialAsyncDataFetch="False" GhostedXslLink="main.xsl" MissingAssembly="Cannot import this Web Part." HelpMode="Modeless" ID="g_1766d7be_7dc0_4277_8418_eba815716c60" ConnectionID="00000000-0000-0000-0000-000000000000" AllowZoneChange="True" TitleUrl="/Strategy-and-Architecture/Business-Account-Managers/Demand Management" ManualRefresh="False" __MarkupType="vsattributemarkup" __WebPartId="{1766D7BE-7DC0-4277-8418-EBA815716C60}" __AllowXSLTEditing="true" __designer:CustomXsl="fldtypes_Ratings.xsl" WebPart="true" Height="" Width=""><ParameterBindings>
<ParameterBinding Name="dvt_sortdir" Location="Postback;Connection"/>
<ParameterBinding Name="dvt_sortfield" Location="Postback;Connection"/>
<ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>
<ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
<ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)" />
<ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)" />
<ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)" />
<ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)" />
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noitemsinview_doclibrary)" />
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noitemsinview_doclibrary_howto2)" />
</ParameterBindings>
<XmlDefinition>
<View Name="{1766D7BE-7DC0-4277-8418-EBA815716C60}" DefaultView="TRUE" Type="HTML" DisplayName="Main View" Url="/Strategy-and-Architecture/Business-Account-Managers/Demand Management/Forms/Main View.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/dlicon.png">
<Query/>
<ViewFields>
<FieldRef Name="LinkFilename"/>
<FieldRef Name="Txt_x0020_Doc_x0020_Ref"/>
<FieldRef Name="Txtdescription"/>
<FieldRef Name="Txt_x0020_Doc_x0020_Status_x0020_Hidden"/>
<FieldRef Name="Ddl_x0020_DM_x0020_Project_x0020_Status"/>
<FieldRef Name="Modified"/>
<FieldRef Name="Editor"/>
<FieldRef Name="Txt_x0020_Version"/>
<FieldRef Name="Title" Explicit="TRUE"/>
</ViewFields>
<RowLimit Paged="TRUE">30</RowLimit>
<Toolbar Type="Standard"/>
</View>
</XmlDefinition>
<DataFields>
</DataFields>
<Xsl>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office">
<xsl:include href="/_layouts/xsl/main.xsl"/>
<xsl:include href="/_layouts/xsl/internal.xsl"/>
<xsl:param name="AllRows" select="/dsQueryResponse/Rows/Row[$EntityName = '' or (position() >= $FirstRow and position() <= $LastRow)]"/>
<xsl:param name="dvt_apos">'</xsl:param>
<xsl:template match="FieldRef[#Name='LinkFilename']" name="LinkFilenameNoMenu.LinkFilename" mode="Computed_LinkFilename_body" ddwrt:tag="a" ddwrt:dvt_mode="body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:param name="thisNode" select="."/>
<xsl:param name="ShowAccessibleIcon" select="0"/>
<xsl:param name="folderUrlAdditionalQueryString"/>
<xsl:param name="IncludeOnClick" select="1"/>
<xsl:choose>
<xsl:when test="$thisNode/#FSObjType='1'">
<xsl:choose>
<xsl:when test="$RecursiveView">
<xsl:value-of select="$thisNode/#FileLeafRef" />
</xsl:when>
<xsl:otherwise>
<xsl:variable name="FolderURL">
<xsl:value-of select="$PagePathFinal" />RootFolder=<xsl:value-of select="$thisNode/#FileRef.urlencode" /><xsl:value-of select="$ShowWebPart"/>&FolderCTID=<xsl:value-of select="$thisNode/#ContentTypeId" />&View=<xsl:value-of select="$View"/><xsl:value-of select="$folderUrlAdditionalQueryString"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$IsDocLib">
<xsl:variable name="OnMouseDownJS">
javascript:VerifyFolderHref(this,event,'<xsl:value-of select="$thisNode/#File_x0020_Type.url" />','<xsl:value-of select="$thisNode/#File_x0020_Type.progid" />','<xsl:value-of select="$XmlDefinition/List/#DefaultItemOpen" />','<xsl:value-of select="$thisNode/#HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon" />','<xsl:value-of select="$thisNode/#HTML_x0020_File_x0020_Type" />','<xsl:value-of select="$thisNode/#serverurl.progid" />');return false;
</xsl:variable>
<xsl:variable name="OnClickJS">
return HandleFolder(this,event,"<xsl:value-of select="$PagePathFinal" />RootFolder=" + escapeProperly("<xsl:value-of select="$thisNode/#FileRef" />") + '<xsl:value-of select="$ShowWebPart" />&FolderCTID=<xsl:value-of select="$thisNode/#ContentTypeId" />&View=<xsl:value-of select="$View" /><xsl:value-of select="$folderUrlAdditionalQueryString"/>','TRUE','FALSE','<xsl:value-of select="$thisNode/#File_x0020_Type.url" />','<xsl:value-of select="$thisNode/#File_x0020_Type.progid" />','<xsl:value-of select="$XmlDefinition/List/#DefaultItemOpen" />','<xsl:value-of select="$thisNode/#HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon" />','<xsl:value-of select="$thisNode/#HTML_x0020_File_x0020_Type" />','<xsl:value-of select="$thisNode/#serverurl.progid" />','<xsl:value-of select="$thisNode/#CheckoutUser.id" />','<xsl:value-of select="$Userid" />','<xsl:value-of select="$XmlDefinition/List/#ForceCheckout" />','<xsl:value-of select="$thisNode/#IsCheckedoutToLocal" />','<xsl:value-of select="$thisNode/#PermMask" />');
</xsl:variable>
<a onfocus="OnLink(this)" href="{$FolderURL}">
<xsl:choose>
<xsl:when test="$IncludeOnClick = '1'">
<xsl:attribute name="onmousedown">
<xsl:value-of select="$OnMouseDownJS"/>
</xsl:attribute>
<xsl:attribute name="onclick">
<xsl:value-of select="$OnClickJS"/>
</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:value-of select="$thisNode/#FileLeafRef" />
<xsl:choose>
<xsl:when test="$ShowAccessibleIcon">
<img src="/_layouts/images/blank.gif" class="ms-hidden" border="0" width="1" height="1" alt="{$idPresEnabled}" />
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="OnClickJS">
javascript:EnterFolder("<xsl:value-of select="$PagePathFinal" />RootFolder=" + escapeProperly("<xsl:value-of select="$thisNode/#FileRef" />") + '<xsl:value-of select="$ShowWebPart" />&FolderCTID=<xsl:value-of select="$thisNode/#ContentTypeId" />&View=<xsl:value-of select="$View" /><xsl:value-of select="$folderUrlAdditionalQueryString" />');return false;
</xsl:variable>
<a onfocus="OnLink(this)" href="{$FolderURL}">
<xsl:choose>
<xsl:when test="$IncludeOnClick = '1'">
<xsl:attribute name="onclick">
<xsl:value-of select="$OnClickJS"/>
</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:value-of select="$thisNode/#FileLeafRef" />
<xsl:choose>
<xsl:when test="$ShowAccessibleIcon">
<img src="/_layouts/images/blank.gif" class="ms-hidden" border="0" width="1" height="1" alt="{$idPresEnabled}" />
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<a onfocus="OnLink(this)" href="{$thisNode/#FileRef}" onmousedown="return VerifyHref(this,event,'{$XmlDefinition/List/#DefaultItemOpen}','{$thisNode/#HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon}','{$thisNode/#serverurl.progid}')"
onclick="return DispEx(this,event,'TRUE','FALSE','{$thisNode/#File_x0020_Type.url}','{$thisNode/#File_x0020_Type.progid}','{$XmlDefinition/List/#DefaultItemOpen}','{$thisNode/#HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon}','{$thisNode/#HTML_x0020_File_x0020_Type}','{$thisNode/#serverurl.progid}','{$thisNode/#CheckoutUser.id}','{$Userid}','{$XmlDefinition/List/#ForceCheckout}','{$thisNode/#IsCheckedoutToLocal}','{$thisNode/#PermMask}')">
<xsl:value-of select="/dsQueryResponse/Rows/Row[1]" />
<xsl:value-of select="$thisNode/#FileLeafRef.Name" /></a>
<xsl:if test="$thisNode/#Created_x0020_Date.ifnew='1'">
<xsl:call-template name="NewGif">
<xsl:with-param name="thisNode" select="$thisNode"/>
</xsl:call-template>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="FieldRef_Text_body.Txt_x0020_Doc_x0020_Ref" ddwrt:dvt_mode="body" match ="FieldRef[#Name='Txt_x0020_Doc_x0020_Ref']" mode="Text_body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:param name="thisNode" select="."/>
<!--- This is the field I wish to change --->
<xsl:value-of select="$thisNode/#Txt_x0020_Doc_x0020_Ref[contains(.,'Test')]"/>
</xsl:template></xsl:stylesheet></Xsl>
</WebPartPages:XsltListViewWebPart>
</ZoneTemplate></WebPartPages:WebPartZone>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderBodyAreaClass" runat="server">
<style type="text/css">
.ms-bodyareaframe {
padding: 0px;
}
</style>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageDescription" runat="server">
<SharePoint:ListProperty CssClass="ms-listdescription" Property="Description" runat="server"/>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderCalendarNavigator" runat="server">
<SharePoint:SPCalendarNavigator id="CalendarNavigatorId" runat="server"/>
<ApplicationPages:CalendarAggregationPanel id="AggregationPanel" runat="server"/>
</asp:Content>
</code>

On the tables select statement change the "AllRows" select statement to the following
This will then display only one result of the same document name, then add a order by clause in the xml as show below to display the latest result.
<Query>
<OrderBy>
<FieldRef Name="Modified" Ascending="FALSE"/>
</OrderBy>
<GroupBy>
</GroupBy>
</Query>

Related

XSlT String Split during Copy [duplicate]

I Have a Attribute that I want to display, but I only want to display the last portion of it indicated by an "-". I am using substring-after to do this but this only works if there is one charactor. There are occasions where there might be one and some where there is two. I have seen some recursive templates for this but I have not seen them in a For-each Loop like I have it here and I am not sure where I would put everything in my XSL document.
Here is my XML document:
<?xml version="1.0" encoding="UTF-8"?>
<JobList>
<Job T.number="28" />
<Job T.identifier="10mm Drill" />
<Job oper.jobName="2: T28-Contour Milling - Grind me back" />
<Job T.number="3" />
<Job T.identifier="9mm Drill" />
<Job oper.jobName="3: T3 Contour Milling" />
</JobList>
Here is my XSL Document. I am using XSL 1.0. The result I am looking for is I want this to be displayed as "10mm Drill - Grind me back" not "10mm Drill-Contour Milling - Grind me back" which is what I am getting now using the substring-after function or something with the same result.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" encoding="UTF-8" method="xml" />
<xsl:param name="REPORT">joblist</xsl:param>
<xsl:param name="LOCALE">en-GB</xsl:param>
<xsl:param name="FORMAT">html</xsl:param>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Tool Report</title>
</head>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="JobList">
<div style="font-size:;">
<table width="100%" style="margin-bottom:50px;font:bold 10px arial;">
<thead>
<tr>
<th style="text-align:center;font-family:Arial;font-size:13;font:bold 7px arial;">
<xsl:value-of select="#month">
</xsl:value-of>
<span>.</span>
<xsl:value-of select="#day">
</xsl:value-of>
<span>.</span>
<xsl:value-of select="#year">
</xsl:value-of>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center;font:normal 7px arial;font-size:12px;">
<xsl:value-of select="//Job[position()=1]/#cfg.JOBLISTNAME" />
<span>
</span>
<span>
</span>
</td>
</tr>
</tbody>
<table width="100%" border="1" style="margin-bottom:50px;font:13px arial;">
<thead style="font:19;">
<tr style="font-size:19;">
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
</tr>
</thead>
<tbody style="font-size:19;">
<xsl:for-each select="//Job[not(#T.number=preceding::Job/#T.number)]">
<tr style="font-size:19;">
<td style="font-size:19;">
<xsl:value-of select="#T.number" />
</td>
<td>
</td>
<td style="font-size:19;">
<xsl:value-of select="#T.identifier" />
<xsl:choose>
<xsl:when test="contains(#T.toolComment3, 'GRIND') or contains(#T.toolComment3, 'Grind')">
<xsl:value-of select="#T.toolComment3" />
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="contains(#T.comment2, 'GRIND') or contains(#T.comment2, 'Grind')">
<xsl:value-of select="#T.comment2" />
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="contains(#oper.jobName, 'GRIND') or contains(#oper.jobName, 'Grind')">
<xsl:value-of select="substring-after(#oper.jobName, '-')" />
</xsl:when>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</table>
</div>
</xsl:template>
</xsl:stylesheet>
Use a named recursive template to get the last token of the text string.
<xsl:template name="last-token">
<xsl:param name="text"/>
<xsl:param name="delimiter" select="'-'"/>
<xsl:choose>
<xsl:when test="contains($text, $delimiter)">
<!-- recursive call -->
<xsl:call-template name="last-token">
<xsl:with-param name="text" select="substring-after($text, $delimiter)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Example of call: http://xsltransform.net/bFWR5Ew

XSLT for an XML file

I am trying to extract few tags using XSLT , but tags are getting blank value. Can you please suggest what is the issue with the code.
Below is my code :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">ClientID</th>
<th style="text-align:left">AssetClass</th>
</tr>
<tr>
<td><xsl:value-of select="ClientID"/></td>
<td><xsl:value-of select="AssetClass"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Below is the XML from which I am trying to pull the data.
<?xml version="1.0"?>
<template123 xmlns="http://www.markit.com/totem/api/data/V40" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ClientID>470</ClientID>
<ValuationDate>2019-01-31</ValuationDate>
<AssetClass>Value</AssetClass>
<ServiceName>Oil</ServiceName>
<ServiceFrequency>ME</ServiceFrequency>
<SubArea>10</SubArea>
<SchemaVersion>40</SchemaVersion>
<Underlier>
<ContractGroup>Chemicals</ContractGroup>
<Currency>USD</Currency>
<ReferencePublication1>XYZ</ReferencePublication1>
<Underlying>ABC</Underlying>
<Underlying1>ABC</Underlying1>
<Instrument>
<CCYScalar>1.0</CCYScalar>
<EndDate>2019-02-28</EndDate>
<InstrumentType>Watch</InstrumentType>
<InstrumentType1>Watch</InstrumentType1>
<Period>Month</Period>
<PricingTime>LDN 16:30</PricingTime>
<StartDate>2019-02-01</StartDate>
<Units>MT</Units>
<ClientPrice>472.84000000</ClientPrice>
</Instrument>
<Instrument>
<CCYScalar>1.0</CCYScalar>
<EndDate>2019-03-31</EndDate>
<InstrumentType>Watch</InstrumentType>
<InstrumentType1>Watch</InstrumentType1>
<Period>Month</Period>
<PricingTime>LDN 16:30</PricingTime>
<StartDate>2019-03-01</StartDate>
<Units>MT</Units>
<ClientPrice>456.46600000</ClientPrice>
</Instrument>
<Instrument>
<CCYScalar>1.0</CCYScalar>
<EndDate>2019-04-30</EndDate>
<InstrumentType>Watch</InstrumentType>
<InstrumentType1>Watch</InstrumentType1>
<Period>Month</Period>
<PricingTime>LDN 16:30</PricingTime>
<StartDate>2019-04-01</StartDate>
<Units>MT</Units>
<ClientPrice>440.30900000</ClientPrice>
</Instrument>
</Underlier>
</template123>
Have tried with the suggested solution and able to get the parent nodes values but nested node is still coming as blank.
My Updated Code :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ab="http://www.markit.com/totem/api/data/V40">
<xsl:output method="text" />
<xsl:template match="ab:template">
<xsl:text>ClientID|ValuationDate|AssetClass|ServiceName|ServiceFrequency|SubArea|SchemaVersion|ContractGroup|EndDate</xsl:text>
<xsl:text>
</xsl:text>
<xsl:value-of select="ab:ClientID" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:ValuationDate" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:AssetClass" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:ServiceName" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:ServiceFrequency" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:SubArea" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:SchemaVersion" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:Underlier/ContractGroup" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:Underlier/Instrument/EndDate" />
<xsl:text>|</xsl:text>
</xsl:template>
</xsl:stylesheet>
I am trying to extract the data from this XML and convert it into a pipe separated file.
Can you suggest what needs to be changed to access the values from nested nodes.
Expected output should look like as below :
ClientID|ValuationDate|AssetClass|ServiceName|ServiceFrequency|SubArea|SchemaVersion|ContractGroup|EndDate
470|2019-01-31|Value|Oil|ME|10|40|Chemicals|2019-02-28
470|2019-01-31|Value|Oil|ME|10|40|Chemicals|2019-03-31
and so on for all nested nodes.
You can try this
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ab="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="ab">
<xsl:template match="ab:template123">
<html>
<body>
<h2>My Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">ClientID</th>
<th style="text-align:left">AssetClass</th>
</tr>
<tr>
<td><xsl:value-of select="ab:ClientID"/></td>
<td><xsl:value-of select="ab:AssetClass"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
DEMO
https://xsltfiddle.liberty-development.net/94AbWB2
XML File:
<?xml version="1.0" encoding="UTF-8"?>
<template123 xmlns="http://www.markit.com/totem/api/data/V40" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ClientID>470</ClientID>
<ValuationDate>2019-01-31</ValuationDate>
<AssetClass>Value</AssetClass>
<ServiceName>Oil</ServiceName>
<ServiceFrequency>ME</ServiceFrequency>
<SubArea>10</SubArea>
<SchemaVersion>40</SchemaVersion>
<Underlier>
<ContractGroup>Chemicals</ContractGroup>
<Currency>USD</Currency>
<ReferencePublication1>XYZ</ReferencePublication1>
<Underlying>ABC</Underlying>
<Underlying1>ABC</Underlying1>
<Instrument>
<CCYScalar>1.0</CCYScalar>
<EndDate>2019-02-28</EndDate>
<InstrumentType>Watch</InstrumentType>
<InstrumentType1>Watch</InstrumentType1>
<Period>Month</Period>
<PricingTime>LDN 16:30</PricingTime>
<StartDate>2019-02-01</StartDate>
<Units>MT</Units>
<ClientPrice>472.84000000</ClientPrice>
</Instrument>
<Instrument>
<CCYScalar>1.0</CCYScalar>
<EndDate>2019-03-31</EndDate>
<InstrumentType>Watch</InstrumentType>
<InstrumentType1>Watch</InstrumentType1>
<Period>Month</Period>
<PricingTime>LDN 16:30</PricingTime>
<StartDate>2019-03-01</StartDate>
<Units>MT</Units>
<ClientPrice>456.46600000</ClientPrice>
</Instrument>
<Instrument>
<CCYScalar>1.0</CCYScalar>
<EndDate>2019-04-30</EndDate>
<InstrumentType>Watch</InstrumentType>
<InstrumentType1>Watch</InstrumentType1>
<Period>Month</Period>
<PricingTime>LDN 16:30</PricingTime>
<StartDate>2019-04-01</StartDate>
<Units>MT</Units>
<ClientPrice>440.30900000</ClientPrice>
</Instrument>
</Underlier>
</template123>
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ab="http://www.markit.com/totem/api/data/V40">
<xsl:output method="text" />
<xsl:template match="ab:template123">
<xsl:text>ClientID|ValuationDate|AssetClass|ServiceName|ServiceFrequency|SubArea|SchemaVersion|ContractGroup|EndDate</xsl:text>
<xsl:text>
</xsl:text>
<xsl:value-of select="ab:ClientID" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:ValuationDate" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:AssetClass" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:ServiceName" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:ServiceFrequency" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:SubArea" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:SchemaVersion" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:Underlier/ab:ContractGroup" />
<xsl:text>|</xsl:text>
<xsl:value-of select="ab:Underlier/ab:Instrument/ab:EndDate" />
</xsl:template>
</xsl:stylesheet>
OUTPUT:
ClientID|ValuationDate|AssetClass|ServiceName|ServiceFrequency|SubArea|SchemaVersion|ContractGroup|EndDate
470|2019-01-31|Value|Oil|ME|10|40|Chemicals|2019-02-28
Look like two things are wrong in you scenario:
Default NameSpace in XML is exact match with transformation namespace
In match context you are on document node so either you need to use template123 in match or in <xsl:value-of select="template123/ClientID"/> & <xsl:value-of select="template123/AssetClass"/> you give the proper path to navigate the elements.
Below is the code you can use:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">ClientID</th>
<th style="text-align:left">AssetClass</th>
</tr>
<tr>
<td><xsl:value-of select="template123/ClientID"/></td>
<td><xsl:value-of select="template123/AssetClass"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
You can see this link for your reference:
https://xsltfiddle.liberty-development.net/6rewNxZ/1

I'm having issues pulling the link to the site from a link list in Sharepoint using the Enhanced Custom Query W/P

I've created a custom style in my ItemStyle.xsl for displaying a list of links from a links list in SharePoint 2007. The only problem I'm getting is I can pull the link to the item in the list, but I can pull the URL stored within the item in the list. Here is my style:
<xsl:template name="LinkListStyled" match="*" mode="itemstyle">
<xsl:param name="CurPos" />
<xsl:param name="LastRow" />
<xsl:variable name="tableStart">
<xsl:if test="$CurPos = 1">
<![CDATA[
<table style="border:0px ; border-collapse:collapse; ">
<tr>
<td align="left" width="70px">
<IMG style="BORDER-BOTTOM: 0px solid; BORDER-LEFT: 0px solid; BORDER-TOP: 0px solid; BORDER-RIGHT: 0px solid" border=0 src="http://intranet.test.co.uk/images/sharepoint_sites/practiceareas/knowhowgreen2.png">
</td>
<td align="left">
<table style="padding:5px">
]]>
</xsl:if>
</xsl:variable>
<xsl:variable name="tableEnd">
<xsl:if test="$CurPos = $LastRow">
<![CDATA[
</table>
</td>
</tr>
</table>]]>
</xsl:if>
</xsl:variable>
<xsl:value-of select="$tableStart" disable-output-escaping="yes"/>
<xsl:if test="($CurPos mod 2) = 1">
<xsl:text disable-output-escaping="yes">
<![CDATA[<tr>
<td width="2px">
<IMG src="http://intranet.test.co.uk/images/sharepoint/green_square_header.gif" />
</td>
<td width="150px">
<a href="
]]>
</xsl:text>
<xsl:value-of select="#FileRef"/>
<xsl:text disable-output-escaping="yes">
<![CDATA["> ]]>
</xsl:text>
<xsl:value-of select="#Title"></xsl:value-of>
<xsl:text disable-output-escaping="yes">
<![CDATA[</a></td>]]>
</xsl:text>
</xsl:if>
<xsl:if test="($CurPos mod 2) = 0">
<xsl:text disable-output-escaping="yes">
<![CDATA[
<td width="2px">
<IMG src="http://intranet.test.co.uk/images/sharepoint/green_square_header.gif" />
</td>
<td width="150px">
]]>
</xsl:text>
<xsl:value-of select="#Title"></xsl:value-of><br />
<xsl:text disable-output-escaping="yes">
<![CDATA[</td>
</tr>]]>
</xsl:text>
</xsl:if>
<xsl:value-of select="$tableEnd" disable-output-escaping="yes" />
</xsl:template>
I have tried using the same methods as in the LinkList style:
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="#URL"/>
<xsl:with-param name="UrlColumnName" select="'URL'"/>
</xsl:call-template>
</xsl:variable>
But the moment I add this into my style it breaks the view. Oddly, if I put a call to the OuterTemplate outside my style and then reference the values in my style it doesn't fall over and I can pull through the values, however this doesn't work for URL (I'm guessing this is because it needs to pull through a title to retrieve the URL). I've tried a few different things but to no avail.
I needed to add the 'URL,text' into the Custom Field View in the web part.

sharepoint content query link to the source page?

If i can get the title of the page where contents are coming from, how can i get the url of the same page with that title?
<div class="custom_posttitle">
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<a href="{$SafeLinkUrl}" title="{#LinkToolTip}">
<xsl:if test="$ItemsHaveStreams = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of select="#OnClickForWebRendering"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ItemsHaveStreams != 'True' and #OpenInNewWindow = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$DisplayTitle"/>
</a>
</div>
IN the XSLT, sth like this?
<div>
READ MORE
</div>
The line
<a href="{$SafeLinkUrl}" title="{#LinkToolTip}">
from the xslt you posted already has the link to the page.

How can I integrate Laconica update stream into SharePoint?

I have Laconica (self hosted twitter) configured on my local intranet and would like to integrate the public stream into SharePoint site with a web part. How can I do this?
You can point an RSS Viewer web part at the laconi.ca public stream RSS feed and use this XSLT to ensure attractive output.
Result screen shot:
XSL transform:
<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:rss="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"
xmlns:laconica="http://laconi.ca/ont/">
<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="rdf:RDF">
<xsl:call-template name="RDFMainTemplate"/>
</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="rss:item"/>
<xsl:variable name="RowCount" select="count($Rows)"/>
<div class="slm-layout-main" >
<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)">
<xsl:element name="div">
<xsl:if test="($CurPosition mod 2 = 1)">
<xsl:attribute name="style"><![CDATA[background-color:#F9F9F9;]]></xsl:attribute>
</xsl:if>
<xsl:element name="table">
<xsl:attribute name="cellpadding">0</xsl:attribute>
<xsl:attribute name="border">0</xsl:attribute>
<xsl:attribute name="style"><![CDATA[margin:0px;padding:0px;border-spacing:0px;background-color:transparent;]]></xsl:attribute>
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="style"><![CDATA[vertical-align:top;padding:0px;background-color:transparent;]]></xsl:attribute>
<xsl:attribute name="rowspan">2</xsl:attribute>
<xsl:element name="img">
<xsl:attribute name="src"><xsl:value-of select="laconica:postIcon/#rdf:resource"/></xsl:attribute>
<xsl:attribute name="style"><![CDATA[margin:3px;height:48px;width:48px;]]></xsl:attribute>
</xsl:element>
</xsl:element>
<xsl:element name="td">
<xsl:attribute name="style"><![CDATA[vertical-align:top;padding:0px;background-color:transparent;]]></xsl:attribute>
<div>
<strong><xsl:value-of select="substring-before(rss:title, ':')"/></strong>
</div>
<div style="width:300px;overflow-x:hidden;">
<div>
<xsl:value-of select="substring-after(rss:title, ':')"/>
</div>
</div>
</xsl:element>
</xsl:element>
<xsl:element name="tr">
<xsl:element name="td">
<xsl:attribute name="style"><![CDATA[padding:0px;background-color:transparent;]]></xsl:attribute>
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="rss:link"/></xsl:attribute>
<xsl:value-of select="ddwrt:FormatDate(dc:date,number($rss_LCID),15)"/>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I like the RSS idea. Another option would be to create a Laconica plugin and hook the EndNoticeSave event to push notices to SharePoint.

Resources