xslt

Flatten XML to HTML table using XSLT

There must be a generic way to transform some hierachical XML such as: <element1 A="AValue" B="BValue"> <element2 C="DValue" D="CValue"> <element3 E="EValue1" F="FValue1"/> <element3 E="EValue2" F="FValue2"/> </element2> ... </element1> into the flattened XML (html) picking up selected attributes along the way and...

How to use node-set function in a platform-independent way?

I'm writing some xlst file which I want to use under linux and Windows. In this file I use node-set function which declared in different namespaces for MSXML and xsltproc ("urn:schemas-microsoft-com:xslt" and "http://exslt.org/common" respectively). Is there any platform independent way of using node-set? ...

Counter inside xsl:for-each loop

How to get a counter inside xsl:for-each loop that would reflect the number of current element processed. For example my source XML is <books> <book> <title>The Unbearable Lightness of Being </title> </book> <book> <title>Narcissus and Goldmund</title> </book> <book> <title>Choke</title> </book> </...

Are .NET 3.5 XPath classes and methods XSLT 2.0 compatible?

I'd like to use regular expressions in selecting elements using the match function. I'd prefer not to use an external library (such as saxon) to do this. ...

Given this XML, is there an xpath that will give me the 'test' and 'name' values?

I need to get the value of the 'test' attribute in the xsl:when tag, and the 'name' attribute in the xsl:call-template tag. This xpath gets me pretty close: ..../xsl:template/xsl:choose/xsl:when But that just returns the 'when' elements, not the exact attribute values I need. Here is a snippet of my XML: <xsl:template match="fie...

XSL code coverage tool

Are there any tools that can tell me what percentage of a XSL document get actually executed during tests? UPDATE I could not find anything better than Oxygen's XSL debugger and profiler, so I'm accepting Mladen's answer. ...

javascript XSLTProcessor occasionally not working

The following javascript supposes to read the popular tags from an XML file and applies the XSL Stylesheet and output to the browser as HTML. function ShowPopularTags() { xml=XMLDocLoad("http://localhost/xml/tags/popular.xml?s=94987898"); xsl=XMLDocLoad("http://localhost/xml/xsl/popular-tags.xsl"); if (window.ActiveXObject...

XSLT multiple file inputs?

Within an XSLT document, is it possible to loop over a set of files in the current directory? I have a situation where I have a directory full of xml files that need some analysis done to generate a report. I have my stylesheet operating on a single document fine, but I'd like to extend that without going to another tool to merge the x...

Number of nodes meeting a conditional based on attributes

Below is part of the XML which I am processing with PHP's XSLTProcessor: <result> <uf x="20" y="0"/> <uf x="22" y="22"/> <uf x="4" y="3"/> <uf x="15" y="15"/> </result> I need to know how many "uf" nodes exist where x = y. In the above example, that would be 2. I've tried looping and incrementing some var, but I can'...

Can XPath return only nodes that have a child of X?

Is it possible to use XPath to select only the nodes that have a particular child elements? For example, from this XML I only want the elements in pets that have a child of 'bar'. So the resulting dataset would contain the lizard and pig elements. <pets> <cat> <foo>don't care about this</foo> </cat> <dog> <foo>not this one either...

Is there a reference for the SharePoint XSLT extension functions?

There are a couple of different .NET XSLT functions that I see used in the out of the box SharePoint web parts (RSS Viewer and Data View web part). <xsl:stylesheet xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:rssaggwrt="http://schemas.microsoft.com/WebParts/v3/rssagg/runtime" ...> ... ...

Is XSLT a functional programming language?

Several questions about functional programming languages have got me thinking about whether XSLT is a functional programming language. If not, what features are missing? Has XSLT 2.0 shortened or closed the gap? ...

How to remove duplicate elements from an xml file?

I have an xml file like <ns0:Employees xmlns:ns0="http://TestIndexMap.Employees"&gt; <Employee FirstName="FirstName_0" LastName="LastName_1" dept="dept_2" empNumber="1"> <Schedules> <Schedule Date_join="2008-01-20" Date_end="2008-01-30" /> </Schedules> </Employee> <Employee FirstName="FirstName_0" LastName="LastNam...

Read in an XML String with Namespaces for Use in an XSL Transformation

In an ASP.NET 2.0 website, I have a string representing some well-formed XML. I am currently creating an XmlDocument object with it and running an XSL transformation for display in a Web form. Everything was operating fine until the XML input started to contain namespaces. How can I read in this string and allow namespaces? I've incl...

Moving the child nodes of an XML node upwards

Imagine I have the folling XML file: <a>before<b>middle</b>after</a> I want to convert it into something like this: <a>beforemiddleafter</a> In other words I want to get all the child nodes of a certain node, and move them to the parent node in order. This is like doing this command: "mv ./directory/* .", but for xml nodes. I'd like...

Restrict a string to whitelisted characters using XSLT 1.0

Question Using XSLT 1.0, given a string with arbitrary characters how can I get back a string that meets the following rules. First character must be one of these: a-z, A-Z, colon, or underscore All other characters must be any of those above or 0-9, period, or hyphen If any character does not meet the above rules, replace it with an ...

XML for Documentation - Standards?

I need to create Documentation for a tool (Manually written User Documentation, no Developer/API Documentation from the Source Files). Now, there are about a billion different ways to do it, but I have the following requirements: Needs to be a physical file, so that it can go to SVN Needs to be printable Needs to be readable and search...

Does XSLT have a Split() function?

I have a string in a node and I'd like to split the string on '?' and return the last item in the array. For example, in the block below: <a> <xsl:attribute name="href"> /newpage.aspx?<xsl:value-of select="someNode"/> </xsl:attribute> Link text </a> I'd like to split the someNode value. Edit: Here's the VB.Net t...

Pure Python XSLT library

Is there an XSLT library that is pure Python? Installing libxml2+libxslt or any similar C libraries is a problem on some of the platforms I need to support. I really only need basic XSLT support, and speed is not a major issue. ...

xsl scope help

I have a xsl file that is grabbing variables from xml and they seem to not be able to see each other. I know it is a scope issue, I just do not know what I am doing wrong. <xsl:template match="one"> <xsl:variable name="varOne" select="@count" /> </xsl:template> <xsl:template match="two"> <xsl:if test="$varOne = 'Y'"> <xsl:value-...