3

変換に問題があり、いくつかのアイデアを期待していました。すべての重要なノードが互いに兄弟である、非常にフラットな入力ドキュメントを扱っています。

これは次のようになります。

<title1> Rule 51 </title1>
<p> text here </p>
<p> text here </p>
<note> Source </note>
<p> text here </p>
<title1> Rule 52 </title1>
<p> text here </p>
<p> text here </p>
<note> Source </note>
<p> text here </p>

私の目標は、この入力が次のようになることです。

  <section>
       <title1> Rule 51 </title1>
       <p> text here </p>
       <p> text here </p>
       <note> Source </note>
           <p> text here </p>
   </section>

   <section>
       <title1> Rule 52 </title1>
       <p> text here </p>
       <p> text here </p>
       <p> text here </p>
       <p> text here </p>
       <note> Source </note>
           <p> text here </p>
   </section>

上記のように、私の主な目標は、各title1とそれに続くすべての兄弟を、別のtitle1がセクション要素にヒットするまでグループ化することです。何か案は??

前もって感謝します。

4

1 に答える 1

2

試す

<!-- Change the match pattern to match the parent of the input you showed. -->
<xsl:template match="blockquote">
  <xsl:for-each-group group-starting-with="h:h4" select="*">
    <section>
      <xsl:copy-of select="current-group()" />

XSLT2.0で。

XSLT 1.0しか使用できない場合は、Muenchian Groupingを検索し、ヘルプが必要な場合はhollerを検索してください。

于 2012-09-14T15:13:28.013 に答える