2009-06-04 193 views
2

我有关于XSLT的任务。过滤器XSLT结果

我在Sitecore CMS上制作一个网站,其中一些页面必须显示文章列表。这不是问题。

每篇文章列表都可以使用一个或多个标签进行“标记”,每篇文章都可以使用相同的标签。假设我有一个已经用'WordPress'标记的文章列表。然后,我只想显示那些也被标记为'WordPress'的文章。那也没关系。

但是现在我的问题: 如果articlelist标记有一个以上的标签,并且一篇文章被标注相同的标记,那么文章就会显示几次,因为我的XSLT识别标签超过一次。

举例: 我有一个标签为'A'和'B'的文章列表。 然后我有四个文章:

  • 第1条(标签: 'A')
  • 第2条(标签: 'A' 和 'B')
  • 第3条(标签: 'B' 和“C”)
  • 第4条(标签:“d”)

现在在我的名单我想告诉所有具有相同的标签,我articlelist的文章。这将是第1条,第2条和第3条。

我的代码这样做,但由于列表和第2条上的两个相同的标签,第2条出现了两次,这并不好。

我有我的一些代码楼下:

<xsl:template match="*"> 
    <xsl:variable name="ids" select="concat(sc:fld('tags',$sc_currentitem),'|')"/> 

    <xsl:call-template name="PrintTitles"> 
    <xsl:with-param name="ids" select="$ids"/> 
    <!-- $sc_currentitem is the item that im currently standing on --> 
    <xsl:with-param name="item" select="$sc_currentitem" /> 
    </xsl:call-template> 
</xsl:template> 

<xsl:template name="PrintTitles"> 
    <xsl:param name="ids"/> 
    <xsl:param name="item"/> 
    <xsl:variable name="itm_id" select="substring-before($ids, '|')"/> 

    <xsl:apply-templates select=" 
    msxml:node-set($item)/item[ 
     contains(fields/field[@key='tags'], $itm_id) 
    ] 
    " mode="insure"> 
    <xsl:with-param name="itm_id" select="$itm_id" /> 
    </xsl:apply-templates> 

    <xsl:call-template name="PrintTitles"> 
    <xsl:with-param name="ids" select="substring-after($ids, '|')"/> 
    <xsl:with-param name="item" select="$item" /> 
    </xsl:call-template> 

</xsl:template> 

<xsl:template match="item" mode="insure"> 
    <xsl:param name="itm_id" /> 
    <!-- ... --> 
</xsl:template> 

继承人从articlelists我的一个XML:

