1<?xml version="1.0" encoding="UTF-8"?>
2<!--***********************************************************
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements.  See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership.  The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License.  You may obtain a copy of the License at
11 *
12 *   http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied.  See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 *
21 ***********************************************************-->
22
23
24<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg   dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
25    <xsl:template match="office:meta">
26        <o:DocumentProperties>
27            <o:Title>
28                <xsl:value-of select="dc:title"/>
29            </o:Title>
30            <o:Subject>
31                <xsl:value-of select="dc:subject"/>
32            </o:Subject>
33            <o:Keywords>
34                <xsl:for-each select="meta:keywords/meta:keyword">
35                    <xsl:value-of select="."/>
36                    <xsl:if test="position()!=last()">, </xsl:if>
37                </xsl:for-each>
38            </o:Keywords>
39            <o:Description>
40                <xsl:value-of select="dc:description"/>
41            </o:Description>
42            <o:Category>
43                <xsl:value-of select="meta:user-defined[@meta:name = 'Category']"/>
44            </o:Category>
45            <o:Author>
46                <xsl:value-of select="meta:initial-creator"/>
47            </o:Author>
48            <o:LastAuthor>
49                <xsl:value-of select="dc:creator"/>
50            </o:LastAuthor>
51            <o:Manager>
52                <xsl:value-of select="meta:user-defined[@meta:name = 'Manager']"/>
53            </o:Manager>
54            <o:Company>
55                <xsl:value-of select="meta:user-defined[@meta:name = 'Company']"/>
56            </o:Company>
57            <o:HyperlinkBase>
58                <xsl:value-of select="meta:user-defined[@meta:name = 'HyperlinkBase']"/>
59            </o:HyperlinkBase>
60            <o:Revision>
61                <xsl:value-of select="meta:editing-cycles"/>
62            </o:Revision>
63            <!-- PresentationFormat, Guid, AppName, Version -->
64            <o:TotalTime>
65                <xsl:if test="meta:editing-duration">
66                    <xsl:variable name="hours">
67                        <xsl:choose>
68                            <xsl:when test="contains(meta:editing-duration, 'H')">
69                                <xsl:value-of select="substring-before( substring-after( meta:editing-duration, 'PT'), 'H')"/>
70                            </xsl:when>
71                            <xsl:otherwise>0</xsl:otherwise>
72                        </xsl:choose>
73                    </xsl:variable>
74                    <xsl:variable name="minutes">
75                        <xsl:choose>
76                            <xsl:when test="contains(meta:editing-duration, 'M') and contains(meta:editing-duration, 'H')">
77                                <xsl:value-of select="substring-before( substring-after( meta:editing-duration, 'H'), 'M')"/>
78                            </xsl:when>
79                            <xsl:when test="contains(meta:editing-duration, 'M')">
80                                <xsl:value-of select="substring-before( substring-after( meta:editing-duration, 'PT'), 'M')"/>
81                            </xsl:when>
82                            <xsl:otherwise>0</xsl:otherwise>
83                        </xsl:choose>
84                    </xsl:variable>
85                    <xsl:value-of select="$hours * 60 + $minutes"/>
86                </xsl:if>
87            </o:TotalTime>
88            <o:LastPrinted>
89                <xsl:if test="meta:print-date">
90                    <xsl:value-of select="concat( meta:print-date, 'Z')"/>
91                </xsl:if>
92            </o:LastPrinted>
93            <o:Created>
94                <xsl:if test="meta:creation-date">
95                    <xsl:value-of select="concat( meta:creation-date, 'Z')"/>
96                </xsl:if>
97            </o:Created>
98            <o:LastSaved>
99                <xsl:if test="dc:date">
100                    <xsl:value-of select="concat( dc:date, 'Z')"/>
101                </xsl:if>
102            </o:LastSaved>
103            <o:Pages>
104                <xsl:value-of select="meta:document-statistic/@meta:page-count"/>
105            </o:Pages>
106            <o:Words>
107                <xsl:value-of select="meta:document-statistic/@meta:word-count"/>
108            </o:Words>
109            <o:Characters>
110                <xsl:value-of select="meta:document-statistic/@meta:character-count"/>
111            </o:Characters>
112            <!-- CharactersWithSpaces, Bytes, Lines -->
113            <o:Paragraphs>
114                <xsl:value-of select="meta:document-statistic/@meta:paragraph-count"/>
115            </o:Paragraphs>
116        </o:DocumentProperties>
117        <o:CustomDocumentProperties>
118            <o:Editor dt:dt="string">
119                <xsl:value-of select="meta:generator"/>
120            </o:Editor>
121            <o:Language dt:dt="string">
122                <xsl:value-of select="dc:language"/>
123            </o:Language>
124            <xsl:for-each select="meta:user-defined">
125                <!-- transfer strings to XML QName, necessary to convert several characters -->
126                <xsl:element name="{concat( 'o:', translate(@meta:name,'.,| ~`!@#$%^&amp;&lt;&gt;*()+=[]{};:&quot;/\?','_'))}">
127                    <xsl:attribute name="dt:dt">string</xsl:attribute>
128                    <xsl:value-of select="."/>
129                </xsl:element>
130            </xsl:for-each>
131        </o:CustomDocumentProperties>
132    </xsl:template>
133</xsl:stylesheet>
134