xslt

XSLT display item

In the following XML, I would like only get the number 2 and 5 items, how could it be done on XSLT? <root> <content>item 1</content> <content>item 2</content> <content>item 3</content> <content>item 4</content> <content>item 5</content> <content>item 6</content> </root> ...

What does my XSLT need to do when the XML has a xmlns in it?

For the following XML <Properties ComponentID="1272040480745" Admin="true"> <Datum ID="P01" Type="File" Name="CSS To Use">style.css</Datum> <Data> <External></External> <Result> <results xmlns="http://www.interwoven.com/schema/iwrr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.inte...

Exclude attribute from a specific xml element using xslt

I am new in xslt. I have the following problem. I need within an xml, to remove a specific attribute from a specific element. i.e. <html> <head>...</head> <body> <div id="qaz" theAtribute="44"> <div> <div id ="ddd" theAtribute="4"> <div id= "ggg" theAtribute="9"> <div> <div> </b...

Doing file path manipulations in XSLT

I'd like my generated output file to contain file paths that point to a path relative to the stylesheet. The location of the stylesheet can change and I don't want to use a parameter for the stylesheet. My solution for this is to get the full stylesheet URI: <xsl:variable name="stylesheetURI" select="document-uri(document(''))" /> Now...

How do I perform automated testing of XSLT stylesheets?

I have some increasingly complex XSLT stylesheets and it would be helpful if I could run some tests on them as part of my CI build process, and even use TDD to develop them in the first place. I'm currently using Visual Studio to run fragments of XML through the stylesheets and I am manually checking the results. What would everyone rec...

Better control of for-each in xsl/xpath possible?

Hey Friends I've got another xsl/xpath problem. Sure a beginners problem, but I'm thinking still too "imperative". <!-- XML --> <Module> <WideTeaserElement> <Headline>Bla bla 1</Headline> </WideTeaserElement> <WideTeaserElement> <Headline>Bla bla 2</Headline> </WideTeaserElement> </Module> <!-- XSL --> <!-- ...

XSLT 2.0 regex question (opening and closing elements on different matches)

I've simplified the problem somewhat, but I hope I've still captured the essence of my problem. Let's say I have the following simple XML file: <main> outside1 ===BEGIN=== inside1 ====END==== outside2 =BEGIN= inside2 ==END== outside3 </main> Then I can use the following the XSLT 2.0: <?xml version="1.0" encodin...

What is the relative processing speed of manipulating data with XML or OOP techniques? (i.e. XProc or XSL vs C# or Java)

What is the difference in processing speed for executing a process using XML manipulation or using object-oriented representation? In general, is it faster to maximize or minimize the reliance on XML for a process. Let it be assumed that the code is highly optimized in either circumstance. A simple example of what I am asking is which...

Insert html-entities in xslt

I have some XMLs that contain character hex codes, e.g. it like this: <char hex="AB"/> Now I want to xslt transform for display in the browser: <xsl:value-of select="concat('&amp;#x', /char/@hex, ';', '')"/> However, the output in the browser is &amp;#xAB; and not as I expected &#xAB; so the browser does not display the character for...

XSL xsl:template match="/"

I am just learning XML and how to use XSL files. In an XSL file I found the following term: xsl:template match="/" What does this stand for ? And what could I use instead of the "/" ?? Could I write "table" or any other html tag instead of "/" ? ...

Using keys in xslt for converting trx file of mstest

I have written an xsl for converting the trx file of mstest into html. Following from this link, I'm unable to get the class names and number of passes and failures for each class to be printed in the output. I'm not sure where I'm goin wrong. the style sheet is applied on the same input file in the link. Thanks. <?xml version="1.0" enc...

How do I select child nodes that don't have a specific parent as an ancestor?

We use CruiseControl for our build server. It compiles our applications using MSBuild and uses its own XML logger that spits out something like the following XML: <project name="CI"> <target name="CompileApp"> <project name="Project1.csproj"> <target name="build"> <error>Compilation error one!</error> </target...

generate form key from a XML schema

I want send a message encoded as application/x-www-form-urlencoded, and the message is validated by a XML schema, so i find a way to generate a html form from a XML Schema using XSLT. the xsd is below: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:m="http://dongfang- china.com#" t...

XSLT: Finding last occurance in a string

Given a form number like: ABC_12345_Q-10 I want to end up with: ABC12345 So I need to find the position of the second underscore Note that there is not a standard pattern or length to any of the "sections" between the underscores (so I cannot use substring to simply eliminate the last section). xPath 2.0 solutions ok ...

simple XSL sorting issue

I am trying to sort an xml using xsl. Got some sample from xml.com. Its seems logical and intuitive. I tried, some how its not sorting. Its hard getting my head around this. Here is the Xsl I am using for sorting <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-c...

XSLT finding links inside tags in XML documents

Is there a way to have an xsl stylesheet recognize when a link appears inside a tag in an xml document and turn it into a working link? Example: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="guys.xsl"?> <people> <person> <name>Guy 1</name> <bio>Guy 1 is a guy.</bio> </person> ...

Clone contents of node into different namespace

I've updated the title and the text of my original question after gaining more knowledge on what's really going on. The misinterpreted the symptom as whitespace not being preserved while what's really going on was that the HTML elements weren't being interpreted as HTML. I'm writing a transformation from a WADL document to HTML. I need ...

How to add specific attribute to every node in Xml file using Xsl?

Hi I have a bit of Xml that looks something like this: <books> <book id="1"> <name>My book</name> <author>My author</author> </book> <book id="2"> <name>My other book</name> <author>My other author</author> </book> </books> I would like to have it look like: <books> <book id="1"> <name id="1">My book</n...

Transforming XML into HTML (as opposed to xhtml)

i want to transform some xml into HTML that has the following format: <TR><TD> col1 <TD> col2 <TD> col3 </TR> Note: The output is HTML, complete with optional closing tags omitted. This is the problem, and the reason the question exists. A snippet of the XSL i'm using is: <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl=...

Generating dynamic HTML table with XSL

I have the following XML data: <Activity> <ObjectGroup type="default"> <Object id="1874" name="PR1010Date" type="reference label" index="10" columnNo="0" dynamic="true"> <Description>Date</Description> <Value instance="0">30/06/2010</Value> </Object> <Object id="1875" name="PR1020LoggedBy" type="reference label...