下午好。
我正在为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>
这是代码。
有人曾经历过类似的经历吗?有人可以帮忙吗? 谢谢。
答案 0 :(得分:0)
对于Mac上的Word的当前(2016/2019)版本(mine 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>
自Windows 2010的Office版本开始以来,似乎不需要进行该测试。令我惊讶的是,在Mac上仍然需要它,因为其他主要的Mac特定书目功能(不同的脚注引用)似乎已被删除。在不需要该代码的情况下,可能有比我较新的Mac Word版本,但在仍有可能需要的地方,也有2011版本的副本。
在此版本的Word中,这些书目样式.xsl文件的正确文件夹似乎是
〜/ Library / Group Containers / UBF8T346G9.Office / User Content / Citations
(“〜”表示顶级用户文件夹,例如/ Macintosh HD / Users / myusername)