ooo2ms_docpr.xsl 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. * This file is part of the LibreOffice project.
  4. *
  5. * This Source Code Form is subject to the terms of the Mozilla Public
  6. * License, v. 2.0. If a copy of the MPL was not distributed with this
  7. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  8. *
  9. * This file incorporates work covered by the following license notice:
  10. *
  11. * Licensed to the Apache Software Foundation (ASF) under one or more
  12. * contributor license agreements. See the NOTICE file distributed
  13. * with this work for additional information regarding copyright
  14. * ownership. The ASF licenses this file to you under the Apache
  15. * License, Version 2.0 (the "License"); you may not use this file
  16. * except in compliance with the License. You may obtain a copy of
  17. * the License at http://www.apache.org/licenses/LICENSE-2.0 .
  18. -->
  19. <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">
  20. <xsl:template match="office:meta">
  21. <o:DocumentProperties>
  22. <o:Title>
  23. <xsl:value-of select="dc:title"/>
  24. </o:Title>
  25. <o:Subject>
  26. <xsl:value-of select="dc:subject"/>
  27. </o:Subject>
  28. <o:Keywords>
  29. <xsl:for-each select="meta:keywords/meta:keyword">
  30. <xsl:value-of select="."/>
  31. <xsl:if test="position()!=last()">, </xsl:if>
  32. </xsl:for-each>
  33. </o:Keywords>
  34. <o:Description>
  35. <xsl:value-of select="dc:description"/>
  36. </o:Description>
  37. <o:Category>
  38. <xsl:value-of select="meta:user-defined[@meta:name = 'Category']"/>
  39. </o:Category>
  40. <o:Author>
  41. <xsl:value-of select="meta:initial-creator"/>
  42. </o:Author>
  43. <o:LastAuthor>
  44. <xsl:value-of select="dc:creator"/>
  45. </o:LastAuthor>
  46. <o:Manager>
  47. <xsl:value-of select="meta:user-defined[@meta:name = 'Manager']"/>
  48. </o:Manager>
  49. <o:Company>
  50. <xsl:value-of select="meta:user-defined[@meta:name = 'Company']"/>
  51. </o:Company>
  52. <o:HyperlinkBase>
  53. <xsl:value-of select="meta:user-defined[@meta:name = 'HyperlinkBase']"/>
  54. </o:HyperlinkBase>
  55. <o:Revision>
  56. <xsl:value-of select="meta:editing-cycles"/>
  57. </o:Revision>
  58. <!-- PresentationFormat, Guid, AppName, Version -->
  59. <o:TotalTime>
  60. <xsl:if test="meta:editing-duration">
  61. <xsl:variable name="hours">
  62. <xsl:choose>
  63. <xsl:when test="contains(meta:editing-duration, 'H')">
  64. <xsl:value-of select="substring-before( substring-after( meta:editing-duration, 'PT'), 'H')"/>
  65. </xsl:when>
  66. <xsl:otherwise>0</xsl:otherwise>
  67. </xsl:choose>
  68. </xsl:variable>
  69. <xsl:variable name="minutes">
  70. <xsl:choose>
  71. <xsl:when test="contains(meta:editing-duration, 'M') and contains(meta:editing-duration, 'H')">
  72. <xsl:value-of select="substring-before( substring-after( meta:editing-duration, 'H'), 'M')"/>
  73. </xsl:when>
  74. <xsl:when test="contains(meta:editing-duration, 'M')">
  75. <xsl:value-of select="substring-before( substring-after( meta:editing-duration, 'PT'), 'M')"/>
  76. </xsl:when>
  77. <xsl:otherwise>0</xsl:otherwise>
  78. </xsl:choose>
  79. </xsl:variable>
  80. <xsl:value-of select="$hours * 60 + $minutes"/>
  81. </xsl:if>
  82. </o:TotalTime>
  83. <o:LastPrinted>
  84. <xsl:if test="meta:print-date">
  85. <xsl:value-of select="concat( meta:print-date, 'Z')"/>
  86. </xsl:if>
  87. </o:LastPrinted>
  88. <o:Created>
  89. <xsl:if test="meta:creation-date">
  90. <xsl:value-of select="concat( meta:creation-date, 'Z')"/>
  91. </xsl:if>
  92. </o:Created>
  93. <o:LastSaved>
  94. <xsl:if test="dc:date">
  95. <xsl:value-of select="concat( dc:date, 'Z')"/>
  96. </xsl:if>
  97. </o:LastSaved>
  98. <o:Pages>
  99. <xsl:value-of select="meta:document-statistic/@meta:page-count"/>
  100. </o:Pages>
  101. <o:Words>
  102. <xsl:value-of select="meta:document-statistic/@meta:word-count"/>
  103. </o:Words>
  104. <o:Characters>
  105. <xsl:value-of select="meta:document-statistic/@meta:character-count"/>
  106. </o:Characters>
  107. <!-- CharactersWithSpaces, Bytes, Lines -->
  108. <o:Paragraphs>
  109. <xsl:value-of select="meta:document-statistic/@meta:paragraph-count"/>
  110. </o:Paragraphs>
  111. </o:DocumentProperties>
  112. <o:CustomDocumentProperties>
  113. <o:Editor dt:dt="string">
  114. <xsl:value-of select="meta:generator"/>
  115. </o:Editor>
  116. <o:Language dt:dt="string">
  117. <xsl:value-of select="dc:language"/>
  118. </o:Language>
  119. <xsl:for-each select="meta:user-defined">
  120. <!-- transfer strings to XML QName, necessary to convert several characters -->
  121. <!-- &#x7b;&#x7d; -->
  122. <xsl:variable name="foo">.,| ~`!@#$%^*()&amp;&lt;&gt;+=[];:&quot;/\?{}'</xsl:variable>
  123. <xsl:element name="{concat( 'o:', translate(@meta:name,string($foo),'_'))}">
  124. <xsl:attribute name="dt:dt">string</xsl:attribute>
  125. <xsl:value-of select="."/>
  126. </xsl:element>
  127. </xsl:for-each>
  128. </o:CustomDocumentProperties>
  129. </xsl:template>
  130. </xsl:stylesheet>