Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml MS Word书目/引用XSL模板不工作_Xml_Xslt_Ms Word - Fatal编程技术网

Xml MS Word书目/引用XSL模板不工作

Xml MS Word书目/引用XSL模板不工作,xml,xslt,ms-word,Xml,Xslt,Ms Word,我想创建一个自定义单词参考书目/引用模板,并从a中选取一个作为基础。无论如何,它不起作用(Windows Office 2013),即Word在可用模板列表中不显示此模板。谁能帮帮我吗 我的代码: <?xml version="1.0" ?> <!--List of the external resources that we are referencing--> <xsl:stylesheet version="1.0" xmlns:xsl="http://www

我想创建一个自定义单词参考书目/引用模板,并从a中选取一个作为基础。无论如何,它不起作用(Windows Office 2013),即Word在可用模板列表中不显示此模板。谁能帮帮我吗

我的代码:

<?xml version="1.0" ?>
<!--List of the external resources that we are referencing-->
<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">
   <!--When the bibliography or citation is in your document, it's just HTML-->
   <xsl:output method="html" encoding="us-ascii"/>
   <!--Match the root element, and dispatch to its children-->
   <xsl:template match="/">
      <xsl:apply-templates select="*" />
   </xsl:template>
   <!--Set an optional version number for this style-->
   <xsl:template match="b:version">
      <xsl:text>2006.5.07</xsl:text>
   </xsl:template>
   <!--Defines the name of the style in the References dropdown-->
   <xsl:template match="b:StyleName">    
      <xsl:text>MyTemplate</xsl:text>
   </xsl:template>
   <!--Specifies which fields should appear in the Create Source dialog when in a collapsed state (The Show All Bibliography Fieldscheckbox is cleared)-->
   <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:Year</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:City</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Publisher</xsl:text>
         </b:ImportantField>
      </b:ImportantFields>
   </xsl:template>
   <!--Defines the output format for a simple Book (in the Bibliography) with important fields defined-->
   <xsl:template match="b:Source[b:SourceType = 'Book']">
      <!--Count the number of Corporate Authors (can only be 0 or 1-->
      <xsl:variable name="cCorporateAuthors">
         <xsl:value-of select="count(b:Author/b:Author/b:Corporate)" />
      </xsl:variable>
      <!--Label the paragraph as an Office Bibliography paragraph-->
      <p>
         <xsl:choose>
            <xsl:when test ="$cCorporateAuthors!=0">
               <!--When the corporate author exists display the corporate author-->
               <xsl:value-of select="b:Author/b:Author/b:Corporate"/>
               <xsl:text>. (</xsl:text>
            </xsl:when>
            <xsl:otherwise>
               <!--When the corporate author does not exist, display the normal author-->
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Last"/>
               <xsl:text>, </xsl:text>
               <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:First"/>
               <xsl:text>. (</xsl:text>
            </xsl:otherwise>
         </xsl:choose>
         <xsl:value-of select="b:Year"/>
         <xsl:text>). </xsl:text>
         <i>
            <xsl:value-of select="b:Title"/>
            <xsl:text>. </xsl:text>
         </i>
         <xsl:value-of select="b:City"/>
         <xsl:text>: </xsl:text>
         <xsl:value-of select="b:Publisher"/>
         <xsl:text>.</xsl:text>
      </p>
   </xsl:template>
   <!--Defines the output of the entire Bibliography-->
   <xsl:template match="b:Bibliography">
      <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
         <head>                    
            <style>
               p.MsoBibliography, li.MsoBibliography, div.MsoBibliography
            </style>
         </head>
         <body>
            <xsl:apply-templates select ="*">
            </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:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
         <head>
         </head>
         <body>
            <xsl:variable name="cCorporateAuthors">
               <xsl:value-of select="count(b:Author/b:Author/b:Corporate)" />
            </xsl:variable>
            <!--Defines the output format as (Author, Year-->
            <xsl:text>(</xsl:text>
            <xsl:choose>
            <!--When the corporate author exists display the corporate author-->
               <xsl:when test ="$cCorporateAuthors!=0">
                  <xsl:value-of select="b:Author/b:Author/b:Corporate"/>
               </xsl:when>
               <!--When the corporate author does not exist, display the normal author-->
               <xsl:otherwise>
                  <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Last"/>
               </xsl:otherwise>
            </xsl:choose>
            <xsl:text>, </xsl:text>
            <xsl:value-of select="b:Year"/>
            <xsl:text>)</xsl:text>
         </body>
      </html>
   </xsl:template>
   <xsl:template match="text()" />
</xsl:stylesheet>

2006.5.07
我的模板
b:作者/b:作者/b:姓名列表
b:头衔
b:一年
b:城市
b:出版商

. (
, 
. (
). 
. 
: 
.

p、 MsoBibliography,li.msobiliography,div.msobiliography ( , )
我认为您需要的结构在2013年发生了变化,引用的文章不正确。您还需要对StyleNameLocal进行测试。这里的以下函数可能需要一些测试才能正常工作。请查找标记为“New”的位:

其中“username”是我的Windows用户名,但您的用户名可能位于不同的位置

<?xml version="1.0" encoding="utf-8"?>
<!--List of the external resources that we are referencing-->
<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">
  <!--When the bibliography or citation is in your document, it's just HTML-->
  <xsl:output method="html" encoding="us-ascii" />
  <!--Match the root element-->
  <xsl:template match="/">
    <!-- New: structure change here...-->
    <xsl:apply-templates select="*" />
    <xsl:choose>
      <!--Set an optional version number for this style-->
      <xsl:when test="b:version">
        <xsl:text>2006.5.07</xsl:text>
      </xsl:when>
      <!--Defines the name of the style in the References dropdown-->
      <xsl:when test="b:StyleName">
        <xsl:text>MyTemplate</xsl:text>
      </xsl:when>
      <!--New: need a StyleNameLocalized-->
      <xsl:when test="b:StyleNameLocalized">
        <xsl:choose>
          <!--You will need a when test for each Lcid you want to support-->
          <xsl:when test="b:StyleNameLocalized/b:Lcid='1033'">
            <xsl:text>MyTemplate</xsl:text>
          </xsl:when>
        </xsl:choose>
      </xsl:when>
    </xsl:choose>
  </xsl:template>
  <!--Specifies which fields should appear in the Create Source dialog when in a collapsed state (The Show All Bibliography Fieldscheckbox is cleared)-->
  <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:Year</xsl:text>
      </b:ImportantField>
      <b:ImportantField>
        <xsl:text>b:City</xsl:text>
      </b:ImportantField>
      <b:ImportantField>
        <xsl:text>b:Publisher</xsl:text>
      </b:ImportantField>
    </b:ImportantFields>
  </xsl:template>
  <!--Defines the output format for a simple Book (in the Bibliography) with important fields defined-->
  <xsl:template match="b:Source[b:SourceType = 'Book']">
    <!--Count the number of Corporate Authors (can only be 0 or 1-->
    <xsl:variable name="cCorporateAuthors">
      <xsl:value-of select="count(b:Author/b:Author/b:Corporate)" />
    </xsl:variable>
    <!--Label the paragraph as an Office Bibliography paragraph-->
    <p>
      <xsl:choose>
        <xsl:when test="$cCorporateAuthors!=0">
          <!--When the corporate author exists display the corporate author-->
          <xsl:value-of select="b:Author/b:Author/b:Corporate" />
          <xsl:text>. (</xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <!--When the corporate author does not exist, display the normal author-->
          <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Last" />
          <xsl:text>, </xsl:text>
          <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:First" />
          <xsl:text>. (</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:value-of select="b:Year" />
      <xsl:text>). </xsl:text>
      <i>
        <xsl:value-of select="b:Title" />
        <xsl:text>. </xsl:text>
      </i>
      <xsl:value-of select="b:City" />
      <xsl:text>: </xsl:text>
      <xsl:value-of select="b:Publisher" />
      <xsl:text>.</xsl:text>
    </p>
  </xsl:template>
  <!--Defines the output of the entire Bibliography-->
  <xsl:template match="b:Bibliography">
    <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
      <head>
        <style>

          p.MsoBibliography, li.MsoBibliography, div.MsoBibliography

        </style>
      </head>
      <body>
        <xsl:apply-templates select="*"></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:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
      <head></head>
      <body>
        <xsl:variable name="cCorporateAuthors">
          <xsl:value-of select="count(b:Author/b:Author/b:Corporate)" />
        </xsl:variable>
        <!--Defines the output format as (Author, Year-->
        <xsl:text>(</xsl:text>
        <xsl:choose>
          <!--When the corporate author exists display the corporate author-->
          <xsl:when test="$cCorporateAuthors!=0">
            <xsl:value-of select="b:Author/b:Author/b:Corporate" />
          </xsl:when>
          <!--When the corporate author does not exist, display the normal author-->
          <xsl:otherwise>
            <xsl:value-of select="b:Author/b:Author/b:NameList/b:Person/b:Last" />
          </xsl:otherwise>
        </xsl:choose>
        <xsl:text>, </xsl:text>
        <xsl:value-of select="b:Year" />
        <xsl:text>)</xsl:text>
      </body>
    </html>
  </xsl:template>
  <xsl:template match="text()" />
</xsl:stylesheet>
c:\Users\username\AppData\Roaming\Microsoft\Bibliography\Style\mybib.xsl