2017-08-16 3 views
1

ich die sublist innen Artikel und Fußnotentext innerhalb Liste para hinzufügen möchten:Need sublist zwischen Schluss para und Artikel und Fußnote innerhalb Schluss para hinzufügen

Meine Quelle xml:

<body> 
<p>blahblah</p> 
<ul outputclass="l1"> 
<li outputclass="lt1">blahblah</li> 
<li outputclass="lt1">blahblah</li> 
<li outputclass="lt1">blahblah 
    <ul outputclass="l2"> 
    <li outputclass="lt2">blahblah</li> 
    <li outputclass="lt2">blahblah<fn><p>blah</p></fn></li> 
    <li outputclass="lt2">blahblah 
    <ul outputclass="l3"> 
    <li outputclass="lt3">blahblah<fn><p>blah</p></fn></li> 
    <li outputclass="lt3">blah<fn><p>blah</p></fn>blah</li> 
    <li outputclass="lt3">blahblah</li> 
    </ul></li> 
    </ul></li> 
<li outputclass="lt1">blahblah</li> 
<li outputclass="lt1">blahblah</li> 
</ul> 
<p>blahblah</p> 
</body> 

myxslt

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    exclude-result-prefixes="xs" 
    version="2.0"> 

    <xsl:template match="p"> 
     <para> 
      <xsl:apply-templates/> 
     </para> 
    </xsl:template> 

    <xsl:template match="ul[@outputclass='l1']"> 
     <itemizedlist type="&#x2022;"> 
      <xsl:apply-templates/> 
     </itemizedlist> 
    </xsl:template> 

    <xsl:template match="ul[@outputclass='l2']"> 
     <itemizedlist type="&#x2022;"> 
      <xsl:apply-templates/> 
     </itemizedlist> 
    </xsl:template> 

    <xsl:template match="ul[@outputclass='l3']"> 
     <itemizedlist type="&#x2022;"> 
      <xsl:apply-templates/> 
     </itemizedlist> 
    </xsl:template> 

    <xsl:template match="li[@outputclass='lt1']"> 
     <item> 
      <xsl:apply-templates/> 
     </item> 
    </xsl:template> 

    <xsl:template match="li[@outputclass='lt2']"> 
     <item> 
      <xsl:apply-templates/> 
     </item> 
    </xsl:template> 

    <xsl:template match="li[@outputclass='lt3']"> 
     <item> 
      <xsl:apply-templates/> 
     </item> 
    </xsl:template> 

    <xsl:template match="li/text()[normalize-space()]"> 
     <para> 
      <xsl:value-of select="."/> 
     </para> 
    </xsl:template> 

</xsl:stylesheet> 

Ausgang ich bin immer para Schließung am Ende der Unterliste als para Schließung benötigte nach sublist:

<body> 
<para>blahblah</para> 
<itemizedlist type="&#x2022;"> 
<item><para>blahblah</para></item> 
<item><para>blahblah</para></item> 
<item><para>blahblah</para> 
    <itemizedlist type="&#x2022;"> 
    <item><para>blahblah</para></item> 
    <item><para>blahblah</para><footnote><para>blah</para></footnote></item> 
    <item><para>blahblah</para> 
    <itemizedlist type="&#x2022;"> 
    <item><para>blahblah</para><footnote><para>blah</para></footnote></item> 
    **<item><para>blah</para><footnote><para>blah</para></footnote><para>blah</para></item>** 
    <item><para>blahblah</para></item> 
    </itemizedlist></item> 
    </itemizedlist></item> 
<item><para>blahblah</para></item> 
<item><para>blahblah</para></item> 
</itemizedlist> 
<para>blahblah</para> 
</body> 

aber benötigen Ausgabe als wie sublist zwischen para Schließ- und Artikel Schließen und Fußnote innen Artikel-para wie unten dargestellt sein soll:

<body> 
<para>blahblah</para> 
<itemizedlist type="&#x2022;"> 
<item><para>blahblah</para></item> 
<item><para>blahblah</para></item> 
**<item><para>blahblah</para>** 
    <itemizedlist type="&#x2022;"> 
    <item><para>blahblah</para></item> 
    <item><para>blahblah</para></item> 
    **<item><para>blahblah<footnote><para>blah</para></footnote></para>** 
    <itemizedlist type="&#x2022;"> 
    <item><para>blahblah<footnote><para>blah</para></footnote></para></item> 
    **<item><para>blah<footnote><para>blah</para></footnote>blah</para></item>** 
    <item><para>blahblah</para></item> 
    **</itemizedlist></item>** 
    **</itemizedlist></item>** 
<item><para>blahblah</para></item> 
<item><para>blahblah</para></item> 
</itemizedlist> 
<para>blahblah</para> 
</body> 

Ist es möglich, als ein bolded. Wenn möglich, bitte schlagen Sie mich vor

Vielen Dank im Voraus.

Antwort

0

Sie haben nicht wirklich erklärt Welches sind die Kriterien Knoten in para zu wickeln, ist hier eine Probe for-each-group group-adjacent="boolean(self::ul)" mit beliebigen benachbarten Knoten wickeln nicht ul Elemente in para Elemente sind:

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    exclude-result-prefixes="xs" 
    version="2.0"> 

    <xsl:template match="@* | node()" mode="#all"> 
     <xsl:copy> 
      <xsl:apply-templates select="@* | node()" mode="#current"/> 
     </xsl:copy> 
    </xsl:template> 

    <xsl:template match="p"> 
     <para> 
      <xsl:apply-templates/> 
     </para> 
    </xsl:template> 

    <xsl:template match="ul[@outputclass='l1'] | ul[@outputclass='l2'] | ul[@outputclass='l3']"> 
     <itemizedlist type="&#x2022;"> 
      <xsl:apply-templates/> 
     </itemizedlist> 
    </xsl:template> 

    <xsl:template match="li[@outputclass='lt1'] | li[@outputclass='lt2'] | li[@outputclass='lt3']"> 
     <item> 
      <xsl:for-each-group select="node()" group-adjacent="boolean(self::ul)"> 
       <xsl:choose> 
        <xsl:when test="current-grouping-key()"> 
         <xsl:apply-templates select="current-group()"/> 
        </xsl:when> 
        <xsl:otherwise> 
         <para> 
          <xsl:apply-templates select="current-group()" mode="preserve"/> 
         </para> 
        </xsl:otherwise> 
       </xsl:choose> 
      </xsl:for-each-group> 
     </item> 
    </xsl:template> 

</xsl:stylesheet> 
+0

Danke @ Martin Honnen es funktioniert – User515

Verwandte Themen