Created
May 29, 2019 12:46
-
-
Save jmlich/39159c82fad265628488492f362c276b to your computer and use it in GitHub Desktop.
export from testlink to xray. xsltproc testlink2xray.xsl My.testproject-deep.xml | php -r 'while(($line=fgets(STDIN)) !== FALSE) echo html_entity_decode($line, ENT_QUOTES|ENT_HTML401);'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" ?> | |
<!DOCTYPE stylesheet [ | |
<!ENTITY % w3centities-f PUBLIC "-//W3C//ENTITIES Combined Set//EN//XML" | |
"http://www.w3.org/2003/entities/2007/w3centities-f.ent"> | |
%w3centities-f; | |
]> | |
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output method="text" encoding="UTF-8" /> | |
<xsl:template match="/"> | |
<xsl:text>"internalid";"name";"execution_type";"importance";"estimated_exec_duration";"status";"is_open";"active";"preconditions";"summary";"steps" | |
</xsl:text> | |
<xsl:for-each select="testsuite"> | |
<xsl:call-template name="sections" /> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="sections"> | |
<xsl:param name="var_parent"/> | |
<xsl:if test="count(testsuite) > 0"> | |
<xsl:for-each select="testsuite"> | |
<xsl:variable name="parent_name"> | |
<xsl:if test="string-length($var_parent)>0"> | |
<xsl:value-of select="$var_parent" /> | |
<xsl:value-of select="' - '"/> | |
</xsl:if> | |
<xsl:value-of select="@name" /> | |
</xsl:variable> | |
<xsl:if test="count(testcase) > 0"> | |
<xsl:for-each select="testcase"> | |
<xsl:call-template name="testcase" > | |
<xsl:with-param name="var_parent" select="$parent_name" tunnel="yes"/> <!-- note the 'tunnel' attribute here, too! --> | |
</xsl:call-template> | |
</xsl:for-each> | |
</xsl:if> | |
<xsl:call-template name="sections" > | |
<xsl:with-param name="var_parent" select="$parent_name" tunnel="yes"/> <!-- note the 'tunnel' attribute here, too! --> | |
</xsl:call-template> | |
</xsl:for-each> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="nl2br"> | |
<xsl:param name="string"/> | |
<xsl:value-of select="normalize-space(substring-before($string,' '))"/> | |
<xsl:choose> | |
<xsl:when test="contains($string,' ')"> | |
<br /> | |
<xsl:call-template name="nl2br"> | |
<xsl:with-param name="string" select="substring-after($string,' ')"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="$string"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="strip_tags"> | |
<xsl:param name="text"/> | |
<xsl:choose> | |
<xsl:when test="contains($text, '<')"> | |
<xsl:value-of select="substring-before($text, '<')"/> | |
<xsl:call-template name="strip_tags"> | |
<xsl:with-param name="text" select="substring-after($text, '>')"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="$text"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="escape_quote"> | |
<xsl:param name="s" select="''"/> | |
<xsl:param name="encoded" select="''"/> | |
<xsl:choose> | |
<xsl:when test="$s = ''"> | |
<xsl:value-of select="$encoded"/> | |
</xsl:when> | |
<xsl:when test="contains($s, '"')"> | |
<xsl:call-template name="escape_quote"> | |
<xsl:with-param name="s" select="substring-after($s,'"')"/> | |
<xsl:with-param name="encoded" | |
select="concat($encoded,substring-before($s,'"'),'\"')"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="concat($encoded, $s)"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="testlink_filters"> | |
<xsl:param name="txt"/> | |
<xsl:variable name="output1"> | |
<xsl:call-template name="strip_tags"> | |
<xsl:with-param name="text" select="$txt"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="output2"> | |
<xsl:call-template name="escape_quote"> | |
<xsl:with-param name="s" select="$output1"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:value-of disable-output-escaping="yes" select="$output2"/> | |
</xsl:template> | |
<xsl:template name="testcase"> | |
<xsl:param name="var_parent"/> | |
<xsl:text>"</xsl:text> | |
<xsl:value-of select="@internalid" /> <xsl:text>";"</xsl:text> | |
<xsl:value-of select="$var_parent"/> <xsl:value-of select="' - '"/> <xsl:value-of select="@name" /> <xsl:text>";"</xsl:text> | |
<xsl:call-template name="testlink_filters"> <xsl:with-param name="txt" select="execution_type"/></xsl:call-template> <xsl:text>";"</xsl:text> | |
<xsl:call-template name="testlink_filters"> <xsl:with-param name="txt" select="importance"/></xsl:call-template> <xsl:text>";"</xsl:text> | |
<xsl:call-template name="testlink_filters"> <xsl:with-param name="txt" select="estimated_exec_duration"/></xsl:call-template> <xsl:text>";"</xsl:text> | |
<xsl:call-template name="testlink_filters"> <xsl:with-param name="txt" select="status"/></xsl:call-template> <xsl:text>";"</xsl:text> | |
<xsl:call-template name="testlink_filters"> <xsl:with-param name="txt" select="is_open"/></xsl:call-template> <xsl:text>";"</xsl:text> | |
<xsl:call-template name="testlink_filters"> <xsl:with-param name="txt" select="active"/></xsl:call-template> <xsl:text>";"</xsl:text> | |
<xsl:call-template name="testlink_filters"> <xsl:with-param name="txt" select="preconditions"/></xsl:call-template> <xsl:text>";"</xsl:text> | |
<xsl:call-template name="testlink_filters"> <xsl:with-param name="txt" select="summary"/></xsl:call-template> <xsl:text>";"</xsl:text> | |
<xsl:call-template name="testlink_filters"> <xsl:with-param name="txt" select="steps"/></xsl:call-template> | |
<xsl:text>" | |
</xsl:text> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment