Search code examples
xmlxsltms-wordstylesheetbibliography

Bibliography styles don't show on some versions of word


Good afternoon.

I'm doing some custom bibliography styles for Word. The problem is the codes do appear and function on my 2016 Word on Windows and in another version of office 365 on Mac. But they don't show up on the other two Macbooks I've tried them on, both with office 365 as well. (At first i thought it was because of file permissions on Mac, but this didn't solve the problem 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>

This are the codes.

Does anyone had experienced something similar before? Can someone help? Thank you.


Solution

  • For the current (2016/2019) version of Word on Mac (mine is v. 16.29 (19090802)), e.g. after

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

    you will need to insert code like this:

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

    That test does not appear to have been required since around the 2010 version of Office on Windows. I am surprised it is still needed on Mac as the other main Mac-specific Bibliography feature (different footnote citations) appears to have been removed. It is possible that you have a more recent version of Mac Word than me where you do not need that code, but you also have copies of the 2011 version where it may still be needed.

    NB in this version of Word the correct folder for these Bibliography Style .xsl files appears to be

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

    ("~" means the top-level user folder, e.g. /Macintosh HD/Users/myusername)