<item name="Artikelliste" key="artikelliste" id="{92BC787F-C935-4EE7-9D41-AEAF67C9CC06}" tid="{D0C4BD18-E64E-4470-B483-4F33BD50F25F}" mid="{00000000-0000-0000-0000-000000000000}" sortorder="200" language="en" version="1" template="artikelliste" parentid="{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"> 
    <fields> 
     <field tfid="{25BED78C-4957-4165-998A-CA1B52F67497}" key="__created" type="datetime"> 
      <content></content> 
     </field> 
     <field tfid="{BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}" key="__updated by" type="text"> 
      <content></content> 
     </field> 
     <field tfid="{234DC975-40DA-472B-B315-796C0FAA8D53}" key="meta title" type="Single-Line Text"> 
      <content></content> 
     </field> 
     <field tfid="{D9CF14B1-FA16-4BA6-9288-E8A174D4D522}" key="__updated" type="datetime"> 
      <content></content> 
     </field> 
     <field tfid="{72BA1931-236F-4279-8E39-8AC60D33408F}" key="navn i menuen" type="Single-Line Text"> 
      <content></content> 
     </field> 
     <field tfid="{8CDC337E-A112-42FB-BBB4-4143751E123F}" key="__revision" type="text"> 
      <content></content> 
     </field> 
     <field tfid="{9683EB7C-DE18-472D-B058-562573FAE23D}" key="titel" type="Single-Line Text"> 
      <content></content> 
     </field> 
     <field tfid="{001DD393-96C5-490B-924A-B0F25CD9EFD8}" key="__lock" type="memo"> 
      <content></content> 
     </field> 
     <field tfid="{93871141-7CB3-472E-9A75-6237A3BCC0F6}" key="tekstindhold" type="Rich Text"> 
      <content></content> 
     </field> 
     <field tfid="{9C13A0D7-2B01-4BB6-B35F-9B073ABEDDF3}" key="relaterede sider" type="Treelist"> 
      <content></content> 
     </field> 
     <field tfid="{92EB3D7A-DA52-496F-ABC1-6869E3B14551}" key="tags" type="Treelist"> 
      <content></content> 
     </field> 
     <field tfid="{2E4FD6E4-83FE-4592-9327-FEC102F817C9}" key="billedetop" type="Image"> 
      <content></content> 
     </field> 
     <field tfid="{7C67F2F2-3577-4466-B170-552E463ADD57}" key="source" type="Droptree"> 
      <content></content> 
     </field> 
     <field tfid="{C38B9B42-D81D-42ED-A56E-4DBA6FD92D4A}" key="antal artikler" type="Number"> 
      <content></content> 
     </field> 
     <field tfid="{5E6D670A-2DD4-4088-8E82-FFD920CEFD9C}" key="alle artikler link" type="Internal Link"> 
      <content></content> 
     </field> 
     <field tfid="{BA3F86A2-4A1C-4D78-B63D-91C2779C1B5E}" key="__sortorder" type="text"> 
      <content></content> 
     </field> 
     <field tfid="{F1A1FE9E-A60C-4DDB-A3A0-BB5B29FE732E}" key="__renderings" type="layout"> 
      <content></content> 
     </field> 
     <field tfid="{DEC8D2D5-E3CF-48B6-A653-8E69E2716641}" key="__security" type="security"> 
      <content></content> 
     </field> 
     <field tfid="{A0CB3965-8884-4C7A-8815-B6B2E5CED162}" key="__editors" type="TreelistEx"> 
      <content></content> 
     </field> 
    </fields> 
    <item name="HP artikel" key="hp artikel" id="{94A742D5-D446-4170-8AF8-099561F57CC4}" tid="{303D39D0-278E-4034-8420-E19A3DEC3298}" mid="{00000000-0000-0000-0000-000000000000}" sortorder="100" language="en" version="1" template="artikel" parentid="{92BC787F-C935-4EE7-9D41-AEAF67C9CC06}"> 
     <fields> 
      <field tfid="{25BED78C-4957-4165-998A-CA1B52F67497}" key="__created" type="datetime"> 
       <content></content> 
      </field> 
      <field tfid="{8CDC337E-A112-42FB-BBB4-4143751E123F}" key="__revision" type="text"> 
       <content></content> 
      </field> 
      <field tfid="{234DC975-40DA-472B-B315-796C0FAA8D53}" key="meta title" type="Single-Line Text"> 
       <content></content> 
      </field> 
      <field tfid="{9683EB7C-DE18-472D-B058-562573FAE23D}" key="titel" type="Single-Line Text"> 
       <content></content> 
      </field> 
      <field tfid="{BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}" key="__updated by" type="text"> 
       <content></content> 
      </field> 
      <field tfid="{D9CF14B1-FA16-4BA6-9288-E8A174D4D522}" key="__updated" type="datetime"> 
       <content></content> 
      </field> 
      <field tfid="{001DD393-96C5-490B-924A-B0F25CD9EFD8}" key="__lock" type="memo"> 
       <content></content> 
      </field> 
      <field tfid="{93871141-7CB3-472E-9A75-6237A3BCC0F6}" key="tekstindhold" type="Rich Text"> 
       <content></content> 
      </field> 
      <field tfid="{F1F0A054-010A-41F1-B0AC-D0D658727181}" key="teaser" type="Multi-Line Text"> 
       <content></content> 
      </field> 
      <field tfid="{476E11CA-A205-48B2-9520-A0C3D954B281}" key="e-mail" type="Single-Line Text"> 
       <content></content> 
      </field> 
      <field tfid="{30A47651-E207-4042-95CC-67C00696EA6F}" key="skrevet af" type="Single-Line Text"> 
       <content></content> 
      </field> 
      <field tfid="{12DE369B-E308-4F24-A617-CD426CF0A29A}" key="relateret information" type="Treelist"> 
       <content></content> 
      </field> 
      <field tfid="{311C5D67-66FB-422A-84CC-3312EF8A6B64}" key="medarbejder" type="Multilist"> 
       <content></content> 
      </field> 
      <field tfid="{08D9129F-0967-4718-A158-2B8CC322D1E7}" key="tags" type="Treelist"> 
       <content></content> 
      </field> 
      <field tfid="{F1A1FE9E-A60C-4DDB-A3A0-BB5B29FE732E}" key="__renderings" type="layout"> 
       <content></content> 
      </field> 
     </fields> 
    </item> 
    <item name="Microsoft artikel" key="microsoft artikel" id="{7AF63885-8BA4-4619-9654-12B3865500D0}" tid="{303D39D0-278E-4034-8420-E19A3DEC3298}" mid="{00000000-0000-0000-0000-000000000000}" sortorder="100" language="en" version="1" template="artikel" parentid="{92BC787F-C935-4EE7-9D41-AEAF67C9CC06}"> 
     <fields> 
      <field tfid="{25BED78C-4957-4165-998A-CA1B52F67497}" key="__created" type="datetime"> 
       <content></content> 
      </field> 
      <field tfid="{8CDC337E-A112-42FB-BBB4-4143751E123F}" key="__revision" type="text"> 
       <content></content> 
      </field> 
      <field tfid="{234DC975-40DA-472B-B315-796C0FAA8D53}" key="meta title" type="Single-Line Text"> 
       <content></content> 
      </field> 
      <field tfid="{9683EB7C-DE18-472D-B058-562573FAE23D}" key="titel" type="Single-Line Text"> 
       <content></content> 
      </field> 
      <field tfid="{BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}" key="__updated by" type="text"> 
       <content></content> 
      </field> 
      <field tfid="{D9CF14B1-FA16-4BA6-9288-E8A174D4D522}" key="__updated" type="datetime"> 
       <content></content> 
      </field> 
      <field tfid="{001DD393-96C5-490B-924A-B0F25CD9EFD8}" key="__lock" type="memo"> 
       <content></content> 
      </field> 
      <field tfid="{93871141-7CB3-472E-9A75-6237A3BCC0F6}" key="tekstindhold" type="Rich Text"> 
       <content></content> 
      </field> 
      <field tfid="{F1F0A054-010A-41F1-B0AC-D0D658727181}" key="teaser" type="Multi-Line Text"> 
       <content></content> 
      </field> 
      <field tfid="{476E11CA-A205-48B2-9520-A0C3D954B281}" key="e-mail" type="Single-Line Text"> 
       <content></content> 
      </field> 
      <field tfid="{30A47651-E207-4042-95CC-67C00696EA6F}" key="skrevet af" type="Single-Line Text"> 
       <content></content> 
      </field> 
      <field tfid="{2E4FD6E4-83FE-4592-9327-FEC102F817C9}" key="billedetop" type="Image"> 
       <content></content> 
      </field> 
      <field tfid="{12DE369B-E308-4F24-A617-CD426CF0A29A}" key="relateret information" type="Treelist"> 
       <content></content> 
      </field> 
      <field tfid="{311C5D67-66FB-422A-84CC-3312EF8A6B64}" key="medarbejder" type="Multilist"> 
       <content></content> 
      </field> 
      <field tfid="{B61C079A-0B97-4CC0-BB9F-22E7B49D57F9}" key="relaterede sider" type="Treelist"> 
       <content></content> 
      </field> 
      <field tfid="{08D9129F-0967-4718-A158-2B8CC322D1E7}" key="tags" type="Treelist"> 
       <content></content> 
      </field> 
      <field tfid="{F1A1FE9E-A60C-4DDB-A3A0-BB5B29FE732E}" key="__renderings" type="layout"> 
       <content></content> 
      </field> 
     </fields> 
    </item> 
    <item name="New Artikel" key="new artikel" id="{91D6625E-F0C4-43C0-A990-078536C1989C}" tid="{303D39D0-278E-4034-8420-E19A3DEC3298}" mid="{00000000-0000-0000-0000-000000000000}" sortorder="100" language="en" version="2" template="artikel" parentid="{92BC787F-C935-4EE7-9D41-AEAF67C9CC06}"> 
     <fields> 
      <field tfid="{25BED78C-4957-4165-998A-CA1B52F67497}" key="__created" type="datetime"> 
       <content></content> 
      </field> 
      <field tfid="{BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}" key="__updated by" type="text"> 
       <content></content> 
      </field> 
      <field tfid="{5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}" key="__created by" type="text"> 
       <content></content> 
      </field> 
      <field tfid="{234DC975-40DA-472B-B315-796C0FAA8D53}" key="meta title" type="Single-Line Text"> 
       <content></content> 
      </field> 
      <field tfid="{D9CF14B1-FA16-4BA6-9288-E8A174D4D522}" key="__updated" type="datetime"> 
       <content></content> 
      </field> 
      <field tfid="{8CDC337E-A112-42FB-BBB4-4143751E123F}" key="__revision" type="text"> 
       <content></content> 
      </field> 
      <field tfid="{9683EB7C-DE18-472D-B058-562573FAE23D}" key="titel" type="Single-Line Text"> 
       <content></content> 
      </field> 
      <field tfid="{3E431DE1-525E-47A3-B6B0-1CCBEC3A8C98}" key="__workflow state" type="reference"> 
       <content></content> 
      </field> 
      <field tfid="{001DD393-96C5-490B-924A-B0F25CD9EFD8}" key="__lock" type="memo"> 
       <content></content> 
      </field> 
      <field tfid="{93871141-7CB3-472E-9A75-6237A3BCC0F6}" key="tekstindhold" type="Rich Text"> 
       <content></content> 
      </field> 
      <field tfid="{F1F0A054-010A-41F1-B0AC-D0D658727181}" key="teaser" type="Multi-Line Text"> 
       <content></content> 
      </field> 
      <field tfid="{C8F93AFE-BFD4-4E8F-9C61-152559854661}" key="__valid from" type="datetime"> 
       <content></content> 
      </field> 
      <field tfid="{08D9129F-0967-4718-A158-2B8CC322D1E7}" key="tags" type="Treelist"> 
       <content></content> 
      </field> 
      <field tfid="{12DE369B-E308-4F24-A617-CD426CF0A29A}" key="relateret information" type="Treelist"> 
       <content></content> 
      </field> 
     </fields> 
    </item> 
    <item name="NY" key="ny" id="{F54BC47C-8D7D-4017-BA39-31AAFCD92042}" tid="{303D39D0-278E-4034-8420-E19A3DEC3298}" mid="{00000000-0000-0000-0000-000000000000}" sortorder="100" language="en" version="1" template="artikel" parentid="{92BC787F-C935-4EE7-9D41-AEAF67C9CC06}"> 
     <fields> 
      <field tfid="{25BED78C-4957-4165-998A-CA1B52F67497}" key="__created" type="datetime"> 
       <content></content> 
      </field> 
      <field tfid="{BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}" key="__updated by" type="text"> 
       <content></content> 
      </field> 
      <field tfid="{5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}" key="__created by" type="text"> 
       <content></content> 
      </field> 
      <field tfid="{234DC975-40DA-472B-B315-796C0FAA8D53}" key="meta title" type="Single-Line Text"> 
       <content></content> 
      </field> 
      <field tfid="{D9CF14B1-FA16-4BA6-9288-E8A174D4D522}" key="__updated" type="datetime"> 
       <content></content> 
      </field> 
      <field tfid="{8CDC337E-A112-42FB-BBB4-4143751E123F}" key="__revision" type="text"> 
       <content></content> 
      </field> 
      <field tfid="{9683EB7C-DE18-472D-B058-562573FAE23D}" key="titel" type="Single-Line Text"> 
       <content></content> 
      </field> 
      <field tfid="{3E431DE1-525E-47A3-B6B0-1CCBEC3A8C98}" key="__workflow state" type="reference"> 
       <content></content> 
      </field> 
      <field tfid="{001DD393-96C5-490B-924A-B0F25CD9EFD8}" key="__lock" type="memo"> 
       <content></content> 
      </field> 
      <field tfid="{08D9129F-0967-4718-A158-2B8CC322D1E7}" key="tags" type="Treelist"> 
       <content></content> 
      </field> 
      <field tfid="{93871141-7CB3-472E-9A75-6237A3BCC0F6}" key="tekstindhold" type="Rich Text"> 
       <content></content> 
      </field> 
      <field tfid="{F1F0A054-010A-41F1-B0AC-D0D658727181}" key="teaser" type="Multi-Line Text"> 
       <content></content> 
      </field> 
     </fields> 
    </item> 
