diff options
author | Zhu, Yongsheng <yongsheng.zhu@intel.com> | 2010-05-13 17:29:37 +0800 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2010-05-18 08:47:25 +0200 |
commit | 0f36e5801b3f9f74c4f0761ceea477b0727a84c1 (patch) | |
tree | d5d1ad8d4722ad3b5df4070f5c5331647057988c | |
parent | b92b017407718be6ca8c2bec83e76a6ec582a4ea (diff) |
Testing: fix wrong link for calendar+todo issue (MBC #1397)mbc1397
If the source type is 'calendar+todo' type, XML spec doesn't allow
'+' in the element tag. Thus the current solution is to replace
'calendar+todo' with 'calendar_todo'.
But this is not a good choice. Instead, escaped strings are used.
"_" is escaped to "__". "+" is escaped to "_-".
So firstly escape these 2 characters when generating nightly xml
documents and then unescape them when generating nightly html page.
-rw-r--r-- | test/generate-html.xsl | 53 | ||||
-rwxr-xr-x | test/resultchecker.py | 4 |
2 files changed, 52 insertions, 5 deletions
diff --git a/test/generate-html.xsl b/test/generate-html.xsl index 2bf03cfb..b17d18fd 100644 --- a/test/generate-html.xsl +++ b/test/generate-html.xsl @@ -265,7 +265,9 @@ </td> <td> <xsl:for-each select="$categories"> - <xsl:value-of select="name(.)"/> + <xsl:call-template name="stringescape"> + <xsl:with-param name="string" select="name(.)"/> + </xsl:call-template> <xsl:if test="position()!=last()"> <xsl:value-of select="', '"/> </xsl:if> @@ -562,7 +564,11 @@ <tr> <th>Item</th> <xsl:for-each select="$type-list"> - <th width="20"><xsl:value-of select="name(.)"/></th> + <th width="20"> + <xsl:call-template name="stringescape"> + <xsl:with-param name="string" select="name(.)"/> + </xsl:call-template> + </th> </xsl:for-each> </tr> @@ -594,7 +600,12 @@ skipped </xsl:when> <xsl:otherwise> - <a href="{concat($log-path,string(@prefix),name($type),'_',name($unit),$log-file-suffix)}"> + <xsl:variable name='escapedtype'> + <xsl:call-template name="stringescape"> + <xsl:with-param name="string" select="name($type)"/> + </xsl:call-template> + </xsl:variable> + <a href="{concat($log-path,string(@prefix),$escapedtype,'_',name($unit),$log-file-suffix)}"> <xsl:value-of select="$status"/> </a> </xsl:otherwise> @@ -792,5 +803,41 @@ <br/> </xsl:template> + <xsl:template name="stringescape"> + <xsl:param name="string"/> + <xsl:variable name="str"> + <xsl:call-template name="stringreplaceall"> + <xsl:with-param name="orginalstring" select="$string"/> + <xsl:with-param name="old" select="'__'"/> + <xsl:with-param name="new" select="'_'"/> + </xsl:call-template> + </xsl:variable> + <xsl:call-template name="stringreplaceall"> + <xsl:with-param name="orginalstring" select="string($str)"/> + <xsl:with-param name="old" select="'_-'"/> + <xsl:with-param name="new" select="'+'"/> + </xsl:call-template> + </xsl:template> + + <xsl:template name="stringreplaceall"> + <xsl:param name="orginalstring"/> + <xsl:param name="old"/> + <xsl:param name="new"/> + <xsl:choose> + <xsl:when test="contains($orginalstring, $old)"> + <xsl:value-of select="substring-before($orginalstring, $old)"/> + <xsl:value-of select="$new"/> + <xsl:call-template name="stringreplaceall"> + <xsl:with-param name="orginalstring" select="substring-after($orginalstring, $old)"/> + <xsl:with-param name="old" select="$old"/> + <xsl:with-param name="new" select="$new"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$orginalstring"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + </xsl:stylesheet> diff --git a/test/resultchecker.py b/test/resultchecker.py index 93adf3ef..58c169a1 100755 --- a/test/resultchecker.py +++ b/test/resultchecker.py @@ -245,8 +245,8 @@ def step2(resultdir, result, servers, indents, srcdir, shellprefix, backenddir): indents.append(indent) prefix = logprefix[format] qformat = format; - if (qformat.find('calendar+todo') !=-1): - qformat = format.replace('calendar+todo', 'calendar_todo') + qformat = qformat.replace("_", "__"); + qformat = qformat.replace("+", "_-"); result.write(indent+'<'+qformat+' prefix="'+prefix+'">\n') for case in logdic[format]: indent +=space |