?xml-stylesheet href="style.xslt" type="text/xslt"?> ?xml-stylesheet href="style.xslt" type="text/xslt"?>

Unable to XSLT transform an trx file (MS LoadTest)


I am trying to transform a TRX file(XML) into HTML using XSLT, but can not get it to transform - at all

This is a mini version of my TRX/XML file

<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="style.xslt" type="text/xslt"?> <TestRun id="5d28f629-b34e-428c-9486-46368f6a6211" name="WIN8-VM-X 2014-09-15 10:15:32" runUser="WIN8-VM-X\jd" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"> <Results> <LoadTestResult executionId="bc475dd2-93d9-4cb5-ac3d-6b088615b8a8" testId="5d7e6f36-158f-4167-aeb3-6f9e5a5d021d" testName="LoadTest1" computerName="WIN8-VM-X" duration="00:02:58.3848158" startTime="2014-09-15T10:15:38.7219789+02:00" endTime="2014-09-15T10:18:37.1067947+02:00" testType="fa4c85ff-1236-4463-b954-3ba2f0eabd95" outcome="Completed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="bc475dd2-93d9-4cb5-ac3d-6b088615b8a8" runId="11" controllerStartTime="2014-09-15T10:15:38.7219789+02:00" runStatus="Stopped" resultsStoreType="Database" resultsRepositoryConnectString="LAs4ogoKlDd+VpAl2ugknpXtkwYcrJ4K4xho6CJjXD1Qv6o/LM9aSaAM4Ac5r6Taj3snulskUGTQzbVVXe9oT7r6RKtPoK7hv4F5g28RXiKSn9lO+5p/Kw==" loadTestDuration="600" loadTestWarmupTime="0" previouslyViewed="false"> <Summary> <PerformanceCounterResults> <PerformanceCounterResult isOverallResultCounter="true" higherIsBetter="true" machineName="WIN8-VM-X" categoryName="LoadTest:Scenario" counterName="User Load" instanceName="_Total" value="1" /> <PerformanceCounterResult isOverallResultCounter="true" higherIsBetter="true" machineName="WIN8-VM-X" categoryName="LoadTest:Test" counterName="Total Tests" instanceName="_Total" value="10" /> <PerformanceCounterResult isOverallResultCounter="true" higherIsBetter="false" machineName="WIN8-VM-X" categoryName="LoadTest:Test" counterName="Failed Tests" instanceName="_Total" value="9" /> <PerformanceCounterResult isOverallResultCounter="true" higherIsBetter="true" machineName="WIN8-VM-X" categoryName="LoadTest:Test" counterName="Tests/Sec" instanceName="_Total" value="0.0560585819" /> <PerformanceCounterResult isOverallResultCounter="true" higherIsBetter="false" machineName="WIN8-VM-X" categoryName="LoadTest:Test" counterName="Avg. Test Time" instanceName="_Total" value="13.0216" /> <PerformanceCounterResult isOverallResultCounter="true" higherIsBetter="true" machineName="WIN8-VM-X" categoryName="LoadTest:Request" counterName="Total Requests" instanceName="_Total" value="130" /> <PerformanceCounterResult isOverallResultCounter="true" higherIsBetter="false" machineName="WIN8-VM-X" categoryName="LoadTest:Request" counterName="Failed Requests" instanceName="_Total" value="18" /> <PerformanceCounterResult isOverallResultCounter="true" higherIsBetter="true" machineName="WIN8-VM-X" categoryName="LoadTest:Request" counterName="Cached Requests" instanceName="_Total" value="0" /> <PerformanceCounterResult isOverallResultCounter="true" higherIsBetter="true" machineName="WIN8-VM-X" categoryName="LoadTest:Request" counterName="Requests/Sec" instanceName="_Total" value="0.728761554" /> <PerformanceCounterResult isOverallResultCounter="true" higherIsBetter="false" machineName="WIN8-VM-X" categoryName="LoadTest:Request" counterName="Avg. Response Time" instanceName="_Total" value="0.9909615" /> <PerformanceCounterResult isOverallResultCounter="false" higherIsBetter="false" machineName="WIN8-VM-X" categoryName="Processor" counterName="% Processor Time" instanceName="_Total" value="43.6383438" /> <PerformanceCounterResult isOverallResultCounter="false" higherIsBetter="true" machineName="WIN8-VM-X" categoryName="Memory" counterName="Available MBytes" instanceName="-" value="214" /> <PerformanceCounterResult isOverallResultCounter="false" higherIsBetter="false" machineName="WIN8-VM-X" categoryName="Network Interface" counterName="Bytes Received/sec" instanceName="local area connection* 13" value="0" /> <PerformanceCounterResult isOverallResultCounter="false" higherIsBetter="false" machineName="WIN8-VM-X" categoryName="Network Interface" counterName="Bytes Received/sec" instanceName="intel[r] 82574l gigabit network connection" value="5012.82275" /> <PerformanceCounterResult isOverallResultCounter="false" higherIsBetter="false" machineName="WIN8-VM-X" categoryName="Network Interface" counterName="Bytes Received/sec" instanceName="isatap.localdomain" value="0" /> <PerformanceCounterResult isOverallResultCounter="false" higherIsBetter="false" machineName="WIN8-VM-X" categoryName="Network Interface" counterName="Bytes Sent/sec" instanceName="local area connection* 13" value="6.840497" /> <PerformanceCounterResult isOverallResultCounter="false" higherIsBetter="false" machineName="WIN8-VM-X" categoryName="Network Interface" counterName="Bytes Sent/sec" instanceName="intel[r] 82574l gigabit network connection" value="1746.74634" /> <PerformanceCounterResult isOverallResultCounter="false" higherIsBetter="false" machineName="WIN8-VM-X" categoryName="Network Interface" counterName="Bytes Sent/sec" instanceName="isatap.localdomain" value="0" /> </PerformanceCounterResults> <TestSummaries> <TestSummary scenarioName="Scenario1" testName="Testing" totalTests="10" testsFailed="9" averageDuration="13021" /> </TestSummaries> <TransactionSummaries> <TransactionSummary scenarioName="Scenario1" testName="Testing" transactionName="Testing.TestingCoded" transactionCount="10" elapsedTime="6772" responseTime="6772" /> <TransactionSummary scenarioName="Scenario1" testName="Testing" transactionName="Testing.TestingPartTwo" transactionCount="10" elapsedTime="6109" responseTime="6109" /> </TransactionSummaries> </Summary> </LoadTestResult> </Results> </TestRun>

