首页 > 解决方案 > 某些版本的 word 中不显示参考书目样式

问题描述

下午好。

我正在为 Word 做一些自定义书目样式。问题是代码确实出现在我的 Windows 上的 2016 Word 和 Mac 上的另一个版本的 Office 365 中。但是它们并没有出现在我尝试过的另外两台 Macbook 上,两者都带有 Office 365。(起初我以为是因为 Mac 上的文件权限,但这并没有解决问题https://answers.microsoft.com/en-us/mac/forum/macoffice2016-macword/word-2016-for- mac-os-x-yosemite-numeric/200b578a-4007-4226-aad6-8132e2958298 )

<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0" 
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
   xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
   xmlns:b="http://schemas.openxmlformats.org/officeDocument/2006/bibliography" 
   xmlns:t="http://www.microsoft.com/temp">
   <xsl:output method="html" encoding="utf-8"/>

   <xsl:template match="*" mode="outputHtml2">
      <xsl:apply-templates mode="outputHtml"/>
  </xsl:template>


   <!--Match the root element, and dispatch to its children-->

   <xsl:template match="/">
      <xsl:apply-templates select="*" />
      <xsl:choose>
         <xsl:when test="b:Version">
            <xsl:text>2019.9.29</xsl:text>
         </xsl:when>

         <xsl:when test="b:XslVersion">
            <xsl:text>4</xsl:text>
         </xsl:when>

         <xsl:when test="b:StyleNameLocalized">
            <xsl:choose>
               <xsl:when test="b:StyleNameLocalized/b:Lcid='1033'">
                  <xsl:text>David Teste</xsl:text>
               </xsl:when>
               <xsl:when test="b:StyleNameLocalized/b:Lcid='2070'">
                  <xsl:text>David Teste</xsl:text>
               </xsl:when>
            </xsl:choose>
         </xsl:when>
      </xsl:choose>

      <xsl:variable name="book_Title">
         <xsl:value-of select="(b:Title)" />
      </xsl:variable>

   </xsl:template>


   <xsl:template match="b:GetImportantFields[b:SourceType = 'Book']">
      <b:ImportantFields>
         <b:ImportantField>
            <xsl:text>b:Author/b:Author/b:NameList</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Title</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:ShortTitle</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Publisher</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Edition</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Year</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Pages</xsl:text>
         </b:ImportantField>
      </b:ImportantFields>
   </xsl:template>

   <xsl:template match="b:GetImportantFields[b:SourceType = 'BookSection']">
      <b:ImportantFields>
         <b:ImportantField>
            <xsl:text>b:Author/b:Author/b:NameList</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Title</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:ShortTitle</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:BookTitle</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Publisher</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Edition</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Year</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Pages</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Comments</xsl:text>
         </b:ImportantField>
      </b:ImportantFields>
   </xsl:template>

   <xsl:template match="b:GetImportantFields[b:SourceType = 'ArticleInAPeriodical']">
      <b:ImportantFields>
         <b:ImportantField>
            <xsl:text>b:Author/b:Author/b:NameList</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Title</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:ShortTitle</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:PeriodicalTitle</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Edition</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Month</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Year</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Pages</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Comments</xsl:text>
         </b:ImportantField>
      </b:ImportantFields>
   </xsl:template>



   <!--Label the paragraph as an Office Bibliography paragraph-->


   <xsl:template match="b:Source[b:SourceType = 'Book']">
      <xsl:if test = "string-length(b:Tag) >= 9">
         <p>
            <span style='text-transform: uppercase;'>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Middle"/>
            </span>
            <xsl:text> </xsl:text>
            <span style='text-transform: uppercase;'>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Last"/>
            </span>
            <xsl:text>, </xsl:text>
            <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:First"/>
            <xsl:text>, </xsl:text>
            <i>
               <xsl:value-of select="b:Title"/>
               <xsl:text>, </xsl:text>
            </i>
            <xsl:value-of select="b:Publisher"/>
            <xsl:text>, </xsl:text>
            <xsl:value-of select="b:Edition"/>
            <xsl:text>.ª ed., </xsl:text>
            <xsl:value-of select="b:Year"/>
         </p>
      </xsl:if>

   </xsl:template>


   <xsl:template match="b:Source[b:SourceType = 'BookSection']">
      <!--Label the paragraph as an Office Bibliography paragraph-->
      <xsl:if test = "string-length(b:Tag) >= 9">
         <p>
            <span style='text-transform: uppercase;'>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Middle"/>
            </span>
            <xsl:text> </xsl:text>
            <span style='text-transform: uppercase;'>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Last"/>
            </span>
            <xsl:text>, </xsl:text>
            <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:First"/>
            <xsl:text>, </xsl:text>
            <i>
               <xsl:value-of select="b:Title"/>
               <xsl:text>, </xsl:text>
            </i>
            <xsl:value-of select="b:Publisher"/>
            <xsl:text>, </xsl:text>
            <xsl:value-of select="b:Edition"/>
            <xsl:text>.ª ed., </xsl:text>
            <xsl:value-of select="b:Year"/>
            <xsl:text>, pp. </xsl:text>
            <xsl:value-of select="b:Comments"/>
         </p>
      </xsl:if>
   </xsl:template>

   <xsl:template match="b:Source[b:SourceType = 'ArticleInAPeriodical']">
      <xsl:if test = "string-length(b:Tag) >= 9">
         <p>
            <span style='text-transform: uppercase;'>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Middle"/>
            </span>
            <xsl:text> </xsl:text>
            <span style='text-transform: uppercase;'>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Last"/>
            </span>
            <xsl:text>, </xsl:text>
            <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:First"/>
            <xsl:text>, "</xsl:text>
            <xsl:value-of select="b:Title"/>
            <xsl:text>", </xsl:text>
            <i>
               <span style='text-transform: uppercase;'>
                  <xsl:value-of select="b:PeriodicalTitle"/>
               </span>
            </i>
            <xsl:text>, n.º </xsl:text>
            <xsl:value-of select="b:Edition"/>
            <xsl:text>, </xsl:text>
            <xsl:value-of select="b:Month"/>
            <xsl:text>, </xsl:text>
            <xsl:value-of select="b:Year"/>
            <xsl:text>, pp. </xsl:text>
            <xsl:value-of select="b:Comments"/>
         </p>
      </xsl:if>
   </xsl:template>

   <!--FINISH Label the paragraph as an Office Bibliography paragraph-->


   <xsl:template match="b:Bibliography">

      <html xmlns="https://www.w3.org/TR/REC-html40">

         <body>

            <xsl:apply-templates select ="b:Source[b:SourceType = 'Book' or b:SourceType = 'BookSection' or b:SourceType = 'ArticleInAPeriodical']">

            </xsl:apply-templates>

         </body>

      </html>
   </xsl:template>

   <!--Defines the output of the Citation-->
   <xsl:template match="b:Citation/b:Source[b:SourceType = 'Book']">
      <html xmlns="https://www.w3.org/TR/REC-html40">
         <body>
            <xsl:if test = "9 > string-length(b:Tag)">
               <!-- Defines the output format as (Author, Year)-->
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:First"/>
               <xsl:text> </xsl:text>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Middle"/>
               <xsl:text> </xsl:text>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Last"/>
               <xsl:text>, </xsl:text>
               <i>
                  <xsl:value-of select="b:ShortTitle"/>
                  <xsl:text>..., </xsl:text>
                  <xsl:text>ob. cit.</xsl:text>
               </i>
               <xsl:text>, pp. </xsl:text>
               <xsl:value-of select="b:Pages"/>
            </xsl:if>
            <xsl:if test = "string-length(b:Tag) >= 9">
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:First"/>
               <xsl:text> </xsl:text>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Middle"/>
               <xsl:text> </xsl:text>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Last"/>
               <xsl:text>, </xsl:text>
               <i>
                  <xsl:value-of select="b:Title"/>
                  <xsl:text>, </xsl:text>
               </i>
               <xsl:value-of select="b:Publisher"/>
               <xsl:text>, </xsl:text>
               <xsl:value-of select="b:Edition"/>
               <xsl:text>.ª ed., </xsl:text>
               <xsl:value-of select="b:Year"/>
               <xsl:text>, pp. </xsl:text>
               <xsl:value-of select="b:Pages"/>
            </xsl:if>

         </body>
      </html>
   </xsl:template>

   <!--Defines the output of the Citation-->

   <xsl:template match="b:Citation/b:Source[b:SourceType = 'BookSection']">
      <html xmlns="https://www.w3.org/TR/REC-html40">
         <body>
            <xsl:if test = "9 > string-length(b:Tag)">
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:First"/>
               <xsl:text> </xsl:text>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Middle"/>
               <xsl:text> </xsl:text>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Last"/>
               <xsl:text>, "</xsl:text>
               <xsl:value-of select="b:ShortTitle"/>
               <xsl:text>...", </xsl:text>
               <i>
                  <xsl:text>ob. cit.</xsl:text>
               </i>
               <xsl:text>, pp. </xsl:text>
               <xsl:value-of select="b:Pages"/>
            </xsl:if>
            <xsl:if test = "string-length(b:Tag) >= 9">
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:First"/>
               <xsl:text> </xsl:text>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Middle"/>
               <xsl:text> </xsl:text>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Last"/>
               <xsl:text>, "</xsl:text>
               <xsl:value-of select="b:Title"/>
               <xsl:text>", </xsl:text>
               <i>
                  <xsl:value-of select="b:BookTitle"/>
                  <xsl:text>, </xsl:text>
               </i>
               <xsl:value-of select="b:Publisher"/>
               <xsl:text>, </xsl:text>
               <xsl:value-of select="b:Edition"/>
               <xsl:text>.ª ed., </xsl:text>
               <xsl:value-of select="b:Year"/>
               <xsl:text>, pp. </xsl:text>
               <xsl:value-of select="b:Pages"/>
            </xsl:if>
         </body>
      </html>
   </xsl:template>


   <!--Defines the output of the Citation-->
   <xsl:template match="b:Citation/b:Source[b:SourceType = 'ArticleInAPeriodical']">
      <html xmlns="https://www.w3.org/TR/REC-html40">
         <body>
            <!-- Defines the output format as (Author, Year)-->
            <xsl:if test = "9 > string-length(b:Tag)">
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:First"/>
               <xsl:text> </xsl:text>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Middle"/>
               <xsl:text> </xsl:text>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Last"/>
               <xsl:text>, "</xsl:text>
               <xsl:value-of select="b:ShortTitle"/>
               <xsl:text>...", </xsl:text>
               <i>
                  <xsl:text>ob. cit.</xsl:text>
               </i>
               <xsl:text>, pp. </xsl:text>
               <xsl:value-of select="b:Pages"/>
            </xsl:if>
            <xsl:if test = "string-length(b:Tag) >= 9">
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:First"/>
               <xsl:text> </xsl:text>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Middle"/>
               <xsl:text> </xsl:text>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Last"/>
               <xsl:text>, "</xsl:text>
               <xsl:value-of select="b:Title"/>
               <xsl:text>", </xsl:text>
               <i>
                  <xsl:value-of select="b:PeriodicalTitle"/>
               </i>
               <xsl:text>, n.º </xsl:text>
               <xsl:value-of select="b:Edition"/>
               <xsl:text>, </xsl:text>
               <xsl:value-of select="b:Month"/>
               <xsl:text>, </xsl:text>
               <xsl:value-of select="b:Year"/>
               <xsl:text>, pp. </xsl:text>
               <xsl:value-of select="b:Pages"/>
            </xsl:if>
         </body>
      </html>
   </xsl:template>



   <xsl:template match="text()" />
</xsl:stylesheet>

这是代码。

有没有人经历过类似的事情?有人可以帮忙吗?谢谢你。

标签: xmlxsltms-wordstylesheetbibliography

解决方案


对于 Mac 上 Word 的当前 (2016/2019) 版本(我的是 v. 16.29 (19090802)),例如在

         <xsl:when test="b:Version">
            <xsl:text>2019.9.29</xsl:text>
         </xsl:when>

您将需要插入这样的代码:

         <xsl:when test="b:OfficeStyleKey">
            <xsl:text>David Teste</xsl:text>
         </xsl:when>

自 2010 版 Office on Windows 以来,似乎不需要进行该测试。我很惊讶在 Mac 上仍然需要它,因为其他主要的 Mac 特定参考书目功能(不同的脚注引用)似乎已被删除。您可能拥有比我更新的 Mac Word 版本,您不需要该代码,但您也有可能仍然需要它的 2011 版本的副本。

注意在此版本的 Word 中,这些参考书目样式 .xsl 文件的正确文件夹似乎是

~/Library/Group Containers/UBF8T346G9.Office/User Content/Citations

("~" 表示顶级用户文件夹,例如 /Macintosh HD/Users/myusername)


推荐阅读