</item> 

所以我的问题是:我如何过滤掉如果该文章已在列表中显示,则该文章不会显示多次,即使它与列表标记有多个共同标记。

如果你们中有些人知道如何在日期之后对列表中的文章进行排序,那也会很棒。

我希望你明白我的问题,以及一些你想帮我:)

感谢

-Kim安徒生

+0

请发表您的相应的XML输入,以及。 – Tomalak 2009-06-04 07:05:33

+0

在这里你去Tomalak :) – 2009-06-04 07:13:57

回答

0

嗨Tomalak和其他人(?)

对不起,没有回应这个问题。我想通了,并做了一个完全不同的XSLT,但现在它工作。

如果有人有兴趣,我已经把我的代码放在下面。但是有很多的它;)

<xsl:template match="*"> 

tekst tekst_smal

 <sc:text field="Content"></sc:text> 
     <!-- MAX: <xsl:value-of select="$maxAntal" /> --> 
    </div> 
<xsl:variable name="alleArtikler"> 
     <root> 
      <xsl:choose> 
       <xsl:when test="$source/@id != '{0DE95AE4-41AB-4D01-9EB0-67441B7C2450}'"> 
        <xsl:apply-templates select="$source/descendant-or-self::item[@template = 'article']"> 
         <xsl:with-param name="tags" select="$tags" /> 
        </xsl:apply-templates> 
       </xsl:when> 
       <xsl:otherwise> 
        <xsl:apply-templates select="$sc_currentitem/descendant-or-self::item[@template = 'article']"> 
         <xsl:with-param name="tags" select="$tags" /> 
        </xsl:apply-templates> 
       </xsl:otherwise> 

      </xsl:choose> 
     </root> 
    </xsl:variable> 
    <xsl:variable name="listTags"> 
     <root> 
      <page> 
       <xsl:call-template name="getTags"> 
        <xsl:with-param name="ids" select="$tags"></xsl:with-param> 
       </xsl:call-template> 
      </page> 
     </root> 
    </xsl:variable> 

    <xsl:choose> 

     <xsl:when test="$hasChilds"> 
      <xsl:choose> 
       <!-- HVIS ARTIKELLISTEN ER TAGGET --> 
       <xsl:when test="$tags != ''"> 
        <xsl:variable name="showThese"> 
         <root> 
          <xsl:for-each select="msxml:node-set($listTags)//tag"> 
           <xsl:variable name="pageTagId" select="."></xsl:variable> 

           <xsl:for-each select="msxml:node-set($alleArtikler)/root/artikel[tag = $pageTagId]"> 
            <artikel date="{@date}"> 
             <id> 
              <xsl:value-of select="@id" /> 
             </id> 
            </artikel> 
           </xsl:for-each> 
          </xsl:for-each> 
         </root> 
        </xsl:variable> 

        <xsl:variable name="tt" select="msxml:node-set($showThese)" /> 
        <xsl:apply-templates select="$tt/root/artikel[not(id=preceding-sibling::artikel/id)]" mode="Presentation"> 
         <xsl:sort data-type="text" select="./@date" order="descending" /> 
        </xsl:apply-templates>            
       </xsl:when> 

       <!-- HVIS ARTIKELLISTEN IKKE ER TAGGET -->  
       <xsl:otherwise> 
        <xsl:variable name="showThese"> 
         <root> 
          <xsl:for-each select="msxml:node-set($alleArtikler)/root/artikel"> 
           <artikel date="{@date}"> 
            <id> 
             <xsl:value-of select="@id" /> 
            </id> 
           </artikel> 
          </xsl:for-each>  
         </root> 
        </xsl:variable> 

        <xsl:variable name="tt" select="msxml:node-set($showThese)" /> 
        <xsl:apply-templates select="$tt/root/artikel[not(id=preceding-sibling::artikel/id)]" mode="Presentation"> 
         <xsl:sort data-type="text" select="./@date" order="descending" /> 
        </xsl:apply-templates> 

       </xsl:otherwise> 
      </xsl:choose> 

     </xsl:when> 
     <xsl:when test="not($hasChilds)"> 
      <xsl:choose> 
       <!-- HVIS ARTIKELLISTEN ER TAGGET --> 
       <xsl:when test="$tags != ''"> 
        <xsl:variable name="showThese"> 
         <root> 
          <xsl:for-each select="msxml:node-set($listTags)//tag"> 
           <xsl:variable name="pageTagId" select="."></xsl:variable> 

           <xsl:for-each select="msxml:node-set($alleArtikler)/root/artikel[tag = $pageTagId]"> 
            <artikel date="{@date}"> 
             <id> 
              <xsl:value-of select="@id" /> 
             </id> 
            </artikel> 
           </xsl:for-each> 
          </xsl:for-each> 
         </root> 
        </xsl:variable> 

        <xsl:variable name="tt" select="msxml:node-set($showThese)" /> 
        <xsl:apply-templates select="$tt/root/artikel[not(id=preceding-sibling::artikel/id)]" mode="Presentation"> 
         <xsl:sort data-type="text" select="./@date" order="descending" /> 
        </xsl:apply-templates> 
       </xsl:when> 

       <!-- HVIS ARTIKELLISTEN IKKE ER TAGGET --> 
       <xsl:otherwise> 
        <xsl:variable name="showThese"> 
         <root> 
          <xsl:for-each select="msxml:node-set($alleArtikler)/root/artikel"> 
           <artikel date="{@date}"> 
            <id> 
             <xsl:value-of select="@id" /> 
            </id> 
           </artikel> 
          </xsl:for-each> 
         </root> 
        </xsl:variable> 

        <xsl:variable name="tt" select="msxml:node-set($showThese)" /> 
        <xsl:apply-templates select="$tt/root/artikel[not(id=preceding-sibling::artikel/id)]" mode="Presentation"> 
         <xsl:sort data-type="text" select="./@date" order="descending" /> 
        </xsl:apply-templates> 

       </xsl:otherwise> 
      </xsl:choose> 
     </xsl:when> 
     <xsl:otherwise> 
      Der findes desværre ingen artikler. 
     </xsl:otherwise> 
    </xsl:choose> 

    <xsl:if test="sc:fld('All Articles link', $sc_currentitem) != ''"> 
     <!--<xsl:variable name="alleArtiklerLink" select="sc:fld('Alle artikler link', $sc_currentitem)" />--> 
     <div> 
      <xsl:choose> 
       <xsl:when test="sc:fld('Related pages', $sc_currentitem) = ''"> 
        <xsl:attribute name="class">alle_bred</xsl:attribute> 
       </xsl:when> 
       <xsl:otherwise> 
        <xsl:attribute name="class">alle_smal</xsl:attribute> 
       </xsl:otherwise> 
      </xsl:choose> 
      <div class="alle_artikler"> 
       <!--<a href="{$alleArtiklerLink}"> 
        <img src="/frontend/images/alle_artikler_btn.png" alt="Alle artikler" /> 
       </a>--> 
       <sc:link select="$sc_currentitem" field="All Articles link"> 
        <img src="/frontend/images/alle_artikler_btn.png" alt="Alle artikler" /> 
       </sc:link> 
      </div> 
     </div> 
    </xsl:if> 

