On Fri, 2007-07-20 at 22:08 +0200, Raphael Hertzog wrote:
> I'm almost sure it won't work:
>
> <xsl:for-each select="document(concat('../base/', $dir, '/excuse.xml'))/excuse/item">
> <xsl:call-template name="outputitem"/>
> </xsl:for-each>
>
> The XSL only consider the content of <item> and you try to provide
> raw text and items mixed.
Ah :(
> > I'm not sure it is the right approach, making all lines with links in them
> > do something similar might be a better way to go so that all links in
> > the update_excuses.html file are preserved on the PTS page. If that is
> > wanted I can rework it.
>
> That looks sensible. It will probably require rework of the template "outputitem"
> however.
I'm not familiar with xsl enough to rework the outputitem xsl function,
I've updated the patch to the python code though (attached).
--
bye,
pabs
http://wiki.debian.org/PaulWise
--- excuses_to_xml.py~ 2007-07-21 12:34:21.000000000 +1000
+++ excuses_to_xml.py 2007-07-21 13:14:30.000000000 +1000
@@ -100,20 +100,21 @@
sub_elt.appendChild(doc.createTextNode(subline))
main_elt.appendChild(sub_elt)
else:
- sub_elt = doc.createElement("item")
- start = subline.find('href="http://')
- if start != -1:
- url = subline[start+6:subline.find('"',start+6)]
- # Manage broken links provided by the testing scripts
- url = string.replace(url, "+", "%2B")
- sub_elt.setAttribute("url", url)
- start = subline.find('href="#')
- if start != -1:
- url = subline[start+7:subline.find('"',start+7)]
- sub_elt.setAttribute("url", "http://packages.qa.debian.org/" + url)
- subline = striphtml(subline)
- sub_elt.appendChild(doc.createTextNode(subline))
- main_elt.appendChild(sub_elt)
+ subline = re.split('(<a href=".*">.*</a>)', subline)
+ for item in subline:
+ try:
+ (url, text) = re.match('<a href="(.*)">(.*)</a>', item).groups()
+ sub_elt = doc.createElement("item")
+ # Manage broken links provided by the testing scripts
+ if url[0] == '#':
+ url = "http://packages.qa.debian.org/" + url
+ url = string.replace(item[0], "+", "%2B")
+ sub_elt.setAttribute("url", url)
+ sub_elt.appendChild(doc.createTextNode(striphtml(text)))
+ except:
+ sub_elt = doc.createTextNode(striphtml(item))
+ main_elt.appendChild(sub_elt)
+ print main_elt
f.close()
Attachment:
signature.asc
Description: This is a digitally signed message part