-
Notifications
You must be signed in to change notification settings - Fork 1
/
jmeter2tsung.xsl
62 lines (58 loc) · 2.21 KB
/
jmeter2tsung.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?xml version="1.0" encoding="UTF-8"?>
<!--
Author : Rodolphe Quiédeville <[email protected]>
Src : https://github.com/rodo/tsung-tricks/
Licence : GPLv3
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output
method="xml"
encoding="UTF-8"
doctype-system="/usr/share/tsung/tsung-1.0.dtd"
indent="yes" />
<xsl:strip-space elements="hashTree"/>
<xsl:template match="//jmeterTestPlan">
<session name="{./hashTree/TestPlan/@testname}" weight="1" type="ts_http">
<xsl:apply-templates select="hashTree"/>
</session>
</xsl:template>
<xsl:template match="hashTree">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="TransactionController">
<transaction name="{@testname}">
<xsl:for-each select="following::hashTree">
<xsl:apply-templates />
</xsl:for-each>
</transaction>
</xsl:template>
<xsl:template match="HTTPSamplerProxy">
<request>
<xsl:choose>
<xsl:when test="./stringProp[@name='HTTPSampler.domain']/. != ''">
<xsl:choose>
<xsl:when test="./stringProp[@name='HTTPSampler.port']/. != ''">
<http
url="{./stringProp[@name='HTTPSampler.protocol']/.}://{./stringProp[@name='HTTPSampler.domain']/.}:{./stringProp[@name='HTTPSampler.port']/.}{./stringProp[@name='HTTPSampler.path']/.}"
method="{./stringProp[@name='HTTPSampler.method']/.}" version="1.1">
</http>
</xsl:when>
<xsl:otherwise>
<http
url="{./stringProp[@name='HTTPSampler.protocol']/.}://{./stringProp[@name='HTTPSampler.domain']/.}{./stringProp[@name='HTTPSampler.path']/.}"
method="{./stringProp[@name='HTTPSampler.method']/.}" version="1.1">
</http>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<http
url="{./stringProp[@name='HTTPSampler.path']/.}"
method="{./stringProp[@name='HTTPSampler.method']/.}" version="1.1">
</http>
</xsl:otherwise>
</xsl:choose>
</request>
</xsl:template>
<xsl:template match="*"/>
</xsl:stylesheet>