0

Dears, currently I am building up a custom citation sytle in WORD and I want to achive the following for the output of the biblipgraphy:

  • Section of books should be displayed by their respective author (BookSection)
  • The book author should be displayed as extra entry in the bibliography
  • Output of both should be sorted into one list!

I have already got it work that two section of entries will show up in the bibliography by doing it like this:

<xsl:template match="b:Bibliography">
        <html xmlns="https://www.w3.org/TR/REC-html40">
           <body>
              <xsl:variable name="Literatur">
              <xsl:apply-templates select ="b:Source[b:SourceType = 'BookSection'] | b:Source[b:SourceType = 'Book']  | b:Source[b:SourceType = 'ArticleInAPeriodical']" />
              <xsl:apply-templates select ="b:Source[b:SourceType = 'BookSection']" mode="ExtraBookAuthorEntry" />
              </xsl:variable>
              <xsl:copy-of select="$Literatur"/>

                  <span style="font-size: 12pt; font-family: 'TimesNewRoman'; font-weight: bold;">
                  <xsl:text>Internetquellen</xsl:text>
                  </span>
                  <xsl:apply-templates select = "b:Source[b:SourceType = 'InternetSite'] | b:Source[b:SourceType = 'DocumentFromInternetSite']">
                     <xsl:sort select="b:Tag" order="descending"/>
                  </xsl:apply-templates>
               </body>

            </html>
         </xsl:template>

Now the entries of the first apply-templates will be visible and below this there will be the extra section with the next apply-tempates.

Nevertheless, I just want to do a sort on both apply-templates inside the variable "Literatur"

How can I perform that sort? Can you help me out?

Thanks Simon

---- EDIT ----

I am using this code:

