XSlT String Split during Copy [duplicate] - string

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

Related

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

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:

xsl - string translate in my code - Help required

I have an xsl code where I need to implement replaceAll functionality as we do in Java. I tried
trasnlate function but it was not working. I am not sure where and how to use the function in the below code and you please help on this.
<xsl:template match="warning">
<xsl:param name="drugsSub" select="'false'"/>
<tr>
<td class="dataRowBorderBottom rowColor" style="width: 35%; padding-right: 5px; font-size:.85em;">
**<xsl:apply-templates select="translate(warningId,'/','/ ')">** This is not working. I want translate function to work both warningId. A value comes for this variable from some other file.
<xsl:with-param name="drugsSub" select="$drugsSub"/>
</xsl:apply-templates>
</td>
<td class="dataRowBorderBottom rowColor leftPadding" style="width: auto; padding-bottom: 15px; font-size:.85em;">
<xsl:apply-templates select="severity"/>
</td>
<td class="dataRowBorderBottom rowColor leftPadding" style="width: 13%;font-size:.85em;">
<xsl:apply-templates select="documentationRating"/>
</td>
<td class="dataRowBorderBottom rowColor leftPadding" style="width: 35%; padding-top: 3px; font-size:.85em;">
<xsl:value-of select="warningText"/>
</td>
</tr>
</xsl:template>
I can tell you why the code doesn't work: translate() produces a string, and you can't apply-templates to a string (only to a node-set).
But I can't tell you how to fix it, because I have no idea what you are trying to achieve.

hyperlink column Name through Xsl

I have document Library where the ColumnName is Name and the data is hyperlinked to Documents.
I want to access this through xslt.
My xsl code is given below:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method='html' indent='yes'/>
<xsl:template match='dsQueryResponse'>
<table cellpadding="10" cellspacing="0" border="1" style="padding:25px;">
<tr>
<td colspan='2'>
<b style="font-size:25px;">NewsLetter List</b>
</td>
</tr>
<xsl:apply-templates select='Rows/Row'/>
</table>
</xsl:template>
<xsl:template match='Row'>
<tr>
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td>
<b>
<img src="../PublishingImages/newsletter_icon.png" width="20px" height="20px"></img>
</b>
</td>
<td>
<xsl:value-of select="#Name"/>
</td>
</tr>
</table>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
Assuming the source XML contains the same attributes that are available by default, could you try replacing this:
<td>
<xsl:value-of select="#Name"/>
</td>
With this:
<td>
<a href="{#FileRef}">
<xsl:value-of select="#Name"/>
</a>
</td>

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