</xsl:template> 
<xsl:template match="artikel" mode="Presentation"> 
    <xsl:variable name="artikel" select="sc:item(./id, .)"></xsl:variable> 
    <!-- <xsl:value-of select="sc:fld('titel', $artikel)"></xsl:value-of> --> 

    <xsl:if test="position() &lt; $maxAntal"> 
    <div> 

     <xsl:choose> 
      <xsl:when test="(sc:fld('Related pages', $sc_currentitem) = '')"> 
       <xsl:attribute name="class">artikel_bred</xsl:attribute> 

       <div class="liste_top"></div> 

       <div class="liste_bg"> 
        <div class="liste_tekst"> 
         <div class="dato"> 
          <xsl:value-of select="sc:formatdate(sc:fld('date',$artikel),'dd-MM-yyyy')"/> 
         </div> 
         <h3> 
          <sc:link select="$artikel"> 
           <xsl:value-of select="sc:fld('Title',$artikel)" /> 
          </sc:link> 
         </h3> 

         <div class="teaser_bred"> 
          <xsl:choose> 
           <xsl:when test="sc:fld('teaser',$artikel) != ''"> 
            <xsl:value-of select="sc:fld('teaser',$artikel)" disable-output-escaping="yes" /> 
           </xsl:when> 
           <xsl:otherwise> 
            <xsl:value-of select="sc:fld('Content',$artikel)" disable-output-escaping="yes" /> 
           </xsl:otherwise> 
          </xsl:choose> 

         </div> 
         <div class="read_more"> 
          <sc:link select="$artikel"> 
           Læs mere >> 
          </sc:link> 
         </div> 

        </div> 
       </div> 

       <div class="liste_bund"></div> 
      </xsl:when> 


      <xsl:otherwise> 
       <xsl:attribute name="class">artikel_smal</xsl:attribute> 
       <div class="liste_smal_top"></div> 

       <div class="liste_smal_bg"> 
        <div class="liste_smal_tekst"> 
         <div class="dato"> 
          <xsl:value-of select="sc:formatdate(sc:fld('date',$artikel),'dd-MM-yyyy')"/> 
         </div> 
         <h3> 
          <sc:link select="$artikel"> 
           <xsl:value-of select="sc:fld('Title',$artikel)" /> 
          </sc:link> 
         </h3> 

         <div class="teaser_smal"> 
          <xsl:value-of select="sc:fld('Content',$artikel)" disable-output-escaping="yes" /> 
         </div> 
         <div class="read_more"> 
          <sc:link select="$artikel"> 
           Læs mere >> 
          </sc:link> 
         </div> 

        </div> 
       </div> 

       <div class="liste_smal_bund"></div> 
      </xsl:otherwise> 
     </xsl:choose> 

    </div> 
    </xsl:if> 
