XSLFO-Schedule-Kram

git-svn-id: svn://svn.c3d2.de/c3d2-web/trunk@930 31f61c52-7bfb-0310-b897-fc00f8a278f0
This commit is contained in:
astro 2007-05-04 22:11:11 +00:00
parent 2c73b03d14
commit d0c2f3aaaa
4 changed files with 278 additions and 0 deletions

View File

@ -0,0 +1,33 @@
EXPORT_URL=http://www.datenspuren.de/fahrplan/
FOP=~/programs/fop/fop
XSLT=xsltproc
XSLT_FLAGS=--novalid
XEP=~/Java/XEP/xep
KEEP=day_1.de.html day_2.de.html
FOP_FILES=day_1.pdf day_2.pdf
XEP_FILES=day_1-xep.pdf day_2-xep.pdf
all: $(FOP_FILES) $(XEP_FILES) $(KEEP)
day_%.de.html:
wget -O $@ $(EXPORT_URL)/$@
schedule.de.xml:
wget -O $@ $(EXPORT_URL)/$@
day_%.xml: day_%.de.html day_schedule.xsl schedule.de.xml
$(XSLT) $(XSLT_FLAGS) day_schedule.xsl $<|ruby schedule_add_spans.rb > $@
day_%.fo: day_%.xml schedule-fo.xsl
$(XSLT) $(XSLT_FLAGS) -o $@ schedule-fo.xsl $<
day_%-xep.pdf: day_%.fo
$(XEP) -fo $< -pdf $@
day_%.pdf: day_%.fo
$(FOP) $(FOP_FLAGS) -fo $< -pdf $@
clean:
rm -f day_*.{de.html,xml,fo,pdf} schedule.de.xml

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:x="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
exclude-result-prefixes="x xsl date">
<xsl:output method="xml"
version="1.0"
encoding="utf-8"
indent="yes"/>
<xsl:strip-space elements="table thead tbody tr"/>
<xsl:template match="/x:html">
<schedule-matrix version="{document('schedule.de.xml')/schedule/conference/release}" ctime="{date:date-time()}">
<title>
<xsl:value-of select="//x:p[@class='intro']/x:strong"/>
</title>
<subtitle>
<xsl:value-of select="//x:div[@id='schedule']/x:h1"/>
</subtitle>
<xsl:apply-templates select="//x:div[@id='schedule']/x:table"/>
</schedule-matrix>
</xsl:template>
<xsl:template match="x:table">
<rooms>
<xsl:apply-templates select="x:thead/x:tr/x:th/x:strong"/>
</rooms>
<table>
<xsl:apply-templates select="x:tbody/x:tr[string(@class)!='noprint']"/>
</table>
</xsl:template>
<xsl:template match="x:th/x:strong">
<room>
<xsl:apply-templates/>
</room>
</xsl:template>
<xsl:template match="x:tbody/x:tr">
<timeslot time="{x:td[@class='time']}">
<xsl:apply-templates/>
</timeslot>
</xsl:template>
<xsl:template match="x:tbody/x:tr/x:td[@class='time']"/>
<xsl:template match="x:tbody/x:tr/x:td[@class='room empty']">
<empty/>
</xsl:template>
<xsl:template match="x:tbody/x:tr/x:td[starts-with(@class,'room event ')]">
<!--xsl:variable name="id" select="substring-before(substring-after(p[@class='title']/a/@href, '/events/'), '.de.html')"/-->
<xsl:variable name="id" select="substring-before(substring-after(x:p[@class='title']/x:a/@href, '/events/'), '.de.html')"/>
<event slots="{@rowspan}" id="{$id}">
<xsl:copy-of select="document('schedule.de.xml')/schedule/day/room/event[@id=$id]/*"/>
</event>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,149 @@
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
xmlns="http://www.w3.org/1999/XSL/Format">
<xsl:attribute-set name="table-headers">
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="font-size">14pt</xsl:attribute>
<xsl:attribute name="text-align">center</xsl:attribute>
</xsl:attribute-set>
<xsl:template match="/schedule-matrix">
<root>
<layout-master-set>
<simple-page-master master-name="FullPage"
page-width="210mm" page-height="297mm"
margin-top="8mm" margin-bottom="8mm"
margin-left="8mm" margin-right="8mm">
<region-body/>
</simple-page-master>
</layout-master-set>
<page-sequence master-reference="FullPage">
<flow flow-name="xsl-region-body" font-size="14pt">
<block text-align="right" font-size="8pt">
Release <xsl:value-of select="@version"/>,
<!--xsl:value-of select="concat(date:day-in-month(@ctime),'.',date:month-in-year(@ctime),'.',date:year(@ctime),' ',date:hour-in-day(@ctime),':',date:minute-in-hour(@ctime),':',date:second-in-minute(@ctime))"/-->
<xsl:value-of select="concat(date:day-in-month(@ctime),'.',date:month-in-year(@ctime),'.',date:year(@ctime),' ',date:time(@ctime))"/>
</block>
<xsl:apply-templates select="title"/>
<xsl:apply-templates select="subtitle"/>
<xsl:variable name="table-width" select="210-8-8-15"/>
<table table-layout="fixed" width="{$table-width}mm" border-collapse="collapse">
<table-column column-width="15mm"/>
<xsl:for-each select="rooms/room">
<table-column column-width="{$table-width div count(../room)}mm"/>
</xsl:for-each>
<table-header>
<table-row>
<table-cell>
<xsl:element name="block" use-attribute-sets="table-headers">
Zeit
</xsl:element>
</table-cell>
<xsl:apply-templates select="rooms"/>
</table-row>
</table-header>
<table-body>
<xsl:apply-templates select="table"/>
</table-body>
</table>
</flow>
</page-sequence>
</root>
</xsl:template>
<xsl:template match="title">
<block font-size="30pt" text-align="center" font-weight="bold" margin-bottom="1mm">
<xsl:apply-templates/>
</block>
</xsl:template>
<xsl:template match="subtitle">
<block font-size="20pt" text-align="center" font-weight="bold" margin-bottom="5mm">
<xsl:apply-templates/>
</block>
</xsl:template>
<xsl:template match="rooms/room">
<table-cell>
<xsl:element name="block" use-attribute-sets="table-headers">
<xsl:apply-templates/>
</xsl:element>
</table-cell>
</xsl:template>
<xsl:template match="table/timeslot">
<xsl:variable name="timeslot" select="position()"/>
<xsl:variable name="previous-timeslot" select="preceding-sibling::*"/>
<xsl:message>== <xsl:value-of select="$previous-timeslot/@time"/> ++ <xsl:value-of select="@time"/> ==</xsl:message>
<table-row>
<table-cell display-align="center">
<block text-align="center">
<xsl:variable name="posteventempty">
<xsl:for-each select="*">
<xsl:variable name="track" select="position()"/>
<!--xsl:if test="(name(.) = 'empty') and (name(../preceding-sibling::*[position() = $track]) = 'span')"-->
<xsl:message><xsl:value-of select="$track"/>: <xsl:value-of select="name(../preceding-sibling::timeslot/*[position() = $track])"/> + <xsl:value-of select="name(.)"/></xsl:message>
<xsl:if test="name(.) != name(../preceding-sibling::timeslot/*[position() = $track])">
y
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:if test="(count(span) != count(../../rooms/room)) or contains($posteventempty, 'y')">
<xsl:value-of select="@time"/>
</xsl:if>
</block>
</table-cell>
<xsl:apply-templates/>
</table-row>
</xsl:template>
<xsl:template match="table/timeslot/empty">
<table-cell margin="0" background-color="#ccc">
<block>
</block>
</table-cell>
</xsl:template>
<xsl:template match="table/timeslot/span"/>
<xsl:template match="table/timeslot/event">
<table-cell number-rows-spanned="{@slots}"
border-style="solid" border-width="0.4mm" border-color="#333"
padding="1mm">
<block font-weight="bold">
<xsl:value-of select="title"/>
</block>
<block font-style="italic" font-size="12pt">
<xsl:value-of select="subtitle"/>
</block>
<block display-align="after" font-size="12pt">
<xsl:for-each select="persons/person[string(.) != '&lt;&lt;&lt;/&gt;&gt; Network']">
<xsl:if test="position() &gt; 1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:value-of select="."/>
</xsl:for-each>
</block>
</table-cell>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,32 @@
#!/usr/bin/env ruby
require 'rexml/document'
matrix = REXML::Document.new($stdin).root
tracks = 0
matrix.each_element('rooms/room') {
tracks += 1
}
trackspans = [0] * tracks
matrix.each_element('table/timeslot') { |timeslot|
events = []
timeslot.each_element { |event|
timeslot.delete(event)
events << event
}
$stderr.puts trackspans.inspect
tracks.times { |i|
if trackspans[i] > 1
timeslot.add(REXML::Element.new('span'))
trackspans[i] -= 1
else
event = events.shift || REXML::Element.new('empty')
timeslot.add(event)
if event.name == 'event'
trackspans[i] = (event.attributes['slots'] || 1).to_i
end
end
}
$stderr.puts "Stale elements: #{events.inspect}" if events.size > 0
}
matrix.write($stdout, 0)