<?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>2020.10.23</xsl:text>
         </xsl:when>

         <xsl:when test="b:OfficeStyleKey">
            <xsl:text>FOM Literatur</xsl:text>
         </xsl:when>

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

         <xsl:when test="b:StyleNameLocalized">
            <xsl:choose>
               <xsl:when test="b:StyleNameLocalized/b:Lcid='1033'">
                  <xsl:text>FOM Literatur</xsl:text>
               </xsl:when>
               <xsl:when test="b:StyleNameLocalized/b:Lcid='2070'">
                  <xsl:text>FOM Literatur</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:City</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:ImportantFields>
   </xsl:template>

   <xsl:template match="b:GetImportantFields[b:SourceType = 'BookSection']">
      <b:ImportantFields>
         <b:ImportantField>
            <!--AUTOR (Kurztitel, Jahr): Titel, in: Hrsg (Hrsg.), Buchtitel, Jahr, S. 277 - 299 -->
            <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:Author/b:BookAuthor/b:NameList</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Publisher</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:City</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>



   <!-- Artikel in einer Zeitschrift -->
   <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:Volume</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Issue</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 = 'InternetSite']">
      <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:InternetSiteTitle</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Year</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Month</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:Day</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:YearAccessed</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:MonthAccessed</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:DayAccessed</xsl:text>
         </b:ImportantField>
         <b:ImportantField>
            <xsl:text>b:URL</xsl:text>
         </b:ImportantField>
      </b:ImportantFields>
   </xsl:template>



   <!--### Abschnitt 2: Hier wird festgelegt, wie die einzelnen Quellen im Literaturverzeichnis
    ausgegeben werden sollen. Hier sind noch nicht alle Arten von Quellen eingetragen.
    Ggf. müssen die entsprechenden Quellenarten noch hinzugefügt werden.###-->

   <xsl:template match = "b:Source[b:SourceType = 'Book'] | b:Source[b:SourceType = 'Report'] | b:Source[b:SourceType = 'ElectronicSource']">
      <p>
         <i>            <!--Autorenliste-->
            <xsl:apply-templates select="b:Author/b:Author" mode="AuthorNamelistFull" />
         </i>
         <xsl:text> (</xsl:text>
         <xsl:value-of select = "b:ShortTitle"/>
         <xsl:text>, </xsl:text>
         <xsl:value-of select = "b:Year"/>
         <xsl:text>): </xsl:text>
         <xsl:value-of select = "b:Title"/>
         <xsl:text>, </xsl:text>
         <xsl:if test="b:Edition != ''">
            <xsl:value-of select = "b:Edition"/>
            <xsl:text>. Aufl., </xsl:text>
         </xsl:if>
         <xsl:value-of select = "b:City"/>
         <xsl:text>: </xsl:text>
         <xsl:value-of select="b:Publisher"/>
         <xsl:text>, </xsl:text>
         <xsl:value-of select = "b:Year"/>
      </p>
      <!-- <p style="font-family: Arial, Helvetica, sans-serif; font-size: 11pt;">
      <span style="font-weight: bold; ">
        <xsl:text>[</xsl:text>
        <xsl:value-of select = "b:Tag"/>
        <xsl:text>] </xsl:text>
      </span> -->
      <!--Autorenliste-->
      <!-- <xsl:apply-templates select="b:Author/b:Author" mode="AuthorNamelistFull" />
      <xsl:text>: </xsl:text> -->
      <!--Titel-->
      <!-- <xsl:value-of select = "b:Title"/> -->
      <!--Datum-->
      <!-- <xsl:text> (</xsl:text>
      <xsl:value-of select = "b:City"/>
      <xsl:text>, </xsl:text>
      <xsl:value-of select = "b:Year"/>
      <xsl:text>).</xsl:text>
    </p> -->
   </xsl:template>

   <xsl:template match = "b:Source[b:SourceType = 'BookSection']">
      <p>
         <!--AUTOR (Kurztitel, Jahr): Titel, in: Hrsg (Hrsg.), Buchtitel, Jahr, S. 277 - 299 -->
         <i>            <!--Autorenliste-->
            <xsl:apply-templates select="b:Author/b:Author" mode="AuthorNamelistFull" />
         </i>
         <xsl:text> (</xsl:text>
         <xsl:value-of select = "b:ShortTitle"/>
         <xsl:text>, </xsl:text>
         <xsl:value-of select = "b:Year"/>
         <xsl:text>): </xsl:text>
         <xsl:value-of select = "b:Title"/>
         <xsl:text>, in: </xsl:text>
         <i>
            <xsl:apply-templates select = "b:Author/b:BookAuthor" mode="BookAuthorNamelistFull" />
         </i>
         <xsl:text> (Hrsg.), </xsl:text>
         <xsl:value-of select = "b:BookTitle"/>
         <xsl:text>, </xsl:text>
         <xsl:value-of select = "b:Year"/>
         <xsl:text>, S. </xsl:text>
         <xsl:value-of select = "b:Pages"/>
      </p>
   </xsl:template>

   <!--Extra Eintrag fuer HRSG. vom Sammelband-->
   <xsl:template match = "b:Source[b:SourceType = 'BookSection']" mode="ExtraBookAuthorEntry">
      <p>
         <i>
            <xsl:apply-templates select="b:Author/b:BookAuthor" mode="BookAuthorNamelistFull" />
         </i>
         <xsl:text> (Hrsg.) (</xsl:text>
         <!--TODO fuer ShortTitel vom Sammelband!!-->
         <xsl:value-of select = "b:ShortTitle"/>
         <xsl:text>, </xsl:text>
         <xsl:value-of select = "b:Year"/>
         <xsl:text>): </xsl:text>
         <xsl:value-of select = "b:Title"/>
         <xsl:text>, </xsl:text>
         <xsl:if test="b:Edition != ''">
            <xsl:value-of select = "b:Edition"/>
            <xsl:text>. Aufl., </xsl:text>
         </xsl:if>
         <xsl:value-of select = "b:City"/>
         <xsl:text>: </xsl:text>
         <xsl:value-of select="b:Publisher"/>
         <xsl:text>, </xsl:text>
         <xsl:value-of select = "b:Year"/>
      </p>
   </xsl:template>

   <xsl:template match="b:Source[b:SourceType = 'ArticleInAPeriodical']">
      <p>
         <!--AUTOR (Kurztitel, Jahr): Titel, in: Hrsg (Hrsg.), Buchtitel, Jahr, S. 277 - 299 -->
         <i>            <!--Autorenliste-->
            <xsl:apply-templates select="b:Author/b:Author" mode="AuthorNamelistFull" />
         </i>
         <xsl:text> (</xsl:text>
         <xsl:value-of select = "b:ShortTitle"/>
         <xsl:text>, </xsl:text>
         <xsl:value-of select = "b:Year"/>
         <xsl:text>): </xsl:text>
         <xsl:value-of select = "b:Title"/>
         <xsl:text>, in: </xsl:text>
         <xsl:value-of select = "b:PeriodicalTitle" />
         <xsl:text>, </xsl:text>
         <xsl:if test="b:Volume != ''">
            <xsl:value-of select = "b:Volume"/>
            <xsl:text></xsl:text>
         </xsl:if>
         <xsl:text>(</xsl:text>
         <xsl:value-of select = "b:Year"/>
         <xsl:text>), </xsl:text>
         <xsl:if test="b:Issue != ''">
            <xsl:text>Nr. </xsl:text>
            <xsl:value-of select = "b:Issue"/>
         </xsl:if>
         <xsl:text>, S. </xsl:text>
         <xsl:value-of select = "b:Pages"/>
      </p>
   </xsl:template>

   <xsl:template match = "b:Source[b:SourceType = 'InternetSite'] | b:Source[b:SourceType = 'DocumentFromInternetSite']">
      <p>
         <i>            <!--Autorenliste-->
            <xsl:apply-templates select="b:Author/b:Author" mode="AuthorNamelistFull" />
         </i>
         <xsl:text> (</xsl:text>
         <xsl:value-of select = "b:ShortTitle"/>
         <xsl:text>, </xsl:text>
         <xsl:value-of select = "b:Year"/>
         <xsl:text>): </xsl:text>
         <xsl:value-of select = "b:Title"/>
         <xsl:text>, &lt;</xsl:text>
         <xsl:value-of select = "b:URL"/>
         <xsl:text>&gt; </xsl:text>
         <xsl:text>(</xsl:text>
         <xsl:value-of select = "b:Day"/>
         <xsl:text>.</xsl:text>
         <xsl:value-of select = "b:Month"/>
         <xsl:text>.</xsl:text>
         <xsl:value-of select = "b:Year"/>
         <xsl:text>) </xsl:text>
         <xsl:text>[Zugriff: </xsl:text>
         <xsl:value-of select = "b:DayAccessed"/>
         <xsl:text>.</xsl:text>
         <xsl:value-of select = "b:MonthAccessed"/>
         <xsl:text>.</xsl:text>
         <xsl:value-of select = "b:YearAccessed"/>
         <xsl:text>]</xsl:text>

         <!--  <xsl:if test="b:Edition != ''">
              <xsl:value-of select = "b:Edition"/>
              <xsl:text>. Aufl., </xsl:text>
            </xsl:if> -->
      </p>

   </xsl:template>
   <!-- 
   <xsl:template match = "b:Source[b:SourceType = 'InternetSite'] | b:Source[b:SourceType = 'DocumentFromInternetSite']">
      <p style="font-family: Arial, Helvetica, sans-serif; font-size: 11pt;">
         
         <xsl:apply-templates select="b:Author/b:Author" mode="AuthorNamelistFull" />
         
         <xsl:text>: </xsl:text>
         <xsl:value-of select = "b:Title"/>
         
         <xsl:text> (</xsl:text>
         <xsl:value-of select = "b:Year"/>
         <xsl:text>) </xsl:text>
         <br />
         
         <span style="font-size: 10pt; color: #0000FF;">
            <xsl:text>[</xsl:text>
            <xsl:value-of select = "b:URL"/>
            <xsl:text>]</xsl:text>
         </span>
         
         <span style="font-size: 10pt;">
            <xsl:text> (Zugriff am: </xsl:text>
            <xsl:value-of select = "b:DayAccessed"/>
            <xsl:text>. </xsl:text>
            <xsl:value-of select = "b:MonthAccessed"/>
            <xsl:text>.</xsl:text>
            <xsl:value-of select = "b:YearAccessed"/>
            <xsl:text>).</xsl:text>
         </span>
      </p>
   </xsl:template> -->

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

   <!--### Abschnitt 3: Ausgabe im Literaturverzecihnis -->

   <xsl:template match="b:Bibliography">
      <html xmlns="https://www.w3.org/TR/REC-html40">
         <body>


            <xsl:variable name="Literatur">
               <xsl:apply-templates select ="b:Source[b:SourceType = 'BookSection'] | b:Source[b:SourceType = 'Book']  | b:Source[b:SourceType = 'ArticleInAPeriodical']" />
               <xsl:apply-templates select ="b:Source[b:SourceType = 'BookSection']" mode="ExtraBookAuthorEntry" />
            </xsl:variable>

            <xsl:copy-of select="$Literatur"/>

            <span style="font-size: 12pt; font-family: 'TimesNewRoman'; font-weight: bold;">
               <xsl:text>Internetquellen</xsl:text>
            </span>
            <xsl:apply-templates select = "b:Source[b:SourceType = 'InternetSite'] | b:Source[b:SourceType = 'DocumentFromInternetSite']">
               <xsl:sort select="b:Tag" order="descending"/>
            </xsl:apply-templates>
         </body>

      </html>
   </xsl:template>


   <!--<xsl:template match="b:Bibliography">
      <html xmlns="http://www.w3.org/TR/REC-html40">
         <body>
            
            <xsl:apply-templates select ="b:Source[b:SourceType = 'Book']"> 

         </xsl:apply-templates> 
            <xsl:apply-templates select = "b:Source[b:SourceType = 'Book'] | b:Source[b:SourceType = 'BookSection']">
               <xsl:sort select="b:Tag" order="ascending"/>
            </xsl:apply-templates>
            

            <xsl:text>Onlinequellen</xsl:text>
            <xsl:apply-templates select = "b:Source[b:SourceType = 'InternetSite'] | b:Source[b:SourceType = 'DocumentFromInternetSite']">
               <xsl:sort select="b:Tag" order="ascending"/>
            </xsl:apply-templates>
            <br/>

         </body>

      </html>
   </xsl:template>-->




   <!--### Abschnitt 4: Hier wird festgelegt, wie einzelne Zitate ausgegeben werden.###-->

   <xsl:template match = "b:Citation/b:Source">
      <html xmlns = "http://www.w3.org/TR/REC-html40">
         <body>
            <!--Zu erst kommt das Tag, Bsp: [VanV]
        <span style="font-weight:bold">
          <xsl:text>[</xsl:text>
          <xsl:value-of select = "b:Tag"/>
          <xsl:text>] </xsl:text>
        </span>-->
            <!-- Autoren-->
            <!--Anmerkung: Wie die Liste genau aufgebaut ist, steht in Abschnitt 5-->
            <i>
               <xsl:apply-templates select="b:Author/b:Author" mode="AuthorNamelistShort" />
            </i>
            <xsl:apply-templates select="b:Author/b:Interviewee" mode="AuthorNamelistVeryShort" />
            <xsl:text>, </xsl:text>
            <!--Schlagwort-->
            <xsl:value-of select="b:ShortTitle"/>
            <xsl:text>, </xsl:text>
            <!--Datum-->
            <xsl:value-of select = "b:Year"/>
            <!--und noch die Seiten, wenn sie angegeben wurden-->
            <xsl:if test="../b:Pages != ''">
               <xsl:text>, S. </xsl:text>
               <xsl:value-of select = "../b:Pages"/>
            </xsl:if>
         </body>
      </html>
   </xsl:template>

   <!--### Abschnitt 5: Hier wird festgelegt, wie die verschieden langen Autoren- bzw- Interviewpartnerlisten ausgegeben werden.###-->

   <!-- Vollständige Interviewpartnerliste -->
   <xsl:template match="b:Interviewee" mode="IntervieweeNamelistFull">
      <xsl:for-each select="b:NameList/b:Person">
         <xsl:apply-templates select="."/>
         <xsl:if test="position() != last()">
            <xsl:text>, </xsl:text>
         </xsl:if>
      </xsl:for-each>
      <xsl:value-of select="b:Corporate"/>
   </xsl:template>

   <!-- Vollständige Autorenliste -->
   <xsl:template match="b:Author" mode="AuthorNamelistFull">
      <!--<xsl:for-each select="b:NameList/b:Person">-->
      <xsl:for-each select="b:NameList/b:Person">
         <xsl:apply-templates select="."/>
         <xsl:if test="position() != last()">
            <xsl:text>, </xsl:text>
         </xsl:if>
      </xsl:for-each>
      <xsl:value-of select="b:Corporate"/>
   </xsl:template>


   <!-- Vollständige Hrsg. Liste -->
   <xsl:template match="b:BookAuthor" mode="BookAuthorNamelistFull">
      <!--<xsl:for-each select="b:NameList/b:Person">-->
      <xsl:for-each select="b:NameList/b:Person">
         <xsl:apply-templates select="."/>
         <xsl:if test="position() != last()">
            <xsl:text>, </xsl:text>
         </xsl:if>
      </xsl:for-each>
      <xsl:value-of select="b:Corporate"/>
   </xsl:template>

   <xsl:template match="b:Author" mode="AuthorNamelistShort">
      <xsl:for-each select="b:NameList/b:Person">
         <xsl:choose>
            <xsl:when test="position() = 2">
               <xsl:choose>
                  <xsl:when test="last() > 2">
                     <xsl:text> et al.</xsl:text>
                  </xsl:when>
                  <xsl:otherwise>
                     <xsl:text>, </xsl:text>
                     <xsl:apply-templates select="." mode="FirstShort" />
                  </xsl:otherwise>
               </xsl:choose>
            </xsl:when>
            <xsl:when test="position() > 2">
            </xsl:when>
            <xsl:otherwise>
               <xsl:apply-templates select="." mode="FirstShort" />
            </xsl:otherwise>
         </xsl:choose>
      </xsl:for-each>
      <xsl:value-of select="b:Corporate"/>
   </xsl:template>



   <!--### Abschnitt 6: Hier wird festgelegt, wie der Name einer Einzelnen Person aufgebaut ist.###-->
   <!-- Beispiel: "Vorname Vorname2 Nachname" -->
   <xsl:template match="b:Person">
      <xsl:if test="b:Last != ''">
         <xsl:value-of select = "b:Last"/>
      </xsl:if>
      <xsl:text>, </xsl:text>
      <xsl:if test="b:First != ''">
         <xsl:value-of select = "b:First"/>
      </xsl:if>
      <xsl:if test="b:Middle != ''">
         <xsl:text></xsl:text>
         <xsl:value-of select = "b:Middle"/>
      </xsl:if>
   </xsl:template>

   <xsl:template match="b:Person" mode="FirstShort">
      <xsl:if test="b:Last != ''">
         <xsl:value-of select = "b:Last"/>
      </xsl:if>
      <xsl:text>, </xsl:text>
      <xsl:if test="b:First != ''">
         <xsl:value-of select = "substring(b:First, 1,1)"/>
         <xsl:text>.</xsl:text>
      </xsl:if>
      <xsl:if test="b:Middle != ''">
         <xsl:text></xsl:text>
         <xsl:value-of select = "substring(b:Middle, 1,1)"/>
         <xsl:text>.</xsl:text>
      </xsl:if>
   </xsl:template>


   <!--<xsl:value-of select="substring(b:Author/b:Author/b:NameList/b:Person/b:First, 1,1)" />-->

   <xsl:template match="text()" />