And this is my XSLT file

<?xml version="1.0" encoding="utf-8"?> <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"> <xsl:output method="html" indent="yes" /> <xsl:template match="/TestRun/Results"> <html> <head> <title>Test Results</title> </head> <body> <table> <xsl:for-each select="/LoadTestResult/Summary/PerformanceCounterResults/PerformanceCounterResult"> <tr> <td> <xsl:value-of select="@counterName" /> </td> <td> <xsl:value-of select="@value" /> </td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>

Can anyone spot the error in the XSLT?


The problem is with namespaces. Your XML looks like this at the start...

<TestRun xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" ....

This means the TestRun element, and all its descendants, belong to that namespace. However, there is no sign of the namespace in your XSLT. Therefore, when you do this...

<xsl:template match="/TestRun/Results">

It is look for elements with no namespace, and such elements are different to ones in a namespace. Therefore the match is not matched.

The solution is to declare the namespace in the XSLT, and prefix all relevant elements in matching expressions with it.

Try this XSLT

<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:tt="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"> <xsl:output method="html" indent="yes" /> <xsl:template match="/tt:TestRun/tt:Results"> <html> <head> <title>Test Results</title> </head> <body> <table> <xsl:for-each select="tt:LoadTestResult/tt:Summary/tt:PerformanceCounterResults/tt:PerformanceCounterResult"> <tr> <td> <xsl:value-of select="@counterName" /> </td> <td> <xsl:value-of select="@value" /> </td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>

Also note there was an error in your xsl:for-each. You did this...

But the initial / represents the document node, so it would look for the root element called LoadTestResult. You need to drop the / to make it a relative expression.


  • Invoking service with @RequestParam and @RequestBody using postman client
  • Cassandra - conflict resolution for mixed column updates with identical timestamp
  • Is it possible to raise events on a subform's form, when that subform is bound to a table?
  • How to SUM the number of duplicates in a range by given value?
  • Posting JSON data from a Chrome browser extension to an MVC controller
  • PostgreSQL 9.3: How to insert upper case UUID into table
  • Need assistance with excel macro- vba
  • Make subset of array, based on values of two other arrays in Python
  • Limiting the number of categories on facets in a facet plot
  • How can I move the image in GUI
  • how do I copy same columns which are laterally placed from different worksheets into a single worksh
  • Convert a data frame column into a frequency distribution in R
  • hbase delete records based on portion of id
  • search all paths and the shortest path for a graph - Prolog
  • How can I create multiple tkinter widgets with different names in a loop?
  • Ping a Website or an IP Address (or Check if a Website is Online) using Swift 4?
  • Append divs to another div after its has already been appended to a div
  • R add new column depending on values in a range in different columns
  • Issue in dynamic table creation
  • Fetch subquery value from cursor to parameter in PL/SQL
  • Why does EF add tons of unused OUTER APPLY clauses when I put OrderBy at the beginning of my query
  • EF LINQ translation: complex query
  • Fast Stack-Columns and Transpose
  • PostgreSQL INSERT FROM SELECT with additional column
  • How to set crop box in jquery cropper
  • Use STL find_if() to find a specific object in a Vector of object pointers
  • Can sklearn DecisionTreeClassifier truly work with categorical data?
  • LINQ - Different results with LINQ to SQL vs LINQPad
  • SQL database problems with addressbook table design
  • How to multiply.outer() in NumPy while assuming 0 * infinity = 0?
  • Spark scala: SELECT in a foreach loop returns java.lang.NullPointerException
  • Generating and downloading an excel file generates a ERR_INVALID_RESPONSE
  • PostgreSQL: update with left outer self join ignored
  • Get value of last non-NA row per column in data.table
  • What is the difference in Angular2 between inject a provider in @Component and @Module?
  • Replace Inf in R data.table / Show number of Inf in colums
  • JOOQ nested condition
  • Inversing an interpolation of rotation
  • joining two bezier curves
  • Implementation of State Monad