Subject:
Maintain tag implemented in XSLT...
From:
Dan York ####@####.####
Date:
27 Jul 2001 20:20:10 -0000
Message-Id: <20010727161938.D5416@e-smith.com>
Well, I'm here at OLS... the wireless connection was too crappy to support
me ssh'ing back in to read my mail... so... I added support for the idea of
a "maintainer" role to the sample XSLT stylesheet I made up. I have
attached ldp.xsl, sample.xml and the output file sample.html. The command
I used to generate it was:
xsltproc -o sample.html ldp.xsl sample.xml
Note that this is my XSL stylesheet that does NOT do chunking (splitting
the file on sections/chapters).
The relevant part of the XML file looks like:
<authorgroup>
<author condition="Original">
<firstname>Dan</firstname>
<surname>York</surname>
<affiliation><orgname>Mitel Networks
Corporation</orgname></affiliation>
</author>
<author role="maintainer" condition="Current">
<firstname>Fred</firstname>
<surname>Frog</surname>
</author>
<author condition="Former">
<firstname>Sally</firstname>
<surname>Salmon</surname>
<affiliation><orgname>XYZ
Corporation</orgname></affiliation>
</author>
</authorgroup>
There are <affiliation> tags in there because I was playing with that as well.
The output looks like:
Original Author: Dan York
Mitel Networks Corporation
Current Maintainer: Fred Frog
Former Author: Sally Salmon
XYZ Corporation
The relevant part of the XSLT stylesheet is:
<xsl:template match="author" mode="titlepage.mode">
<h3 class="{name(.)}">
<!-- If there is a condition attribute, print it VERBATIM first -->
<xsl:if test="@condition"><i><xsl:value-of select="@condition"/></i>
<xsl:text> </xsl:text></xsl:if>
<!-- Test to see if there is a role. If maintainer, print that. If not,
assume it is an author. -->
<xsl:choose>
<xsl:when test="@role='maintainer'">
<i>Maintainer: </i>
</xsl:when>
<xsl:otherwise>
<i>Author: </i>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="person.name"/>
</h3>
<xsl:apply-templates mode="titlepage.mode" select="./contrib"/>
<xsl:apply-templates mode="titlepage.mode" select="./affiliation"/>
</xsl:template>
Basically, I chose to check for a "condition" attribute to the <author> tag.
If it exists, I copy it *verbatim* to be in front of either "Maintainer" or
"Author". My reason for this was to allow for many different types of
relationships - "Original", "Former", "Current", "Previous", etc.
I just chose to put it out as italicized text with a colon in front of the
author's name. This can, of course, be customized to whatever we decide.
Note that in my sample.xml, you do NOT have to put 'role="author"' into
an <author> tag. Basically, unless the role is "maintainer" the role
attribute is completely ignored. (Well, it uses the default
<xsl:otherwise> text) It could certainly be extended for other roles.
Enjoy,
Dan
P.S. I probably should check this into the LDP CVS server - how do I go about
getting an account there?
--
Dan York, Director of Training ####@####.####
Ph: +1-613-751-4401 Mobile: +1-613-263-4312 Fax: +1-613-564-7739
e-smith, inc. 150 Metcalfe St., Suite 1500, Ottawa,ON K2P 1P1 Canada
http://www.e-smith.com/ open source, open mind
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'
xmlns="http://www.w3.org/TR/xhtml1/transitional"
exclude-result-prefixes="#default">
<!-- Experimental stylesheet by Dan York
This is an attempt to replicate the customizations done in ldp.dsl
5 Jul 2001 -->
<!-- Change this to the path to where you have installed Norman
Walsh's XSL stylesheets -->
<xsl:import href="/usr/share/sgml/docbook/docbook-xsl-1.41/html/docbook.xsl"/>
<!-- NOT IN LDP.DSL
Creates header content in all generated HTML files -->
<xsl:template name="user.head.content">
<xsl:param name="node" select="."/>
<meta name="generator" content="Experimental LDP.XSL v1.0"/>
<xsl:comment> Generated by LDP XSLT customization layer
based on Norman Walsh's DocBook XSL stylesheets v1.40.
More information at http://www.linuxdoc.org/ </xsl:comment>
</xsl:template>
<!-- declare-characteristic preserve-sdata?
No longer appears necessary as it is a JadeTex issue. -->
<!-- generate-legalnotice-link? -->
<!-- If using admon graphics (1 below), what is path to graphics? -->
<xsl:param name="admon.graphics.path">
/usr/share/sgml/docbook/docbook-xsl-1.41/images
</xsl:param>
<!-- Should graphics be used for admonitions (notes, warnings)? 0 or 1 -->
<xsl:param name="admon.graphics" select="0"/>
<!-- Make funcsynopsis look pretty -->
<xsl:param name="funcsynopsis.decoration" select="1" doc:type="boolean"/>
<!-- Extension for HTML files -->
<xsl:param name="html.ext" select="'.html'"/>
<!-- Generate TOCs for book, article, part -->
<xsl:param name="generate.book.toc" select="1" doc:type="boolean"/>
<xsl:param name="generate.article.toc" select="1" doc:type="boolean"/>
<xsl:param name="generate.part.toc" select="1" doc:type="boolean"/>
<!-- generate-book-titlepage -->
<!-- generate-article-titlepage -->
<!-- Equivalent to chunk-skip-first-element-list - forces TOC on separate page
If 0, first sect is on page for chapter or article -->
<xsl:param name="chunk.first.sections" select="'1'"/>
<!-- NOT IN LDP.DSL -->
<!-- Create chunks for top-level sections. If 0, chunks will only be
created for chapters/appendixes, and NOT for sectx elements -->
<xsl:param name="chunk.sections" select="'1'"/>
<!-- list-element-list - NO LONGER NEEDED - bug fix -->
<!-- Filename for the root chunk -->
<xsl:param name="root.filename" select="'index'"/>
<!-- shade-verbatim
I have created a function below that shades the verbatim sections.
logic would need to be added to check if this is set. -->
<!-- When chunking, use id attribute as filename? 0 or 1 -->
<xsl:param name="use.id.as.filename" select="1"/>
<!-- graphic-extensions - NO LONGER NEEDED?? -->
<!-- default graphic filename extension -->
<xsl:param name="graphic.default.extension" select="'.gif'" doc:type="string"/>
<!-- Should chapters be labeled? 0 or 1 -->
<xsl:param name="chapter.autolabel" select="1"/>
<!-- Should sections be labeled? 0 or 1 -->
<xsl:param name="section.autolabel" select="1"/>
<!-- Related to section labels, should those labels include the chapter
number in them (i.e., 1.1, 1.2, 1.3, 1.4 )-->
<xsl:param name="section.label.includes.component.label" select="1" doc:type="boolean"/>
<!-- To what depth (in sections) should the TOC go? -->
<xsl:param name="toc.section.depth" select="2"/>
<!-- Custom 'emphasis' template to allow 'role="strong"' to
also produce a bold item. -->
<xsl:template match="emphasis">
<xsl:choose>
<xsl:when test="@role='bold'">
<xsl:call-template name="inline.boldseq"/>
</xsl:when>
<xsl:when test="@role='strong'">
<xsl:call-template name="inline.boldseq"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="inline.italicseq"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- book-titlepage-recto-elements
article-titlepage-recto-elements
article-titlepage-recto-mode
article-title
- Customizing these elements (for instance, to list what is on the
title page) involves writing a layer for html/titlepage.templates.xml and the
other files html/titlepage.xsl and html/titlepage.templates.xsl - Norm
is doing something funky here and I haven't fully figured it out. -->
<!-- The remainder of ldp.dsl deals with changing the foreground and
background colors of verbatim elements although in reading through the
DSSSL it doesn't look like it actually changed the foreground colors.
The changing of the background shading can be done at two locations
(one numbered, one not) in the template below. -->
<!-- Custom template for programlisting, screen and synopsis to generate a gray
background to the item. -->
<xsl:template match="programlisting|screen|synopsis">
<xsl:param name="suppress-numbers" select="'0'"/>
<xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
<xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
<xsl:if test="@id">
<a href="{$id}"/>
</xsl:if>
<xsl:choose>
<xsl:when test="$suppress-numbers = '0'
and @linenumbering = 'numbered'
and $use.extensions != '0'
and $linenumbering.extension != '0'">
<xsl:variable name="rtf">
<xsl:apply-templates/>
</xsl:variable>
<!-- Change the color bacground color in the line below. -->
<table border="0" bgcolor="#E0E0E0" width="90%">
<tr><td>
<pre class="{name(.)}">
<xsl:call-template name="number.rtf.lines">
<xsl:with-param name="rtf" select="$rtf"/>
</xsl:call-template>
</pre>
</td></tr></table>
</xsl:when>
<xsl:otherwise>
<!-- Change the color bacground color in the line below. -->
<table border="0" bgcolor="#E0E0E0" width="90%">
<tr><td>
<pre class="{name(.)}">
<xsl:apply-templates/>
</pre>
</td></tr></table>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Custom template to allow Maintainer to be a role in the Author element.
It also checks for a "condition" attribute to the <author> element. If it
finds the condition attribute, it copies VERBATIM the value of the
attribute to be in front of the word Author or Maintainer. This is done
to allow maximum flexibility.
Note that an <xsl:text> element was necessary to put the space between
the condition and the word Author or Maintainer. -->
<xsl:template match="author" mode="titlepage.mode">
<h3 class="{name(.)}">
<!-- If there is a condition attribute, print it VERBATIM first -->
<xsl:if test="@condition"><i><xsl:value-of select="@condition"/></i>
<xsl:text> </xsl:text></xsl:if>
<!-- Test to see if there is a role. If maintainer, print that. If not,
assume it is an author. -->
<xsl:choose>
<xsl:when test="@role='maintainer'">
<i>Maintainer: </i>
</xsl:when>
<xsl:otherwise>
<i>Author: </i>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="person.name"/>
</h3>
<xsl:apply-templates mode="titlepage.mode" select="./contrib"/>
<xsl:apply-templates mode="titlepage.mode" select="./affiliation"/>
</xsl:template>
</xsl:stylesheet>
--> -->
<type 'exceptions.IOError'> | Python 2.5.2: /usr/bin/python Wed Jul 3 14:14:13 2024 |
A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.
/opt/ezmlm-browse-0.20/main.py in main() |
424
|
425 if path is not None:
|
426 main_path(path)
|
427 else:
|
428 main_form()
|
global main_form = <function main_form at 0x950dc6c> |
/opt/ezmlm-browse-0.20/main.py in main_form() |
378 except ImportError:
|
379 die(ctxt, "Invalid command")
|
380 module.do(ctxt)
|
381
|
382 def main():
|
module = <module 'commands.showmsg' from '/opt/ezmlm-browse-0.20/commands/showmsg.pyc'>, module.do = <function do at 0x95166f4>, global ctxt = {'cmd': 'showmsg', 'threadidx': 0, 'HTTP_X_FORWA...HTTP_ACCEPT_ENCODING': 'gzip, br, zstd, deflate'} |
/opt/ezmlm-browse-0.20/commands/showmsg.py in do(ctxt={'cmd': 'showmsg', 'threadidx': 0, 'HTTP_X_FORWA...HTTP_ACCEPT_ENCODING': 'gzip, br, zstd, deflate'}) |
18 write(html('msg-pager') % ctxt)
|
19 write('<hr>')
|
20 sub_showmsg(ctxt, ctxt[MSGNUM])
|
21 write('<hr>')
|
22 write(html('msg-pager') % ctxt)
|
global sub_showmsg = <function sub_showmsg at 0x950d1ec>, ctxt = {'cmd': 'showmsg', 'threadidx': 0, 'HTTP_X_FORWA...HTTP_ACCEPT_ENCODING': 'gzip, br, zstd, deflate'}, global MSGNUM = 'msgnum' |
/opt/ezmlm-browse-0.20/globalfns.py in sub_showmsg(ctxt={'cmd': 'showmsg', 'threadidx': 0, 'HTTP_X_FORWA...HTTP_ACCEPT_ENCODING': 'gzip, br, zstd, deflate'}, msgnum=1199) |
229 format_timestamp(ctxt, ctxt)
|
230 write(html('msg-header') % ctxt)
|
231 rec_showpart(ctxt, msg, 0)
|
232 write(html('msg-footer') % ctxt)
|
233 ctxt.pop()
|
global rec_showpart = <function rec_showpart at 0x950d1b4>, ctxt = {'cmd': 'showmsg', 'threadidx': 0, 'HTTP_X_FORWA...HTTP_ACCEPT_ENCODING': 'gzip, br, zstd, deflate'}, msg = <email.message.Message instance at 0x957ef0c> |
/opt/ezmlm-browse-0.20/globalfns.py in rec_showpart(ctxt={'cmd': 'showmsg', 'threadidx': 0, 'HTTP_X_FORWA...HTTP_ACCEPT_ENCODING': 'gzip, br, zstd, deflate'}, part=<email.message.Message instance at 0x957ef0c>, partnum=2) |
205 else:
|
206 for p in part.get_payload():
|
207 partnum = rec_showpart(ctxt, p, partnum+1)
|
208 else:
|
209 write(html('msg-sep') % ctxt)
|
partnum = 2, global rec_showpart = <function rec_showpart at 0x950d1b4>, ctxt = {'cmd': 'showmsg', 'threadidx': 0, 'HTTP_X_FORWA...HTTP_ACCEPT_ENCODING': 'gzip, br, zstd, deflate'}, p = <email.message.Message instance at 0x957efcc> |
/opt/ezmlm-browse-0.20/globalfns.py in rec_showpart(ctxt={'cmd': 'showmsg', 'threadidx': 0, 'HTTP_X_FORWA...HTTP_ACCEPT_ENCODING': 'gzip, br, zstd, deflate'}, part=<email.message.Message instance at 0x957efcc>, partnum=3) |
208 else:
|
209 write(html('msg-sep') % ctxt)
|
210 sub_showpart(ctxt, part)
|
211 return partnum
|
212
|
global sub_showpart = <function sub_showpart at 0x950d144>, ctxt = {'cmd': 'showmsg', 'threadidx': 0, 'HTTP_X_FORWA...HTTP_ACCEPT_ENCODING': 'gzip, br, zstd, deflate'}, part = <email.message.Message instance at 0x957efcc> |
/opt/ezmlm-browse-0.20/globalfns.py in sub_showpart(ctxt={'cmd': 'showmsg', 'threadidx': 0, 'HTTP_X_FORWA...HTTP_ACCEPT_ENCODING': 'gzip, br, zstd, deflate'}, part=<email.message.Message instance at 0x957efcc>) |
164 type = ctxt[TYPE] = part.get_content_type()
|
165 ctxt[FILENAME] = part.get_filename()
|
166 template = html('msg-' + type.replace('/', '-'))
|
167 if not template:
|
168 template = html('msg-' + type[:type.find('/')])
|
global template = <function template at 0x9505e9c>, global html = <function html at 0x9505ed4>, type = 'text/xml', type.replace = <built-in method replace of str object at 0x9584a80> |
/opt/ezmlm-browse-0.20/globalfns.py in html(name='msg-text-xml') |
40
|
41 def html(name):
|
42 return template(name + '.html')
|
43
|
44 def xml(name):
|
global template = <function template at 0x9505e9c>, name = 'msg-text-xml' |
/opt/ezmlm-browse-0.20/globalfns.py in template(filename='msg-text-xml.html') |
31 except IOError:
|
32 if not _template_zipfile:
|
33 _template_zipfile = zipfile.ZipFile(sys.argv[0])
|
34 try:
|
35 f = _template_zipfile.open(n).read()
|
global _template_zipfile = None, global zipfile = <module 'zipfile' from '/usr/lib/python2.5/zipfile.pyc'>, zipfile.ZipFile = <class zipfile.ZipFile at 0x949ea7c>, global sys = <module 'sys' (built-in)>, sys.argv = ['-c', '/opt/ezmlm-browse-0.20'] |
/usr/lib/python2.5/zipfile.py in __init__(self=<zipfile.ZipFile instance at 0x9514c4c>, file='-c', mode='r', compression=0, allowZip64=False) |
337 self.filename = file
|
338 modeDict = {'r' : 'rb', 'w': 'wb', 'a' : 'r+b'}
|
339 self.fp = open(file, modeDict[mode])
|
340 else:
|
341 self._filePassed = 1
|
self = <zipfile.ZipFile instance at 0x9514c4c>, self.fp = None, builtin open = <built-in function open>, file = '-c', modeDict = {'a': 'r+b', 'r': 'rb', 'w': 'wb'}, mode = 'r' |
<type 'exceptions.IOError'>: [Errno 2] No such file or directory: '-c'
args =
(2, 'No such file or directory')
errno =
2
filename =
'-c'
message =
''
strerror =
'No such file or directory'