xslt

Help with multi-pass XSLT using node-set()

I need to display certain data in a tabular form, and would prefer to use multi-pass xslt using node-set() so that I can avoid deploying additional tools (like xsltproc). Right now, I'm able to perform the required task in two steps i.e. Step 1: convert XML-1 to XMl-2 using identity template (xsl:copy, using xsl:element to add dynamic e...

XSLT1.0: replance new line character with _

I am having this below variable <xsl:variable name="testvar"> d e d </xsl:variable> and I have this function: <xsl:choose> <xsl:when test="not($str-input)"> <func:result select="false()"/> </xsl:when> <xsl:otherwise> <func:resul...

Trimming URL with XSL

I have some XSL on a page with a URL of: site.domain.com/dir/dir/dir/dir The same XSL also appears on a page with URL of: site.domain.com/dir/dir/dir I need links from these two pages to point to: site.domain.com/dir/dir/site So on both pages I need to get: site.domain.com/dir/dir as part of the HREF attribute. Can anyone th...

xslt 1.0, string-length function

I saw string-length on this website http://www.xsltfunctions.com/xsl/fn%5Fstring-length.html I think it's the xslt 2.0 syntax. though, in xslt 1.0, i tried this: <xsl:template match="/"> <xsl:value-of select="string-length(())" /> </xsl:template> and i got an error. is there any function that i can use to convert () and pass i...

xsl to php array

I got a xml file that contains hierarchical data. Now I need to get some of that data into a php array. I use xsl to get the data I want formatted as a php array. But when I print it it leaves all the tabs and extra spaces and line breaks etc which I need to get rid of to turn it into a flat string (I suppose!) and then convert that stri...

XSL for-each layout problem

I have a fairly simple layout required. <ul> <li>Link</li> </li>Link</li> </ul <ul> <li>Link</link> <li>Link</link> </ul> However I get: <ul> <li>Link</li> </ul> <ul> </li>Link</li> </ul <ul> <li>Link</link> </ul> <ul> <li>Link</link> </ul> Im sorry I dont have the XSL to hand, network issues but thought id ask an...

sort nodes based on multiple attributes?

I want to sort nodes base on attributes. Say there are three attributes A, B and C in element E1. I know that a sub-group of nodes have the same value of attribute A and B. How can I get this sub-group retrieve the node that has the max value of C? The tricky part here is that I don't know what value of A is. I just know that sub-group s...

Reusing xml for-each blocks in XSLT?

Hello, I have an attribute whose value is the XPath to the current node, like so: <xsl:attribute name="path"> <xsl:for-each select="ancestor-or-self::*"> <xsl:if test="name() != 'root'"> <xsl:value-of select="name()"> <xsl:if test="not(position()=last())"> <xsl:text>/</xsl:text> </xsl:if> ...

Getting XSLT Current Node, formatted as XPath Query?

Hi there, I have the following block of code that gets the name of the nodes down the tree, like this: section/page/subPage But I would like to be able to get it down to the following (just making it up): section[@id='someId']/page/subPage[@user='UserA']/@title I found the following code from one of these StackOverflow posts: <xsl...

"invalid XPath expression" error in Visual Studio 2008 TS

I'm learning XSLT via "Beginning XSLT 2.0 From Novice to Professional". Following the source code from the book, I've tried to compile this in Visual Studio 2008 TS: <xsl:template match="Program"> <div> <p> <xsl:if test="@flag"> <img src="{if (@flag = 'favorite') then 'favorite' else 'interest'}.gif" al...

Passing a Node as an XSL Template Parameter

In an existing XSL stylesheet I was passing a string into a named template. Due to a requirements change, I now need to display four strings, the string I was displaying and its three siblings. Rather than pass the four separate strings into the named template, I'm trying to pass their parent element (PETrailingFund in the code below), ...

Page breaks with whole sections on one page

I have a document with a few sections and each section can be very varied as its very dynamic. The requirement is that each section if started on a particular page say for e.g. section 1 appears on page 1 and section 2 starts on this page below section 1 should appear on the same page if it can fit completely else it needs to go onto the...

left trim white space xslt 1.0

I am creating a left trim template and I have this below template: <xsl:template name="str:left-trim"> <xsl:param name="string" select="''"/> <xsl:variable name="tmp" select="substring($string, 1, 1)"/> <xsl:if test="$tmp = ' '"> <xsl:variable name="tmp2" select="substring-after($string, $tmp)"/> <xsl:choose...

How can I select the first element using XSLT?

I have a list of news items, sorted by dateCreated. I have a preview box control where I only want to show the first item. How can I do that using XSLT? <xml> <news> <newsitem> <dateCreated>2009-09-09</dateCreated> <summary>Something great happened</sumamry> </newsitem> <newsitem> ...

how do I get around "Axis steps" created by "atomic values" in XSL 2.0?

In XSL 2.0, I'm trying to iterate through some data by the distinct values, and then do something with them. <xsl:for-each select="distinct-values(InvoiceLine/Service/ServiceMnemonicCode)"> <xsl:variable name="mnemonic"> <xsl:value-of select="."/> </xsl:variable> <fo:table-row> <fo:table-cell> <fo:block> ...

Apply XSL to RSS Feed

I want to display an RSS feed from Feedburner on my website, however I'd like to be able to apply an XSLT to it as well. Is it possible to fetch a URL in an XSLT rather than add the link to the style in the XML? ...

XSL media:content - Trimming strings in XSLT

Can anyone tell me how to select the URL from this: <media:content url="http://feedproxy.google.com/~r/TEDTalks_video/~5/aZWq6PY05YE/TimBrown_2009G.mp4" fileSize="57985745" type="video/mp4" /> I want to: Create a link to this file: Trim the URL from: http://feedproxy.google.com/~r/TEDTalks%5Fvideo/~5/aZWq6PY05YE/TimBrown%5F2009G...

XSL - Unknown Error in FF media:content/@url

I keep getting "Unknow Error occurred" when i try this in my XSLT: <table class="TEDtalks"> <xsl:for-each select="/rss/channel/item"> <tr> <td><xsl:value-of select="title"/></td> <td> <xsl:value-of select="media:content/@url" /> </td> </tr> </xsl:for-each> </table> The XML <rss> <channel> <item> <title>TEDTa...

XSL Get filename from URL

I need to get just the filename from this url: http://feedproxy.google.com/~r/TEDTalks_video/~5/XT8k_DqlzGc/KarenArmstrong_2009G.mp4 SO i need to get: KarenArmstrong_2009G I need the filename so i can add .jpg to it and another base url. ...

Node count and occurence - XSL

I need to write generic xsl that would take in an xml document and output the count of nodes and their names. So if I have a file like the following: <assets> <asset> <type>hardware</type> <item> <name>HP laptop</name> <value>799</value> </item> <item> <name>ser...