Testing: fix wrong link for calendar+todo issue (MBC #1397)

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.
This commit is contained in:
Zhu, Yongsheng 2010-05-13 17:29:37 +08:00 committed by Patrick Ohly
parent b92b017407
commit 0f36e5801b
2 changed files with 52 additions and 5 deletions

View File

@ -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>

View File

@ -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