| 1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|---|
| 2 |
<!DOCTYPE xsl:stylesheet [ |
|---|
| 3 |
<!ENTITY nbsp " "> |
|---|
| 4 |
]> |
|---|
| 5 |
<!-- |
|---|
| 6 |
(C) Copyright 2006 Nuxeo SAS <http://nuxeo.com> |
|---|
| 7 |
(C) Copyright 2004-2005 Nuxeo SARL <http://nuxeo.com> |
|---|
| 8 |
(C) Copyright 2003 Stefan Rinke <stefan@stefan-rinke.de> |
|---|
| 9 |
(C) Copyright 2002 Eric Bellot <ebellot@netcourrier.com> |
|---|
| 10 |
|
|---|
| 11 |
Authors: |
|---|
| 12 |
M.-A. Darche (Nuxeo) |
|---|
| 13 |
Stefan Rinke <stefan@stefan-rinke.de> |
|---|
| 14 |
Eric Bellot <ebellot@netcourrier.com> |
|---|
| 15 |
Laurent Godard <lgodard@indesko.com> |
|---|
| 16 |
|
|---|
| 17 |
This script is free software; you can redistribute it and/or |
|---|
| 18 |
modify it under the terms of the GNU Lesser General Public |
|---|
| 19 |
License as published by the Free Software Foundation; either |
|---|
| 20 |
version 2.1 of the License, or (at your option) any later version. |
|---|
| 21 |
|
|---|
| 22 |
This script is distributed in the hope that it will be useful, |
|---|
| 23 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 24 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 25 |
Lesser General Public License for more details. |
|---|
| 26 |
|
|---|
| 27 |
You should have received a copy of the GNU Lesser General Public |
|---|
| 28 |
License along with this library; if not, write to the Free Software |
|---|
| 29 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 30 |
|
|---|
| 31 |
See ``COPYING`` for more information. |
|---|
| 32 |
|
|---|
| 33 |
$Id$ |
|---|
| 34 |
--> |
|---|
| 35 |
<xsl:stylesheet version="1.0" |
|---|
| 36 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|---|
| 37 |
xmlns:office="http://openoffice.org/2000/office" |
|---|
| 38 |
xmlns:style="http://openoffice.org/2000/style" |
|---|
| 39 |
xmlns:text="http://openoffice.org/2000/text" |
|---|
| 40 |
xmlns:table="http://openoffice.org/2000/table" |
|---|
| 41 |
xmlns:draw="http://openoffice.org/2000/drawing" |
|---|
| 42 |
xmlns:fo="http://www.w3.org/1999/XSL/Format" |
|---|
| 43 |
xmlns:xlink="http://www.w3.org/1999/xlink" |
|---|
| 44 |
xmlns:number="http://openoffice.org/2000/datastyle" |
|---|
| 45 |
xmlns:svg="http://www.w3.org/2000/svg" |
|---|
| 46 |
xmlns:chart="http://openoffice.org/2000/chart" |
|---|
| 47 |
xmlns:dr3d="http://openoffice.org/2000/dr3d" |
|---|
| 48 |
xmlns:math="http://www.w3.org/1998/Math/MathML" |
|---|
| 49 |
xmlns:form="http://openoffice.org/2000/form" |
|---|
| 50 |
xmlns:script="http://openoffice.org/2000/script" |
|---|
| 51 |
xmlns:dc="http://purl.org/dc/elements/1.1/" |
|---|
| 52 |
xmlns:meta="http://openoffice.org/2000/meta" |
|---|
| 53 |
exclude-result-prefixes="office style text table draw |
|---|
| 54 |
fo xlink number svg chart dr3d math form script dc meta"> |
|---|
| 55 |
|
|---|
| 56 |
<xsl:output method="xml" indent="yes" omit-xml-declaration="no" |
|---|
| 57 |
doctype-public="-//OASIS//DTD DocBook XML V4.4//EN" |
|---|
| 58 |
doctype-system="http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"/> |
|---|
| 59 |
|
|---|
| 60 |
<!-- |
|---|
| 61 |
Parameter used to determine which top element the resulting tree will have. |
|---|
| 62 |
This parameter can be overridden by passing a parameter to the XSLT processor. |
|---|
| 63 |
Supported DocBook top elements are: article, book. |
|---|
| 64 |
It defaults to "article". |
|---|
| 65 |
--> |
|---|
| 66 |
<xsl:param name="topElementName">book</xsl:param> |
|---|
| 67 |
<xsl:param name="topElementMetainfoName"> |
|---|
| 68 |
<xsl:value-of select="concat($topElementName, 'info')"/> |
|---|
| 69 |
</xsl:param> |
|---|
| 70 |
|
|---|
| 71 |
<!-- Which unit to use --> |
|---|
| 72 |
<xsl:param name="measureUnit"> |
|---|
| 73 |
<xsl:choose> |
|---|
| 74 |
<xsl:when test="//table:table"> |
|---|
| 75 |
<xsl:call-template name="measureUnit"/> |
|---|
| 76 |
</xsl:when> |
|---|
| 77 |
<xsl:otherwise> |
|---|
| 78 |
<xsl:value-of select="'unknown'"/> |
|---|
| 79 |
</xsl:otherwise> |
|---|
| 80 |
</xsl:choose> |
|---|
| 81 |
</xsl:param> |
|---|
| 82 |
|
|---|
| 83 |
<xsl:variable name="oooGenerator" |
|---|
| 84 |
select="/office:document/office:meta/meta:generator"/> |
|---|
| 85 |
<xsl:variable name="oooVersion"> |
|---|
| 86 |
<xsl:value-of |
|---|
| 87 |
select="substring-before(substring-after($oooGenerator, ' '), ' ')"/> |
|---|
| 88 |
</xsl:variable> |
|---|
| 89 |
|
|---|
| 90 |
<xsl:template name="measureUnit"> |
|---|
| 91 |
<xsl:param name="firstValue" select="//style:properties[1]/@style:width"/> |
|---|
| 92 |
<xsl:if test="contains(string($firstValue), 'mm')"> |
|---|
| 93 |
<xsl:value-of select="'mm'"/> |
|---|
| 94 |
</xsl:if> |
|---|
| 95 |
<xsl:if test="contains(string($firstValue), 'cm')"> |
|---|
| 96 |
<xsl:value-of select="'cm'"/> |
|---|
| 97 |
</xsl:if> |
|---|
| 98 |
<xsl:if test="contains(string($firstValue), 'inch')"> |
|---|
| 99 |
<xsl:value-of select="'inch'"/> |
|---|
| 100 |
</xsl:if> |
|---|
| 101 |
<xsl:if test="contains(string($firstValue), 'pi')"> |
|---|
| 102 |
<xsl:value-of select="'pi'"/> |
|---|
| 103 |
</xsl:if> |
|---|
| 104 |
<xsl:if test="contains(string($firstValue), 'pt')"> |
|---|
| 105 |
<xsl:value-of select="'pt'"/> |
|---|
| 106 |
</xsl:if> |
|---|
| 107 |
<xsl:if test="contains(string($firstValue), '%')"> |
|---|
| 108 |
<xsl:value-of select="'%'"/> |
|---|
| 109 |
</xsl:if> |
|---|
| 110 |
</xsl:template> |
|---|
| 111 |
|
|---|
| 112 |
<!-- |
|---|
| 113 |
When called with the right parameters this template ouputs a |
|---|
| 114 |
processing-instruction specifying the print-orientation for the element that |
|---|
| 115 |
has the given style. |
|---|
| 116 |
|
|---|
| 117 |
Examples: |
|---|
| 118 |
<?print-orientation portrait?> |
|---|
| 119 |
<?print-orientation landscape?> |
|---|
| 120 |
|
|---|
| 121 |
Details given in the getPrintOrientation template. |
|---|
| 122 |
--> |
|---|
| 123 |
<xsl:template name="outputPrintOrientation"> |
|---|
| 124 |
<!-- Mandatory param --> |
|---|
| 125 |
<xsl:param name="styleName"/> |
|---|
| 126 |
<!-- Optional param --> |
|---|
| 127 |
<xsl:param name="parentStyleName" select="''"/> |
|---|
| 128 |
|
|---|
| 129 |
<xsl:variable name="printOrientation"> |
|---|
| 130 |
<xsl:call-template name="getPrintOrientation"> |
|---|
| 131 |
<xsl:with-param name="styleName" select="$styleName"/> |
|---|
| 132 |
<xsl:with-param name="parentStyleName" select="$parentStyleName"/> |
|---|
| 133 |
</xsl:call-template> |
|---|
| 134 |
</xsl:variable> |
|---|
| 135 |
<xsl:if test="string($printOrientation)"> |
|---|
| 136 |
<xsl:processing-instruction name="print-orientation"> |
|---|
| 137 |
<xsl:value-of select="$printOrientation"/> |
|---|
| 138 |
</xsl:processing-instruction> |
|---|
| 139 |
</xsl:if> |
|---|
| 140 |
</xsl:template> |
|---|
| 141 |
|
|---|
| 142 |
<!-- |
|---|
| 143 |
Return a string of styles having page orientation information. |
|---|
| 144 |
Example of output of this template: |
|---|
| 145 |
P1,portrait;P9,portrait;P14,portrait;P19,landscape;P20,landscape;P21,portrait; |
|---|
| 146 |
--> |
|---|
| 147 |
<xsl:variable name="styleNamesPrintOrientations"> |
|---|
| 148 |
<xsl:for-each select="//style:page-master"> |
|---|
| 149 |
<xsl:variable name="printOrientation" |
|---|
| 150 |
select="style:properties/@style:print-orientation"/> |
|---|
| 151 |
<xsl:variable name="pageMasterName" select="@style:name"/> |
|---|
| 152 |
<xsl:for-each select="//style:master-page[@style:page-master-name = $pageMasterName]"> |
|---|
| 153 |
<xsl:variable name="masterPageName" select="@style:name"/> |
|---|
| 154 |
<xsl:for-each select="//style:style[@style:master-page-name = $masterPageName]"> |
|---|
| 155 |
<xsl:value-of select="concat(@style:name, ',')"/> |
|---|
| 156 |
<xsl:value-of select="concat($printOrientation, ';')"/> |
|---|
| 157 |
</xsl:for-each> |
|---|
| 158 |
</xsl:for-each> |
|---|
| 159 |
</xsl:for-each> |
|---|
| 160 |
</xsl:variable> |
|---|
| 161 |
|
|---|
| 162 |
<!-- |
|---|
| 163 |
When called with the right parameters this template returns the |
|---|
| 164 |
print-orientation for the element that has the given style. |
|---|
| 165 |
|
|---|
| 166 |
Details: |
|---|
| 167 |
The style given to this template should be used the style of a text:h element |
|---|
| 168 |
used for defining a part (not in the DocBook or OOo sense) of the OOo |
|---|
| 169 |
document. So for example the style could be the one of the title (text:h) of |
|---|
| 170 |
the main content or an appendix. |
|---|
| 171 |
|
|---|
| 172 |
How it works: |
|---|
| 173 |
1. It looks for the page corresponding to the style:master-page-name of the |
|---|
| 174 |
given style (contained in the styles.xml file). |
|---|
| 175 |
2. It looks for the print-orientation of the page. |
|---|
| 176 |
--> |
|---|
| 177 |
<xsl:template name="getPrintOrientation"> |
|---|
| 178 |
<!-- Mandatory param --> |
|---|
| 179 |
<xsl:param name="styleName"/> |
|---|
| 180 |
<!-- Optional param --> |
|---|
| 181 |
<xsl:param name="parentStyleName" select="''"/> |
|---|
| 182 |
|
|---|
| 183 |
<!-- Implementation finding print-orientation from precomputed list --> |
|---|
| 184 |
<xsl:value-of select="substring-before( |
|---|
| 185 |
substring-after($styleNamesPrintOrientations, concat($styleName, ',')), |
|---|
| 186 |
';')"/> |
|---|
| 187 |
<xsl:if test="string($parentStyleName)"> |
|---|
| 188 |
<xsl:value-of select="substring-before( |
|---|
| 189 |
substring-after($styleNamesPrintOrientations, concat($parentStyleName, ',')), |
|---|
| 190 |
';')"/> |
|---|
| 191 |
</xsl:if> |
|---|
| 192 |
|
|---|
| 193 |
<!-- Implementation finding print-orientation dynamically --> |
|---|
| 194 |
<!-- |
|---|
| 195 |
<xsl:for-each select="//style:style[@style:name = $styleName]"> |
|---|
| 196 |
<xsl:variable name="masterPageName" select="@style:master-page-name"/> |
|---|
| 197 |
<xsl:for-each select="//style:master-page[@style:name = $masterPageName]"> |
|---|
| 198 |
<xsl:variable name="pageMasterName" select="@style:page-master-name"/> |
|---|
| 199 |
<xsl:for-each select="//style:page-master[@style:name = $pageMasterName]"> |
|---|
| 200 |
<xsl:value-of select="style:properties/@style:print-orientation"/> |
|---|
| 201 |
</xsl:for-each> |
|---|
| 202 |
</xsl:for-each> |
|---|
| 203 |
</xsl:for-each> |
|---|
| 204 |
--> |
|---|
| 205 |
</xsl:template> |
|---|
| 206 |
|
|---|
| 207 |
|
|---|
| 208 |
<!-- |
|---|
| 209 |
============= |
|---|
| 210 |
DOCUMENT ROOT |
|---|
| 211 |
============= |
|---|
| 212 |
--> |
|---|
| 213 |
<xsl:template match="/"> |
|---|
| 214 |
<xsl:element name="{$topElementName}"> |
|---|
| 215 |
<xsl:attribute name="lang"> |
|---|
| 216 |
<xsl:value-of select="/office:document/office:meta/dc:language"/> |
|---|
| 217 |
</xsl:attribute> |
|---|
| 218 |
|
|---|
| 219 |
<!-- Uncomment this to debug print-orientation processing-instructions --> |
|---|
| 220 |
<!-- |
|---|
| 221 |
<xsl:value-of select="$styleNamesPrintOrientations"/> |
|---|
| 222 |
--> |
|---|
| 223 |
|
|---|
| 224 |
<xsl:processing-instruction name="ooogenerator"> |
|---|
| 225 |
<xsl:value-of select="$oooGenerator"/> |
|---|
| 226 |
</xsl:processing-instruction> |
|---|
| 227 |
<xsl:processing-instruction name="oooversion"> |
|---|
| 228 |
<xsl:value-of select="$oooVersion"/> |
|---|
| 229 |
</xsl:processing-instruction> |
|---|
| 230 |
|
|---|
| 231 |
<xsl:call-template name="metaInfo"/> |
|---|
| 232 |
|
|---|
| 233 |
<!-- |
|---|
| 234 |
Only books can have preface elements. |
|---|
| 235 |
A book might have both a Foreword and an Introduction. |
|---|
| 236 |
Both should be tagged as preface. |
|---|
| 237 |
--> |
|---|
| 238 |
<xsl:if test="$topElementName='book'"> |
|---|
| 239 |
<xsl:call-template name="preface"/> |
|---|
| 240 |
</xsl:if> |
|---|
| 241 |
|
|---|
| 242 |
<!-- We start with the first title of level 1 --> |
|---|
| 243 |
<xsl:choose> |
|---|
| 244 |
<xsl:when test="/office:document/office:body/text:h[@text:level='1']"> |
|---|
| 245 |
<xsl:apply-templates |
|---|
| 246 |
select="/office:document/office:body/text:h[@text:level='1'][1]" |
|---|
| 247 |
mode="hierarchy"> |
|---|
| 248 |
<xsl:with-param name="source" select="$topElementName"/> |
|---|
| 249 |
</xsl:apply-templates> |
|---|
| 250 |
</xsl:when> |
|---|
| 251 |
<xsl:otherwise> |
|---|
| 252 |
<xsl:apply-templates select="/office:document/office:body" |
|---|
| 253 |
mode="noHierarchy"/> |
|---|
| 254 |
</xsl:otherwise> |
|---|
| 255 |
</xsl:choose> |
|---|
| 256 |
|
|---|
| 257 |
<xsl:call-template name="appendix"/> |
|---|
| 258 |
<xsl:call-template name="bibliography"/> |
|---|
| 259 |
<xsl:call-template name="glossary"/> |
|---|
| 260 |
<xsl:call-template name="index"/> |
|---|
| 261 |
</xsl:element> |
|---|
| 262 |
</xsl:template> |
|---|
| 263 |
|
|---|
| 264 |
|
|---|
| 265 |
<!-- |
|---|
| 266 |
============================= |
|---|
| 267 |
CHAPTER AND SECTION HIERARCHY |
|---|
| 268 |
============================= |
|---|
| 269 |
--> |
|---|
| 270 |
|
|---|
| 271 |
<xsl:template match="*|@*" name="hierarchy" mode="hierarchy"> |
|---|
| 272 |
<!-- Specify which element calls this template (optional) --> |
|---|
| 273 |
<xsl:param name="source"/> |
|---|
| 274 |
<!-- Store the current depth level (1, 2, etc.) (optional) --> |
|---|
| 275 |
<xsl:param name="level" select="'0'"/> |
|---|
| 276 |
<!-- |
|---|
| 277 |
Specify the id of the node you don't want to have in the result set |
|---|
| 278 |
(optional) |
|---|
| 279 |
--> |
|---|
| 280 |
<xsl:param name="excludeNodeId"/> |
|---|
| 281 |
|
|---|
| 282 |
<xsl:choose> |
|---|
| 283 |
|
|---|
| 284 |
<!-- If the matched element is not a title (text:h) --> |
|---|
| 285 |
<xsl:when test="name(.) != 'text:h'"> |
|---|
| 286 |
<xsl:call-template name="allTags"> |
|---|
| 287 |
<xsl:with-param name="source" select="'hierarchy'"/> |
|---|
| 288 |
</xsl:call-template> |
|---|
| 289 |
<xsl:apply-templates select="following-sibling::*[1]" mode="hierarchy"> |
|---|
| 290 |
<xsl:with-param name="level" select="$level"/> |
|---|
| 291 |
</xsl:apply-templates> |
|---|
| 292 |
</xsl:when> |
|---|
| 293 |
|
|---|
| 294 |
<!-- If the matched element is a title (text:h) |
|---|
| 295 |
and is deeper (level) than the preceding title --> |
|---|
| 296 |
<xsl:when test="@text:level > $level"> |
|---|
| 297 |
|
|---|
| 298 |
<!-- |
|---|
| 299 |
If we want to produce an article it is possible to have paras |
|---|
| 300 |
preceding the 1st title at level 1. We want to have those paras too |
|---|
| 301 |
when a preface or an appendix is encountered. |
|---|
| 302 |
So those instructions are used to display paras that could occur |
|---|
| 303 |
before any title is encountered. |
|---|
| 304 |
The only case when we don't want to have preceding paras is when the |
|---|
| 305 |
source is a book element, the source being the element calling the |
|---|
| 306 |
template, which means that a preface in a book can have paras before its |
|---|
| 307 |
first title, but chapters in a book cannot have paras before their |
|---|
| 308 |
first title. |
|---|
| 309 |
--> |
|---|
| 310 |
<xsl:if test="$source != 'book' |
|---|
| 311 |
and count(preceding-sibling::text:h[@text:level='1']) = 0"> |
|---|
| 312 |
<xsl:apply-templates select="preceding-sibling::*[ |
|---|
| 313 |
generate-id(.) != $excludeNodeId]" mode="noHierarchy"/> |
|---|
| 314 |
</xsl:if> |
|---|
| 315 |
|
|---|
| 316 |
<!-- |
|---|
| 317 |
We construct a new section (sectn) and the content of the "h" source |
|---|
| 318 |
element is placed into the "title" output element. |
|---|
| 319 |
--> |
|---|
| 320 |
<xsl:if test="$level >= 0"> |
|---|
| 321 |
<xsl:variable name="structuringElementName"> |
|---|
| 322 |
<xsl:choose> |
|---|
| 323 |
<xsl:when test="$level=0 and $source='book'"> |
|---|
| 324 |
<xsl:value-of select="'chapter'"/> |
|---|
| 325 |
</xsl:when> |
|---|
| 326 |
<xsl:otherwise> |
|---|
| 327 |
<xsl:value-of select="'section'"/> |
|---|
| 328 |
</xsl:otherwise> |
|---|
| 329 |
</xsl:choose> |
|---|
| 330 |
</xsl:variable> |
|---|
| 331 |
<xsl:element name="{$structuringElementName}"> |
|---|
| 332 |
<!-- Debug --> |
|---|
| 333 |
<!-- |
|---|
| 334 |
<level><xsl:value-of select="$level"/></level> |
|---|
| 335 |
<source><xsl:value-of select="$source"/></source> |
|---|
| 336 |
--> |
|---|
| 337 |
<xsl:call-template name="outputPrintOrientation"> |
|---|
| 338 |
<xsl:with-param name="styleName" select="@text:style-name"/> |
|---|
| 339 |
</xsl:call-template> |
|---|
| 340 |
<title><xsl:apply-templates/></title> |
|---|
| 341 |
<xsl:apply-templates select="following-sibling::*[1]" mode="hierarchy"> |
|---|
| 342 |
<xsl:with-param name="level" select="@text:level"/> |
|---|
| 343 |
<xsl:with-param name="source" select="$source"/> |
|---|
| 344 |
</xsl:apply-templates> |
|---|
| 345 |
</xsl:element> |
|---|
| 346 |
</xsl:if> |
|---|
| 347 |
|
|---|
| 348 |
<xsl:apply-templates select="following-sibling::*[1]" mode="scanLevel"> |
|---|
| 349 |
<xsl:with-param name="level" select="@text:level"/> |
|---|
| 350 |
<xsl:with-param name="source" select="$source"/> |
|---|
| 351 |
</xsl:apply-templates> |
|---|
| 352 |
|
|---|
| 353 |
</xsl:when> |
|---|
| 354 |
|
|---|
| 355 |
</xsl:choose> |
|---|
| 356 |
</xsl:template> |
|---|
| 357 |
|
|---|
| 358 |
<xsl:template match="*" mode="scanLevel"> |
|---|
| 359 |
<xsl:param name="level" select="'0'"/> |
|---|
| 360 |
<xsl:param name="source"/> |
|---|
| 361 |
<xsl:choose> |
|---|
| 362 |
<xsl:when test="@text:level < $level"/> |
|---|
| 363 |
<xsl:when test="@text:level = $level"> |
|---|
| 364 |
<xsl:call-template name="hierarchy"> |
|---|
| 365 |
<xsl:with-param name="level" select="$level - 1"/> |
|---|
| 366 |
<xsl:with-param name="source" select="$source"/> |
|---|
| 367 |
</xsl:call-template> |
|---|
| 368 |
</xsl:when> |
|---|
| 369 |
<xsl:otherwise> |
|---|
| 370 |
<xsl:apply-templates select="following-sibling::*[1]" mode="scanLevel"> |
|---|
| 371 |
<xsl:with-param name="level" select="$level"/> |
|---|
| 372 |
<xsl:with-param name="source" select="$source"/> |
|---|
| 373 |
</xsl:apply-templates> |
|---|
| 374 |
</xsl:otherwise> |
|---|
| 375 |
</xsl:choose> |
|---|
| 376 |
</xsl:template> |
|---|
| 377 |
|
|---|
| 378 |
<xsl:template match="/office:document/office:body" mode="noHierarchy"> |
|---|
| 379 |
<xsl:apply-templates mode="noHierarchy"/> |
|---|
| 380 |
</xsl:template> |
|---|
| 381 |
|
|---|
| 382 |
<xsl:template match="*|@*" mode="noHierarchy"> |
|---|
| 383 |
<xsl:call-template name="allTags"/> |
|---|
| 384 |
</xsl:template> |
|---|
| 385 |
|
|---|
| 386 |
<xsl:template name="allTags"> |
|---|
| 387 |
<xsl:param name="source"/> |
|---|
| 388 |
|
|---|
| 389 |
<xsl:choose> |
|---|
| 390 |
|
|---|
| 391 |
<xsl:when test="name(current())='text:h'"> |
|---|
| 392 |
<xsl:choose> |
|---|
| 393 |
<xsl:when test="$source='hierarchy'"/> |
|---|
| 394 |
<xsl:otherwise> |
|---|
| 395 |
<para>ERROR: Title hierarchy is wrong, section title is in bad position.</para> |
|---|
| 396 |
</xsl:otherwise> |
|---|
| 397 |
</xsl:choose> |
|---|
| 398 |
</xsl:when> |
|---|
| 399 |
|
|---|
| 400 |
<xsl:when test="name(current())='text:p'"> |
|---|
| 401 |
<xsl:call-template name="para"> |
|---|
| 402 |
<xsl:with-param name="source" select="$source"/> |
|---|
| 403 |
</xsl:call-template> |
|---|
| 404 |
</xsl:when> |
|---|
| 405 |
|
|---|
| 406 |
<xsl:when test="name(current())='text:ordered-list'"> |
|---|
| 407 |
<xsl:call-template name="ordList"/> |
|---|
| 408 |
</xsl:when> |
|---|
| 409 |
|
|---|
| 410 |
<xsl:when test="name(current())='text:unordered-list'"> |
|---|
| 411 |
<xsl:call-template name="unordList"/> |
|---|
| 412 |
</xsl:when> |
|---|
| 413 |
|
|---|
| 414 |
<xsl:when test="name(current())='table:table'"> |
|---|
| 415 |
<xsl:choose> |
|---|
| 416 |
<xsl:when test="$source='cellTable'"> |
|---|
| 417 |
<para>ERROR: Section title should not be in a cell.</para> |
|---|
| 418 |
</xsl:when> |
|---|
| 419 |
<xsl:otherwise> |
|---|
| 420 |
<xsl:call-template name="table"/> |
|---|
| 421 |
</xsl:otherwise> |
|---|
| 422 |
</xsl:choose> |
|---|
| 423 |
</xsl:when> |
|---|
| 424 |
|
|---|
| 425 |
</xsl:choose> |
|---|
| 426 |
</xsl:template> |
|---|
| 427 |
|
|---|
| 428 |
|
|---|
| 429 |
<!-- |
|---|
| 430 |
======== |
|---|
| 431 |
METAINFO |
|---|
| 432 |
======== |
|---|
| 433 |
--> |
|---|
| 434 |
|
|---|
| 435 |
<xsl:template match="/office:document/office:meta"/> |
|---|
| 436 |
<xsl:template match="text:p"/> |
|---|
| 437 |
|
|---|
| 438 |
<xsl:template name="metaInfo"> |
|---|
| 439 |
<xsl:param name="bodyRootPara" select="/office:document/office:body/text:p"/> |
|---|
| 440 |
<xsl:element name="{$topElementMetainfoName}"> |
|---|
| 441 |
<xsl:apply-templates select="$bodyRootPara" mode="metaInfo"/> |
|---|
| 442 |
<xsl:apply-templates select="/office:document/office:meta/dc:title"/> |
|---|
| 443 |
<xsl:apply-templates select="/office:document/office:meta/dc:date"/> |
|---|
| 444 |
<xsl:apply-templates select="/office:document/office:meta/dc:subject"/> |
|---|
| 445 |
<xsl:apply-templates select="/office:document/office:meta/meta:keywords"/> |
|---|
| 446 |
<xsl:call-template name="abstract"/> |
|---|
| 447 |
<xsl:call-template name="userFields"/> |
|---|
| 448 |
</xsl:element> |
|---|
| 449 |
</xsl:template> |
|---|
| 450 |
|
|---|
| 451 |
|
|---|
| 452 |
<xsl:template name="userFields"> |
|---|
| 453 |
<xsl:call-template name="metainfoUserFields"/> |
|---|
| 454 |
<xsl:call-template name="authorUserFields"/> |
|---|
| 455 |
<xsl:call-template name="publisherUserFields"/> |
|---|
| 456 |
<xsl:call-template name="contractsponsorUserFields"/> |
|---|
| 457 |
<xsl:call-template name="conferenceUserFields"/> |
|---|
| 458 |
</xsl:template> |
|---|
| 459 |
|
|---|
| 460 |
|
|---|
| 461 |
<xsl:template name="metainfoUserFields"> |
|---|
| 462 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 463 |
text:user-field-decl[@text:string-value!='' |
|---|
| 464 |
and starts-with(@text:name, 'metainfo_')]"> |
|---|
| 465 |
<xsl:if test="@text:name='metainfo_subtitle'"> |
|---|
| 466 |
<subtitle> |
|---|
| 467 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 468 |
</subtitle> |
|---|
| 469 |
</xsl:if> |
|---|
| 470 |
|
|---|
| 471 |
<xsl:if test="@text:name='metainfo_date'"> |
|---|
| 472 |
<date> |
|---|
| 473 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 474 |
</date> |
|---|
| 475 |
</xsl:if> |
|---|
| 476 |
|
|---|
| 477 |
<xsl:if test="@text:name='metainfo_abstract'"> |
|---|
| 478 |
<abstract> |
|---|
| 479 |
<para> |
|---|
| 480 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 481 |
</para> |
|---|
| 482 |
</abstract> |
|---|
| 483 |
</xsl:if> |
|---|
| 484 |
|
|---|
| 485 |
<xsl:if test="@text:name='metainfo_bibliomisc'"> |
|---|
| 486 |
<bibliomisc> |
|---|
| 487 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 488 |
</bibliomisc> |
|---|
| 489 |
</xsl:if> |
|---|
| 490 |
|
|---|
| 491 |
<xsl:if test="@text:name='metainfo_volumenum'"> |
|---|
| 492 |
<volumenum> |
|---|
| 493 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 494 |
</volumenum> |
|---|
| 495 |
</xsl:if> |
|---|
| 496 |
|
|---|
| 497 |
<xsl:if test="@text:name='metainfo_seriesvolnums'"> |
|---|
| 498 |
<seriesvolnums> |
|---|
| 499 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 500 |
</seriesvolnums> |
|---|
| 501 |
</xsl:if> |
|---|
| 502 |
|
|---|
| 503 |
<xsl:if test="@text:name='metainfo_contractnum'"> |
|---|
| 504 |
<contractnum> |
|---|
| 505 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 506 |
</contractnum> |
|---|
| 507 |
</xsl:if> |
|---|
| 508 |
|
|---|
| 509 |
<xsl:if test="@text:name='metainfo_isbn'"> |
|---|
| 510 |
<biblioid class="isbn"> |
|---|
| 511 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 512 |
</biblioid> |
|---|
| 513 |
</xsl:if> |
|---|
| 514 |
|
|---|
| 515 |
<xsl:if test="@text:name='metainfo_issn'"> |
|---|
| 516 |
<biblioid class="issn"> |
|---|
| 517 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 518 |
</biblioid> |
|---|
| 519 |
</xsl:if> |
|---|
| 520 |
|
|---|
| 521 |
<xsl:if test="@text:name='metainfo_isrn'"> |
|---|
| 522 |
<biblioid class="isrn"> |
|---|
| 523 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 524 |
</biblioid> |
|---|
| 525 |
</xsl:if> |
|---|
| 526 |
</xsl:for-each> |
|---|
| 527 |
</xsl:template> |
|---|
| 528 |
|
|---|
| 529 |
<xsl:template name="conferenceUserFields"> |
|---|
| 530 |
<confgroup> |
|---|
| 531 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 532 |
text:user-field-decl[@text:string-value!='' |
|---|
| 533 |
and starts-with(@text:name, 'metainfo_confgroup')]"> |
|---|
| 534 |
<xsl:if test="@text:name='metainfo_confgroup_address'"> |
|---|
| 535 |
<address> |
|---|
| 536 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 537 |
</address> |
|---|
| 538 |
</xsl:if> |
|---|
| 539 |
|
|---|
| 540 |
<xsl:if test="@text:name='metainfo_confgroup_confdates'"> |
|---|
| 541 |
<confdates> |
|---|
| 542 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 543 |
</confdates> |
|---|
| 544 |
</xsl:if> |
|---|
| 545 |
|
|---|
| 546 |
<xsl:if test="@text:name='metainfo_confgroup_confnum'"> |
|---|
| 547 |
<confnum> |
|---|
| 548 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 549 |
</confnum> |
|---|
| 550 |
</xsl:if> |
|---|
| 551 |
|
|---|
| 552 |
<xsl:if test="@text:name='metainfo_confgroup_confsponsor'"> |
|---|
| 553 |
<confsponsor> |
|---|
| 554 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 555 |
</confsponsor> |
|---|
| 556 |
</xsl:if> |
|---|
| 557 |
|
|---|
| 558 |
<xsl:if test="@text:name='metainfo_confgroup_conftitle'"> |
|---|
| 559 |
<conftitle> |
|---|
| 560 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 561 |
</conftitle> |
|---|
| 562 |
</xsl:if> |
|---|
| 563 |
|
|---|
| 564 |
</xsl:for-each> |
|---|
| 565 |
</confgroup> |
|---|
| 566 |
</xsl:template> |
|---|
| 567 |
|
|---|
| 568 |
<xsl:template name="authorUserFields"> |
|---|
| 569 |
<!-- |
|---|
| 570 |
Testing if there are authors to put in the authorgroup element because |
|---|
| 571 |
this element cannot be empty. |
|---|
| 572 |
XXX: Maybe there is way to optimize the treatments below where we test if |
|---|
| 573 |
there are some nodes (text:user-field-decl) and then look for those same |
|---|
| 574 |
nodes over again. |
|---|
| 575 |
--> |
|---|
| 576 |
|
|---|
| 577 |
<!-- tests if any author metadata exists --> |
|---|
| 578 |
<xsl:variable name="hasAuthor"> |
|---|
| 579 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/text:user-field-decl[@text:string-value!='' |
|---|
| 580 |
and starts-with(@text:name, 'metainfo_author')]"> |
|---|
| 581 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 582 |
</xsl:for-each> |
|---|
| 583 |
</xsl:variable> |
|---|
| 584 |
|
|---|
| 585 |
<xsl:if test="string($hasAuthor)"> |
|---|
| 586 |
<authorgroup> |
|---|
| 587 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 588 |
text:user-field-decl[@text:string-value!='' |
|---|
| 589 |
and starts-with(@text:name, 'metainfo_author') |
|---|
| 590 |
and contains(@text:name, '_surname')]"> |
|---|
| 591 |
<!-- Getting the "namexxx_" string --> |
|---|
| 592 |
<xsl:variable name="authorBase" |
|---|
| 593 |
select="concat(substring-before(@text:name, '_'), '_', |
|---|
| 594 |
substring-before(substring-after(@text:name, '_'), '_'), '_')"/> |
|---|
| 595 |
<author> |
|---|
| 596 |
<xsl:variable name="firstname"> |
|---|
| 597 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 598 |
text:user-field-decl[@text:name=concat($authorBase, 'firstname')]"> |
|---|
| 599 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 600 |
</xsl:for-each> |
|---|
| 601 |
</xsl:variable> |
|---|
| 602 |
<xsl:if test="string($firstname)"> |
|---|
| 603 |
<firstname><xsl:value-of select="$firstname"/></firstname> |
|---|
| 604 |
</xsl:if> |
|---|
| 605 |
|
|---|
| 606 |
<xsl:variable name="surname"> |
|---|
| 607 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 608 |
text:user-field-decl[@text:name=concat($authorBase, 'surname')]"> |
|---|
| 609 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 610 |
</xsl:for-each> |
|---|
| 611 |
</xsl:variable> |
|---|
| 612 |
<xsl:if test="string($surname)"> |
|---|
| 613 |
<surname><xsl:value-of select="$surname"/></surname> |
|---|
| 614 |
</xsl:if> |
|---|
| 615 |
|
|---|
| 616 |
<xsl:variable name="honorific"> |
|---|
| 617 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 618 |
text:user-field-decl[@text:name=concat($authorBase, 'honorific')]"> |
|---|
| 619 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 620 |
</xsl:for-each> |
|---|
| 621 |
</xsl:variable> |
|---|
| 622 |
<xsl:if test="string($honorific)"> |
|---|
| 623 |
<honorific><xsl:value-of select="$honorific"/></honorific> |
|---|
| 624 |
</xsl:if> |
|---|
| 625 |
|
|---|
| 626 |
<xsl:variable name="email"> |
|---|
| 627 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 628 |
text:user-field-decl[@text:name=concat($authorBase, 'email')]"> |
|---|
| 629 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 630 |
</xsl:for-each> |
|---|
| 631 |
</xsl:variable> |
|---|
| 632 |
<xsl:if test="string($email)"> |
|---|
| 633 |
<email><xsl:value-of select="$email"/></email> |
|---|
| 634 |
</xsl:if> |
|---|
| 635 |
|
|---|
| 636 |
|
|---|
| 637 |
<xsl:variable name="orgabbrev"> |
|---|
| 638 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 639 |
text:user-field-decl[@text:name=concat($authorBase, 'orgname_acronym')]"> |
|---|
| 640 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 641 |
</xsl:for-each> |
|---|
| 642 |
</xsl:variable> |
|---|
| 643 |
|
|---|
| 644 |
<xsl:variable name="jobtitle"> |
|---|
| 645 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 646 |
text:user-field-decl[@text:name=concat($authorBase, 'jobtitle')]"> |
|---|
| 647 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 648 |
</xsl:for-each> |
|---|
| 649 |
</xsl:variable> |
|---|
| 650 |
|
|---|
| 651 |
<xsl:variable name="orgname"> |
|---|
| 652 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 653 |
text:user-field-decl[@text:name=concat($authorBase, 'orgname')]"> |
|---|
| 654 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 655 |
</xsl:for-each> |
|---|
| 656 |
</xsl:variable> |
|---|
| 657 |
<xsl:variable name="orgdiv"> |
|---|
| 658 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 659 |
text:user-field-decl[@text:name=concat($authorBase, 'orgdiv')]"> |
|---|
| 660 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 661 |
</xsl:for-each> |
|---|
| 662 |
</xsl:variable> |
|---|
| 663 |
<xsl:variable name="address"> |
|---|
| 664 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 665 |
text:user-field-decl[@text:name=concat($authorBase, 'address')]"> |
|---|
| 666 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 667 |
</xsl:for-each> |
|---|
| 668 |
</xsl:variable> |
|---|
| 669 |
<xsl:if test="string($jobtitle) |
|---|
| 670 |
or string($orgname) or string($orgdiv) or string($orgabbrev) or string($address)"> |
|---|
| 671 |
<affiliation> |
|---|
| 672 |
<xsl:if test="string($orgabbrev)"> |
|---|
| 673 |
<shortaffil role="orgabbrev"><xsl:value-of select="$orgabbrev"/></shortaffil> |
|---|
| 674 |
</xsl:if> |
|---|
| 675 |
<xsl:if test="string($jobtitle)"> |
|---|
| 676 |
<jobtitle><xsl:value-of select="$jobtitle"/></jobtitle> |
|---|
| 677 |
</xsl:if> |
|---|
| 678 |
<xsl:if test="string($orgname)"> |
|---|
| 679 |
<orgname><xsl:value-of select="$orgname"/></orgname> |
|---|
| 680 |
</xsl:if> |
|---|
| 681 |
<xsl:if test="string($orgdiv)"> |
|---|
| 682 |
<orgdiv><xsl:value-of select="$orgdiv"/></orgdiv> |
|---|
| 683 |
</xsl:if> |
|---|
| 684 |
<xsl:if test="string($address)"> |
|---|
| 685 |
<address><xsl:value-of select="$address"/></address> |
|---|
| 686 |
</xsl:if> |
|---|
| 687 |
</affiliation> |
|---|
| 688 |
</xsl:if> |
|---|
| 689 |
</author> |
|---|
| 690 |
</xsl:for-each> |
|---|
| 691 |
</authorgroup> |
|---|
| 692 |
<!-- the prelimenary test |
|---|
| 693 |
--> |
|---|
| 694 |
</xsl:if> |
|---|
| 695 |
|
|---|
| 696 |
</xsl:template> |
|---|
| 697 |
|
|---|
| 698 |
|
|---|
| 699 |
<xsl:template name="publisherUserFields"> |
|---|
| 700 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 701 |
text:user-field-decl[ |
|---|
| 702 |
@text:string-value != '' |
|---|
| 703 |
and starts-with(@text:name, 'metainfo_corpauthor') |
|---|
| 704 |
and contains(@text:name, '_orgname') |
|---|
| 705 |
and substring-after(@text:name, '_orgname') = '' |
|---|
| 706 |
]"> |
|---|
| 707 |
<!-- Getting the "corpauthorxxx_" string --> |
|---|
| 708 |
<xsl:variable name="authorBase" |
|---|
| 709 |
select="concat(substring-before(@text:name, '_'), '_', |
|---|
| 710 |
substring-before(substring-after(@text:name, '_'), '_'), '_')"/> |
|---|
| 711 |
<publisher> |
|---|
| 712 |
<xsl:variable name="name"> |
|---|
| 713 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 714 |
text:user-field-decl[@text:name=concat($authorBase, 'orgname')]"> |
|---|
| 715 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 716 |
</xsl:for-each> |
|---|
| 717 |
</xsl:variable> |
|---|
| 718 |
<xsl:if test="string($name)"> |
|---|
| 719 |
<publishername><xsl:value-of select="$name"/></publishername> |
|---|
| 720 |
</xsl:if> |
|---|
| 721 |
|
|---|
| 722 |
<!-- |
|---|
| 723 |
Unused variable because there is no markup for this information |
|---|
| 724 |
in DocBook yet. |
|---|
| 725 |
--> |
|---|
| 726 |
<xsl:variable name="orgabbrev"> |
|---|
| 727 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 728 |
text:user-field-decl[@text:name=concat($authorBase, 'orgname_acronym')]"> |
|---|
| 729 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 730 |
</xsl:for-each> |
|---|
| 731 |
</xsl:variable> |
|---|
| 732 |
<!-- |
|---|
| 733 |
Unused variable because there is no markup for this information |
|---|
| 734 |
in DocBook yet. |
|---|
| 735 |
--> |
|---|
| 736 |
<xsl:variable name="orgdiv"> |
|---|
| 737 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 738 |
text:user-field-decl[@text:name=concat($authorBase, 'orgdiv')]"> |
|---|
| 739 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 740 |
</xsl:for-each> |
|---|
| 741 |
</xsl:variable> |
|---|
| 742 |
|
|---|
| 743 |
<xsl:variable name="street"> |
|---|
| 744 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 745 |
text:user-field-decl[@text:name=concat($authorBase, 'address')]"> |
|---|
| 746 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 747 |
</xsl:for-each> |
|---|
| 748 |
</xsl:variable> |
|---|
| 749 |
<xsl:variable name="pob"> |
|---|
| 750 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 751 |
text:user-field-decl[@text:name=concat($authorBase, 'pob')]"> |
|---|
| 752 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 753 |
</xsl:for-each> |
|---|
| 754 |
</xsl:variable> |
|---|
| 755 |
<xsl:variable name="postcode"> |
|---|
| 756 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 757 |
text:user-field-decl[@text:name=concat($authorBase, 'postcode')]"> |
|---|
| 758 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 759 |
</xsl:for-each> |
|---|
| 760 |
</xsl:variable> |
|---|
| 761 |
<xsl:variable name="city"> |
|---|
| 762 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 763 |
text:user-field-decl[@text:name=concat($authorBase, 'city')]"> |
|---|
| 764 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 765 |
</xsl:for-each> |
|---|
| 766 |
</xsl:variable> |
|---|
| 767 |
<xsl:variable name="state"> |
|---|
| 768 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 769 |
text:user-field-decl[@text:name=concat($authorBase, 'state')]"> |
|---|
| 770 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 771 |
</xsl:for-each> |
|---|
| 772 |
</xsl:variable> |
|---|
| 773 |
<xsl:variable name="phone"> |
|---|
| 774 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 775 |
text:user-field-decl[@text:name=concat($authorBase, 'phone')]"> |
|---|
| 776 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 777 |
</xsl:for-each> |
|---|
| 778 |
</xsl:variable> |
|---|
| 779 |
<xsl:variable name="fax"> |
|---|
| 780 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 781 |
text:user-field-decl[@text:name=concat($authorBase, 'fax')]"> |
|---|
| 782 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 783 |
</xsl:for-each> |
|---|
| 784 |
</xsl:variable> |
|---|
| 785 |
<xsl:variable name="email"> |
|---|
| 786 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 787 |
text:user-field-decl[@text:name=concat($authorBase, 'email')]"> |
|---|
| 788 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 789 |
</xsl:for-each> |
|---|
| 790 |
</xsl:variable> |
|---|
| 791 |
<xsl:variable name="ulink"> |
|---|
| 792 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 793 |
text:user-field-decl[@text:name=concat($authorBase, 'ulink')]"> |
|---|
| 794 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 795 |
</xsl:for-each> |
|---|
| 796 |
</xsl:variable> |
|---|
| 797 |
|
|---|
| 798 |
<xsl:if test="string($street) or string($pob) or string($postcode) |
|---|
| 799 |
or string($city) or string($state) |
|---|
| 800 |
or string($phone) or string($fax) or string($email) or string($ulink)"> |
|---|
| 801 |
<address> |
|---|
| 802 |
<xsl:if test="string($street)"> |
|---|
| 803 |
<street><xsl:value-of select="$street"/></street> |
|---|
| 804 |
</xsl:if> |
|---|
| 805 |
<xsl:if test="string($pob)"> |
|---|
| 806 |
<pob><xsl:value-of select="$pob"/></pob> |
|---|
| 807 |
</xsl:if> |
|---|
| 808 |
<xsl:if test="string($postcode)"> |
|---|
| 809 |
<postcode><xsl:value-of select="$postcode"/></postcode> |
|---|
| 810 |
</xsl:if> |
|---|
| 811 |
<xsl:if test="string($city)"> |
|---|
| 812 |
<city><xsl:value-of select="$city"/></city> |
|---|
| 813 |
</xsl:if> |
|---|
| 814 |
<xsl:if test="string($state)"> |
|---|
| 815 |
<state><xsl:value-of select="$state"/></state> |
|---|
| 816 |
</xsl:if> |
|---|
| 817 |
<xsl:if test="string($phone)"> |
|---|
| 818 |
<phone><xsl:value-of select="$phone"/></phone> |
|---|
| 819 |
</xsl:if> |
|---|
| 820 |
<xsl:if test="string($fax)"> |
|---|
| 821 |
<fax><xsl:value-of select="$fax"/></fax> |
|---|
| 822 |
</xsl:if> |
|---|
| 823 |
<xsl:if test="string($email)"> |
|---|
| 824 |
<email><xsl:value-of select="$email"/></email> |
|---|
| 825 |
</xsl:if> |
|---|
| 826 |
<xsl:if test="string($ulink)"> |
|---|
| 827 |
<otheraddr> |
|---|
| 828 |
<ulink> |
|---|
| 829 |
<xsl:attribute name="url"> |
|---|
| 830 |
<xsl:value-of select="$ulink"/> |
|---|
| 831 |
</xsl:attribute> |
|---|
| 832 |
<xsl:value-of select="$ulink"/> |
|---|
| 833 |
</ulink> |
|---|
| 834 |
</otheraddr> |
|---|
| 835 |
</xsl:if> |
|---|
| 836 |
</address> |
|---|
| 837 |
</xsl:if> |
|---|
| 838 |
</publisher> |
|---|
| 839 |
</xsl:for-each> |
|---|
| 840 |
</xsl:template> |
|---|
| 841 |
|
|---|
| 842 |
|
|---|
| 843 |
<xsl:template name="contractsponsorUserFields"> |
|---|
| 844 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 845 |
text:user-field-decl[ |
|---|
| 846 |
@text:string-value!='' |
|---|
| 847 |
and starts-with(@text:name, 'metainfo_contractsponsor') |
|---|
| 848 |
and contains(@text:name, '_orgname') |
|---|
| 849 |
and substring-after(@text:name, '_orgname') = '' |
|---|
| 850 |
]"> |
|---|
| 851 |
<!-- Getting the "contractsponsorxxx_" string --> |
|---|
| 852 |
<xsl:variable name="authorBase" |
|---|
| 853 |
select="concat(substring-before(@text:name, '_'), '_', |
|---|
| 854 |
substring-before(substring-after(@text:name, '_'), '_'), '_')"/> |
|---|
| 855 |
<xsl:variable name="name"> |
|---|
| 856 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 857 |
text:user-field-decl[@text:name=concat($authorBase, 'orgname')]"> |
|---|
| 858 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 859 |
</xsl:for-each> |
|---|
| 860 |
</xsl:variable> |
|---|
| 861 |
<xsl:variable name="street"> |
|---|
| 862 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 863 |
text:user-field-decl[@text:name=concat($authorBase, 'address')]"> |
|---|
| 864 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 865 |
</xsl:for-each> |
|---|
| 866 |
</xsl:variable> |
|---|
| 867 |
<xsl:variable name="pob"> |
|---|
| 868 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 869 |
text:user-field-decl[@text:name=concat($authorBase, 'pob')]"> |
|---|
| 870 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 871 |
</xsl:for-each> |
|---|
| 872 |
</xsl:variable> |
|---|
| 873 |
<xsl:variable name="postcode"> |
|---|
| 874 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 875 |
text:user-field-decl[@text:name=concat($authorBase, 'postcode')]"> |
|---|
| 876 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 877 |
</xsl:for-each> |
|---|
| 878 |
</xsl:variable> |
|---|
| 879 |
<xsl:variable name="city"> |
|---|
| 880 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 881 |
text:user-field-decl[@text:name=concat($authorBase, 'city')]"> |
|---|
| 882 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 883 |
</xsl:for-each> |
|---|
| 884 |
</xsl:variable> |
|---|
| 885 |
<xsl:variable name="state"> |
|---|
| 886 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 887 |
text:user-field-decl[@text:name=concat($authorBase, 'state')]"> |
|---|
| 888 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 889 |
</xsl:for-each> |
|---|
| 890 |
</xsl:variable> |
|---|
| 891 |
<xsl:variable name="phone"> |
|---|
| 892 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 893 |
text:user-field-decl[@text:name=concat($authorBase, 'phone')]"> |
|---|
| 894 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 895 |
</xsl:for-each> |
|---|
| 896 |
</xsl:variable> |
|---|
| 897 |
<xsl:variable name="fax"> |
|---|
| 898 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 899 |
text:user-field-decl[@text:name=concat($authorBase, 'fax')]"> |
|---|
| 900 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 901 |
</xsl:for-each> |
|---|
| 902 |
</xsl:variable> |
|---|
| 903 |
<xsl:variable name="email"> |
|---|
| 904 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 905 |
text:user-field-decl[@text:name=concat($authorBase, 'email')]"> |
|---|
| 906 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 907 |
</xsl:for-each> |
|---|
| 908 |
</xsl:variable> |
|---|
| 909 |
<xsl:variable name="ulink"> |
|---|
| 910 |
<xsl:for-each select="/office:document/office:body/text:user-field-decls/ |
|---|
| 911 |
text:user-field-decl[@text:name=concat($authorBase, 'ulink')]"> |
|---|
| 912 |
<xsl:value-of select="@text:string-value"/> |
|---|
| 913 |
</xsl:for-each> |
|---|
| 914 |
</xsl:variable> |
|---|
| 915 |
|
|---|
| 916 |
<contractsponsor> |
|---|
| 917 |
<xsl:value-of select="$name"/> |
|---|
| 918 |
<xsl:if test="string($street) or string($pob) or string($postcode) |
|---|
| 919 |
or string($city) or string($state) |
|---|
| 920 |
or string($phone) or string($fax) or string($email) or string($ulink)"> |
|---|
| 921 |
<xsl:comment>Address</xsl:comment> |
|---|
| 922 |
</xsl:if> |
|---|
| 923 |
<xsl:if test="string($street)"> |
|---|
| 924 |
<xsl:processing-instruction name="street"> |
|---|
| 925 |
<xsl:value-of select="$street"/> |
|---|
| 926 |
</xsl:processing-instruction> |
|---|
| 927 |
</xsl:if> |
|---|
| 928 |
<xsl:if test="string($pob)"> |
|---|
| 929 |
<xsl:processing-instruction name="pob"> |
|---|
| 930 |
<xsl:value-of select="$pob"/> |
|---|
| 931 |
</xsl:processing-instruction> |
|---|
| 932 |
</xsl:if> |
|---|
| 933 |
<xsl:if test="string($postcode)"> |
|---|
| 934 |
<xsl:processing-instruction name="postcode"> |
|---|
| 935 |
<xsl:value-of select="$postcode"/> |
|---|
| 936 |
</xsl:processing-instruction> |
|---|
| 937 |
</xsl:if> |
|---|
| 938 |
<xsl:if test="string($city)"> |
|---|
| 939 |
<xsl:processing-instruction name="city"> |
|---|
| 940 |
<xsl:value-of select="$city"/> |
|---|
| 941 |
</xsl:processing-instruction> |
|---|
| 942 |
</xsl:if> |
|---|
| 943 |
<xsl:if test="string($state)"> |
|---|
| 944 |
<xsl:processing-instruction name="state"> |
|---|
| 945 |
<xsl:value-of select="$state"/> |
|---|
| 946 |
</xsl:processing-instruction> |
|---|
| 947 |
</xsl:if> |
|---|
| 948 |
<xsl:if test="string($phone)"> |
|---|
| 949 |
<xsl:processing-instruction name="phone"> |
|---|
| 950 |
<xsl:value-of select="$phone"/> |
|---|
| 951 |
</xsl:processing-instruction> |
|---|
| 952 |
</xsl:if> |
|---|
| 953 |
<xsl:if test="string($fax)"> |
|---|
| 954 |
<xsl:processing-instruction name="fax"> |
|---|
| 955 |
<xsl:value-of select="$fax"/> |
|---|
| 956 |
</xsl:processing-instruction> |
|---|
| 957 |
</xsl:if> |
|---|
| 958 |
<xsl:if test="string($email)"> |
|---|
| 959 |
<xsl:processing-instruction name="email"> |
|---|
| 960 |
<xsl:value-of select="$email"/> |
|---|
| 961 |
</xsl:processing-instruction> |
|---|
| 962 |
</xsl:if> |
|---|
| 963 |
<xsl:if test="string($ulink)"> |
|---|
| 964 |
<xsl:processing-instruction name="ulink"> |
|---|
| 965 |
<xsl:value-of select="$ulink"/> |
|---|
| 966 |
</xsl:processing-instruction> |
|---|
| 967 |
</xsl:if> |
|---|
| 968 |
</contractsponsor> |
|---|
| 969 |
</xsl:for-each> |
|---|
| 970 |
</xsl:template> |
|---|
| 971 |
|
|---|
| 972 |
|
|---|
| 973 |
<xsl:template name="keywordsetContent"> |
|---|
| 974 |
<!-- |
|---|
| 975 |
keywordsString is a string of coma separated keywords |
|---|
| 976 |
Spaces can appear before or after the comas. |
|---|
| 977 |
A so called keyword can contain spaces. |
|---|
| 978 |
Examples: |
|---|
| 979 |
keywordsString = "aaa, bbb, ccc" |
|---|
| 980 |
keywordsString = "aaa , bbb ,ccc" |
|---|
| 981 |
keywordsString = "a aa, b bb, ccc" |
|---|
| 982 |
keywordsString = "a aa , b bb ,ccc" |
|---|
| 983 |
--> |
|---|
| 984 |
<xsl:param name="keywordsString"/> |
|---|
| 985 |
<xsl:if test="$keywordsString"> |
|---|
| 986 |
<xsl:choose> |
|---|
| 987 |
<xsl:when test="contains($keywordsString, ',')"> |
|---|
| 988 |
<keyword><xsl:value-of select="normalize-space(substring-before($keywordsString, ','))"/></keyword> |
|---|
| 989 |
<xsl:call-template name="keywordsetContent"> |
|---|
| 990 |
<xsl:with-param name="keywordsString" select="substring-after($keywordsString, ',')"/> |
|---|
| 991 |
</xsl:call-template> |
|---|
| 992 |
</xsl:when> |
|---|
| 993 |
<xsl:otherwise> |
|---|
| 994 |
<keyword><xsl:value-of select="normalize-space($keywordsString)"/></keyword> |
|---|
| 995 |
</xsl:otherwise> |
|---|
| 996 |
</xsl:choose> |
|---|
| 997 |
</xsl:if> |
|---|
| 998 |
</xsl:template> |
|---|
| 999 |
|
|---|
| 1000 |
|
|---|
| 1001 |
<xsl:template name="authorGroupContent"> |
|---|
| 1002 |
<!-- |
|---|
| 1003 |
authorsString is a string of semi-colon separated authors |
|---|
| 1004 |
Spaces can appear before or after the semi-colons. |
|---|
| 1005 |
A so called author can contain spaces and a coma. |
|---|
| 1006 |
If there is a coma for an author, the surname is first and then comes the |
|---|
| 1007 |
surname. This could have been the other way but this is how it is defined |
|---|
| 1008 |
in OOo. |
|---|
| 1009 |
Examples: |
|---|
| 1010 |
authorsString = "aaa; bbb; ccc" |
|---|
| 1011 |
authorsString = "aaa ; bbb ;ccc" |
|---|
| 1012 |
authorsString = "a aa; b bb; ccc" |
|---|
| 1013 |
authorsString = "a aa ; b bb ;ccc" |
|---|
| 1014 |
authorsString = " DOE, John ; Monroe, Marilyn ;Buzz" |
|---|
| 1015 |
--> |
|---|
| 1016 |
<xsl:param name="authorsString"/> |
|---|
| 1017 |
<xsl:if test="$authorsString"> |
|---|
| 1018 |
<xsl:choose> |
|---|
| 1019 |
<xsl:when test="contains($authorsString, ';')"> |
|---|
| 1020 |
<xsl:call-template name="authorGroupContent"> |
|---|
| 1021 |
<xsl:with-param name="authorsString" select="substring-after($authorsString, ';')"/> |
|---|
| 1022 |
</xsl:call-template> |
|---|
| 1023 |
</xsl:when> |
|---|
| 1024 |
<xsl:otherwise> |
|---|
| 1025 |
<author> |
|---|
| 1026 |
<personname> |
|---|
| 1027 |
<xsl:choose> |
|---|
| 1028 |
<xsl:when test="contains($authorsString , ',')"> |
|---|
| 1029 |
<xsl:variable name="surname" |
|---|
| 1030 |
select="normalize-space(substring-before($authorsString, ','))"/> |
|---|
| 1031 |
<xsl:variable name="firstname" |
|---|
| 1032 |
select="normalize-space(substring-after($authorsString, ','))"/> |
|---|
| 1033 |
<surname> |
|---|
| 1034 |
<xsl:value-of select="$surname"/> |
|---|
| 1035 |
</surname> |
|---|
| 1036 |
<xsl:if test="string($firstname)"> |
|---|
| 1037 |
<firstname> |
|---|
| 1038 |
<xsl:value-of select="$firstname"/> |
|---|
| 1039 |
</firstname> |
|---|
| 1040 |
</xsl:if> |
|---|
| 1041 |
</xsl:when> |
|---|
| 1042 |
<xsl:otherwise> |
|---|
| 1043 |
<surname> |
|---|
| 1044 |
<xsl:value-of select="$authorsString"/> |
|---|
| 1045 |
</surname> |
|---|
| 1046 |
</xsl:otherwise> |
|---|
| 1047 |
</xsl:choose> |
|---|
| 1048 |
</personname> |
|---|
| 1049 |
</author> |
|---|
| 1050 |
</xsl:otherwise> |
|---|
| 1051 |
</xsl:choose> |
|---|
| 1052 |
</xsl:if> |
|---|
| 1053 |
</xsl:template> |
|---|
| 1054 |
|
|---|
| 1055 |
|
|---|
| 1056 |
<xsl:template match="text:p" mode="metaInfo"> |
|---|
| 1057 |
<xsl:param name="inAuthor" select="'false'"/> |
|---|
| 1058 |
|
|---|
| 1059 |
<xsl:variable name="parentStyleName" |
|---|
| 1060 |
select="/office:document/office:automatic-styles/ |
|---|
| 1061 |
style:style[@style:name=(current()/@text:style-name)]/@style:parent-style-name"/> |
|---|
| 1062 |
|
|---|
| 1063 |
<!-- |
|---|
|
|---|