</xsl:template> 
<xsl:template match="item[@template = 'article']"> 
    <artikel id="{@id}" date="{sc:fld('date', .)}"> 

     <xsl:variable name="tags" select="./fields/field[@key='tags']"></xsl:variable> 
     <xsl:call-template name="getTags"> 
      <xsl:with-param name="ids" select="$tags"></xsl:with-param> 
     </xsl:call-template> 

    </artikel> 
</xsl:template> 

<xsl:template name="getTags"> 
    <xsl:param name="ids"/> 
    <xsl:if test="$ids"> 
     <xsl:variable name="itm_id" select="substring-before($ids, '|')"/> 
     <xsl:if test="$itm_id"> 
      <tag> 
       <xsl:value-of select="$itm_id" /> 
      </tag> 
     </xsl:if> 
     <xsl:if test="$itm_id = ''"> 
      <tag> 
       <xsl:value-of select="$ids" /> 
      </tag> 
     </xsl:if> 
     <xsl:call-template name="getTags"> 
      <xsl:with-param name="ids" select="substring-after($ids, '|')"/> 
     </xsl:call-template> 
    </xsl:if> 
</xsl:template> 
2

一个天真的解决办法是沿着$done变量拖动并输出任何东西之前检查:

<xsl:template name="PrintTitles"> 
    <xsl:param name="ids"/> 
    <xsl:param name="item"/> 
    <xsl:param name="done" select="'|'"/> 

    <xsl:variable name="itm_id" select="substring-before($ids, '|')"/> 

    <xsl:if test="not(contains($done, concat('|', $itm_id, '|'))"> 
    <xsl:apply-templates select="msxml:node-set($item)/item[contains(fields/field[@key='tags'], $itm_id)]" mode="insure"> 
     <xsl:with-param name="itm_id" select="$itm_id"></xsl:with-param>      
    </xsl:apply-templates> 
    </xsl:if> 

    <xsl:call-template name="PrintTitles"> 
    <xsl:with-param name="ids" select="substring-after($ids, '|')"/> 
    <xsl:with-param name="item" select="$item" /> 
    <xsl:with-param name="done" select="concat($done, $itm_id, '|')" /> 
    </xsl:call-template> 

</xsl:template> 

但是,我有一个预感,整个问题可以解决米矿石优雅,但没有输入XML这是很难的。