XSLT for an XML file - python-3.x

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

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 - dynamic node name

I want to convert all child node as attribute name to Nodes. and attribute value should be the node value.
How do i give dynamic node name?
<xsl:attribute name="shouldBeNodeName">
SOURCE XML
<transaction>
<transactionId>T001</transactionId>
<clientId>C001</clientId>
<contractId>C001</contractId>
<scriptId>REL</scriptId>
<price>500.5000</price>
<tradeDate>2019-02-09 16:00:00</tradeDate>
<valueDate>2019-02-09 16:00:00</valueDate>
<quantity>100000</quantity>
</transaction>
XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<ROOT>
<TRANS>
<xsl:for-each select="node()/*">
<xsl:attribute name="shouldBeNodeName">
<!-- <xsl:value-of select="name()" /> -->
<xsl:value-of select="." />
</xsl:attribute>
</xsl:for-each>
</TRANS>
</ROOT>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<ROOT>
<TRANS>
<xsl:for-each select="node()/*">
<xsl:attribute name="{name()}">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:for-each>
</TRANS>
</ROOT>
</xsl:template>

XSLT for selecting specific values in filtered nodes

I have a XML structure where i need to apply filtering for nodes and out of the filtered nodes i need to select specific elements. The structure of actual XML looks like this-
<Host>
<element1>type0</element1>
<element2>Fruits</element2>
....
<elementn>Price0</elementn>
<Menu>
<NodeA>
<element1>type1</element1>
<element2>Fruits</element2>
....
<elementn>Price1</elementn>
<Menu>
<NodeB>
<element1>type2</element1>
<element2>Fruits</element2>
....
<elementn>Price2</elementn>
<Menu>
<NodeC>
<element1>type3</element1>
<element2>Fruits</element2>
....
<elementn>Price3</elementn>
<Menu>
<NodeD>
<Element1>type4</element1>
<Element2>Vegetables</Element2>
....
<Elementn>Price4</elementn>
</NodeD>
</Menu>
</NodeC>
</Menu>
</NodeB>
</Menu>
</NodeA>
<NodeE>
<element1>type5</element1>
<element2>Fruits</element2>
....
<elementn>Price5</elementn>
<Menu>
<NodeF>
<element1>type6</element1>
<element2>Vegetables</element2>
....
<elementn>Price6</elementn>
</NodeF>
</Menu>
</NodeE>
</Menu>
</Host>
Now I have filtered this XML as follows-
a) if <element2> == fruits in all the nodes, the XML result is -
<Host>
<element1>type0</element1>
<element2>Fruits</element2>
....
<elementn>Price0</elementn>
<NodeA>
<element1>type1</element1>
<element2>Fruits</element2>
....
<elementn>Price1</elementn>
</NodeA>
<NodeB>
<element1>type2</element1>
<element2>Fruits</element2>
....
<elementn>Price2</elementn>
</NodeB>
<NodeC>
<element1>type3</element1>
<element2>Fruits</element2>
....
<elementn>Price3</elementn>
</NodeC>
<NodeE>
<element1>type5</element1>
<element2>Fruits</element2>
....
<elementn>Price5</elementn>
</NodeE>
</Host>
XSLT used for getting the above result is-
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:param name="element2" select="'Fruits'" />
<xsl:template match="/*">
<xsl:copy>
<xsl:apply-templates select="//*[element2=$element2]" mode="copy"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[element2]" mode="copy">
<xsl:copy>
<xsl:apply-templates select="*[not(*)]" mode="copy"/>
</xsl:copy>
</xsl:template>
<xsl:template match="#*|node()" mode="copy">
<xsl:copy>
<xsl:apply-templates select="#*|node()" mode="copy"/>
</xsl:copy>
</xsl:template>
The above XSLT select all the elements in the node where <element2> = Fruits condition is applied. Now I need to select specific elements in each filtered node (<Host>, <NodeA>, <NodeB>, <NodeC>, <NodeE>) - say for every node, i have elements range from to . Now I want to select only and from filtered nodes (<Host>, <NodeA>, <NodeB>, <NodeC>, <NodeE>). Also the expected output format is given below. The two values in each given below is from and of each node.
<html>
<head>
<body>
<table border="1">
<tr>
<td>type0</td>
<td>Price0</td>
</tr>
<td>type1</td>
<td>Price1</td>
</tr>
<tr>
<td>type2</td>
<td>Price2</td>
</tr>
<tr>
<td>type3</td>
<td>Price3</td>
</tr>
<tr>
<td>type5</td>
<td>Price5</td>
</tr>
</table>
</body>
</head>
</html>
Any help would be a great plus.
It seems you want to do something like:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="element2" select="'Fruits'" />
<xsl:template match="/">
<html>
<head/>
<body>
<table border="1">
<xsl:for-each select="//*[element2=$element2]">
<tr>
<td>
<xsl:value-of select="element1" />
</td>
<td>
<xsl:value-of select="elementn" />
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
When this is applied to the following well-formed (!) input:
XML
<Host>
<element1>type0</element1>
<element2>Fruits</element2>
<elementn>Price0</elementn>
<Menu>
<NodeA>
<element1>type1</element1>
<element2>Fruits</element2>
<elementn>Price1</elementn>
<Menu>
<NodeB>
<element1>type2</element1>
<element2>Fruits</element2>
<elementn>Price2</elementn>
<Menu>
<NodeC>
<element1>type3</element1>
<element2>Fruits</element2>
<elementn>Price3</elementn>
<Menu>
<NodeD>
<element1>type4</element1>
<element2>Vegetables</element2>
<elementn>Price4</elementn>
</NodeD>
</Menu>
</NodeC>
</Menu>
</NodeB>
</Menu>
</NodeA>
<NodeE>
<element1>type5</element1>
<element2>Fruits</element2>
<elementn>Price5</elementn>
<Menu>
<NodeF>
<element1>type6</element1>
<element2>Vegetables</element2>
<elementn>Price6</elementn>
</NodeF>
</Menu>
</NodeE>
</Menu>
</Host>
the result will be:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<table border="1">
<tr>
<td>type0</td>
<td>Price0</td>
</tr>
<tr>
<td>type1</td>
<td>Price1</td>
</tr>
<tr>
<td>type2</td>
<td>Price2</td>
</tr>
<tr>
<td>type3</td>
<td>Price3</td>
</tr>
<tr>
<td>type5</td>
<td>Price5</td>
</tr>
</table>
</body>
</html>
rendered as:

Sharepoint Xpath Contains Issue

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>

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.

Resources