</xsl:stylesheet>
beckico95
  • 3
  • 2
  • 1
    So do you really use XSLT 2? In that case you can use `` instead of the copy-of. Actually the suggestion is to use `xsl:perform-sort` on the variable, I am not sure whether it contains `b:Source` elements or some result elements so you might need to adjust the `select` expression. – Martin Honnen Oct 25 '20 at 22:25
  • Thanks, but that did not worked. Do you have another idea? BTW: I use the following header: ` ` – beckico95 Oct 26 '20 at 20:57
  • First of all tell us if you use an XSLT 2 or 3 processor like Saxon 9 or 10, XmlPrime or Altova, otherwise you can forget about my suggestion to use `perform-sort`. In the context of MS Word I am not sure you are using a Microsoft XSLT processor which all only support XSLT 1. In addition, it would help if you show us what you want to sort, it is not clear what kind of result your templates produce and which sorting you want. As for "did not work", please show us what you tried and explain how it failed (exact error or exact result you get). – Martin Honnen Oct 26 '20 at 21:00
  • Dear Martin, I don't see any error log because it is Word... I can only see that my bibliography was not working after that. (Because it is Word I think I don't have to possibility to trace the error.) I think it is XSL Version 1 (I think so because of the header of my file) --> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" – beckico95 Oct 26 '20 at 21:17
  • I want to sort entries in my bibliography depending on their b:Tag or b:Author. This example is working inside the section where I want to output the entries: ` ` When I output 3 apply-templates I can sort them inside their output but then it is possible that I have entries sorted like that: A,B,C A,A,B – beckico95 Oct 26 '20 at 21:19
  • The snippet in your comment does not show any version, the namespace is the same in any version of XSLT. But if you use stuff directly in Word I suppose it is XSLT 1. That begs the question why you tagged the question as `xslt-2.0`? – Martin Honnen Oct 26 '20 at 21:20
  • And I want to logically combine the output of the apply-templates I mentioned to perform a sort over the 3 apply-templates to get an output of this: A, A, A, A, B, B, B, B, C – beckico95 Oct 26 '20 at 21:20
  • Regarding the xslt-2.0 I wasn't quite sure if this is used. Sorry I am new to XSL. Never did it before – beckico95 Oct 26 '20 at 21:21
  • Can you edit your question and show us any code there in a formatted way? Please show us the code of the templates you apply so that we can see what kind of elements you create. – Martin Honnen Oct 26 '20 at 21:22
  • I have edited that! – beckico95 Oct 26 '20 at 21:29
  • So the templates create HTML `p` elements with an `i` child element populated with a further apply-templates. Do you want to sort those `p` elements by the contents of the created `i` elements? – Martin Honnen Oct 26 '20 at 21:40
  • Inside the `p` elements are more than the `i` elements. There are also a couple of ` elements`. My current ouput is generating multiple entries of type `` But they are displayed in two sections. I want a sort all over these two types of entries. (Currently first comes 10 elements of 'BookSection' and after that 10 elements of the booksections with the mode. – beckico95 Oct 26 '20 at 21:47
  • Your XSLT has the templates for `b:Source`, but these are elements in your input. The output creates `p` elements and if you want to sort after creating output or output in a variable you need code to sort the `p` elements. It is not clear what the sort key would be, the content of the `i` element? – Martin Honnen Oct 26 '20 at 21:58
  • yes sounds great to sort on the `i` element. Do you know how to do that? – beckico95 Oct 26 '20 at 22:37

1 Answers1

0

You could try to sort the contents of the variable but in XSLT 1 that is only possible using a proprietary extension function so for MS Word try

<xsl:variable name="p-elements" select="msxml:node-set($Literatur)/p" xmlns:msxml="urn:schemas-microsoft-com:xslt"/>

<xsl:for-each select="$p-elements">
  <xsl:sort select="i"/>
  <xsl:copy-of select="."/>
</xsl:for-each>

instead of the xsl:copy-of select="$Literatur"/>.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110