Элемент Section должен быть закрыт перед другим элементом section (docbook to dita)

Мой входной файл — docbook.xml, а вывод должен быть в формате DITA с Topic DTD. В Topic DTD элемент раздела 2-го уровня не допускает попадания внутрь элемента раздела 1-го уровня. Вот мой входной xml-файл:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book
  PUBLIC "-//OASIS//DTD DocBook V5.0//EN" "http://docbook.org/xml/5.0/dtd/docbook.dtd">
<book xmlns="http://docbook.org/ns/docbook"><article><info><bibliomisc role="data.module.code">HSXWB-A-79-11-11-00A01-000A-D</bibliomisc><issuenum>001</issuenum><date>2016-01-29</date><title>LANDING GEAR</title><subtitle>FUNCTION, DATA
FOR PLANS AND DESCRIPTION</subtitle><bibliomisc role="classification">01</bibliomisc><bibliomisc role="responsible.partner.company">F0302</bibliomisc><bibliomisc role="originator">F0302</bibliomisc><bibliomisc role="applicability">ALL</bibliomisc><bibliomisc role="data.module.reference.code">TRENTXWB-A-00-00-00-01A01-022A-D</bibliomisc><bibliomisc role="quality.assurance">tabtop</bibliomisc><bibliomisc role="skill.level">sk01</bibliomisc><bibliomisc role="reason.for.update">First Release</bibliomisc><bibliomisc role="publication.code">UNKNOWN PUBLICATION</bibliomisc></info><?dbfo-need height="2cm"?><section><title>DESCRIPTION</title>
<para>The A380 is available with two types of turbofan engines, the
Rolls-Royce Trent 900 (variants A380-841, −842 and −843F) or the Engine
Alliance GP7000 (A380-861 and −863F).  Noise reduction was an important
requirement in the A380 design, and particularly affects engine design.</para>
<para>Landing gears<itemizedlist>
<listitem><para>Nose Landing Gear</para>
</listitem>
<listitem><para>Wing Landing Gear (Bogie Type, 4 Wheels  - 4 Braked)</para>
</listitem>
<listitem><para>Body Landing Gear (Bogie Type, 6 Wheels  - 4 Braked)</para>
</listitem>
</itemizedlist></para>
<section><title>Wing Landing Gear</title>
<section><para>Each wing landing gear has a leg assembly and
a four-wheel bogie beam. The WLG leg includes a Bogie Trim Actuator
(BTA) and an oleo-pneumatic shock absorber.</para>
</section></section><section><title>Body Landing Gear</title>
<section><para>The two body landing gears have a six-wheel bogie
beam and a leg assembly that includes an oleo- pneumatic shock absorber.
A two-piece drag-stay assembly mechanically locks the leg in the extended
position.</para>
</section></section></section>
<section><figure xml:id="HSXWB-A-79-11-11-00A01-000A-DTRENTXWB-A-00-00-00-01A01-022A-D-fig-0001" label="1"><title>Landing gear</title>
<mediaobject><imageobject><imagedata align="center" fileref="ICN-HSXWB-A-791111-H-F0302-00001-A-001-01.tif"/></imageobject></mediaobject>
</figure></section>
</article></book>

Фактический результат, который я получаю:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE topic
  PUBLIC "com.rsicms.rsuite_te:doctypes:dita:topic" "topic.dtd">
<topic id="topic_1">
   <title outputclass="title">LANDING GEARLANDING GEAR</title>
   <titlealts>
      <navtitle>FUNCTION, DATA
FOR PLANS AND DESCRIPTION</navtitle>
   </titlealts>
   <prolog>
      <metadata>
         <data-about>
            <data type="data.module.code">HSXWB-A-79-11-11-00A01-000A-D</data>
            <data type="classification">01</data>
            <data type="responsible.partner.company">F0302</data>
            <data type="originator">F0302</data>
            <data type="applicability">ALL</data>
            <data type="data.module.reference.code">TRENTXWB-A-00-00-00-01A01-022A-D</data>
            <data type="quality.assurance">tabtop</data>
            <data type="skill.level">sk01</data>
            <data type="reason.for.update">First Release</data>
            <data type="publication.code">UNKNOWN PUBLICATION</data>
         </data-about>
         <foreign outputclass="issuenum">001</foreign>
         <unknown outputclass="date">2016-01-29</unknown>
      </metadata>
   </prolog>
   <body>
      <section>
         <title>DESCRIPTION</title>
         <p>The A380 is available with two types of turbofan engines, the
Rolls-Royce Trent 900 (variants A380-841, −842 and −843F) or the Engine
Alliance GP7000 (A380-861 and −863F).  Noise reduction was an important
requirement in the A380 design, and particularly affects engine design.</p>
         <p>Landing gears<ul>
               <li>
                  <p>Nose Landing Gear</p>
               </li>
               <li>
                  <p>Wing Landing Gear (Bogie Type, 4 Wheels  - 4 Braked)</p>
               </li>
               <li>
                  <p>Body Landing Gear (Bogie Type, 6 Wheels  - 4 Braked)</p>
               </li>
            </ul>
         </p>
         <section>
            <title>Wing Landing Gear</title>
            <section>
               <p>Each wing landing gear has a leg assembly and
a four-wheel bogie beam. The WLG leg includes a Bogie Trim Actuator
(BTA) and an oleo-pneumatic shock absorber.</p>
            </section>
         </section>
         <section>
            <title>Body Landing Gear</title>
            <section>
               <p>The two body landing gears have a six-wheel bogie
beam and a leg assembly that includes an oleo- pneumatic shock absorber.
A two-piece drag-stay assembly mechanically locks the leg in the extended
position.</p>
            </section>
         </section>
      </section>
      <section>
         <title>Landing gear</title>
         <image align="center" href="ICN-HSXWB-A-791111-H-F0302-00001-A-001-01.tif"/>
      </section>
   </body>
</topic>

Мой xsl-файл:

<xsl:template match="*|text()|@*">
    <xsl:copy>
        <xsl:apply-templates select="@*"/>
        <xsl:apply-templates/>
    </xsl:copy>
</xsl:template>

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

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

<xsl:template match="itemizedlist">
        <ul>       
            <xsl:apply-templates/>
        </ul>      
    </xsl:template>

<xsl:template match="listitem">
        <li>
            <xsl:apply-templates/>
        </li>
    </xsl:template>

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

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

    <xsl:template match="imagedata">
        <image>
            <xsl:apply-templates select="@*"/>
        </image>
    </xsl:template>

<xsl:template match="@fileref">
   <xsl:attribute name="href">
      <xsl:value-of select="."/>
   </xsl:attribute>
</xsl:template>

    <xsl:template match="mediaobject">

            <xsl:apply-templates/>

    </xsl:template>

    <xsl:template match="imageobject">

            <xsl:apply-templates/>

    </xsl:template>

Исключенный вывод xml как:

 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE topic
  PUBLIC "com.rsicms.rsuite_te:doctypes:dita:topic" "topic.dtd">
<topic id="topic_1">
   <title outputclass="title">LANDING GEARLANDING GEAR</title>
   <titlealts>
      <navtitle>FUNCTION, DATA
FOR PLANS AND DESCRIPTION</navtitle>
   </titlealts>
   <prolog>
      <metadata>
         <data-about>
            <data type="data.module.code">HSXWB-A-79-11-11-00A01-000A-D</data>
            <data type="classification">01</data>
            <data type="responsible.partner.company">F0302</data>
            <data type="originator">F0302</data>
            <data type="applicability">ALL</data>
            <data type="data.module.reference.code">TRENTXWB-A-00-00-00-01A01-022A-D</data>
            <data type="quality.assurance">tabtop</data>
            <data type="skill.level">sk01</data>
            <data type="reason.for.update">First Release</data>
            <data type="publication.code">UNKNOWN PUBLICATION</data>
         </data-about>
         <foreign outputclass="issuenum">001</foreign>
         <unknown outputclass="date">2016-01-29</unknown>
      </metadata>
   </prolog>
   <body>
      <section>
         <title>DESCRIPTION</title>
         <p>The A380 is available with two types of turbofan engines, the
Rolls-Royce Trent 900 (variants A380-841, −842 and −843F) or the Engine
Alliance GP7000 (A380-861 and −863F).  Noise reduction was an important
requirement in the A380 design, and particularly affects engine design.</p>
         <p>Landing gears<ul>
               <li>
                  <p>Nose Landing Gear</p>
               </li>
               <li>
                  <p>Wing Landing Gear (Bogie Type, 4 Wheels  - 4 Braked)</p>
               </li>
               <li>
                  <p>Body Landing Gear (Bogie Type, 6 Wheels  - 4 Braked)</p>
               </li>
            </ul>
         </p></section>
         <section>
            <title>Wing Landing Gear</title>

               <p>Each wing landing gear has a leg assembly and
a four-wheel bogie beam. The WLG leg includes a Bogie Trim Actuator
(BTA) and an oleo-pneumatic shock absorber.</p>

         </section>
         <section>
            <title>Body Landing Gear</title>

               <p>The two body landing gears have a six-wheel bogie
beam and a leg assembly that includes an oleo- pneumatic shock absorber.
A two-piece drag-stay assembly mechanically locks the leg in the extended
position.</p>

         </section>

      <section>
         <title>Landing gear</title>
         <image align="center" href="ICN-HSXWB-A-791111-H-F0302-00001-A-001-01.tif"/>
      </section>
   </body>
</topic>

Пожалуйста, посоветуйте мне по этому поводу. заранее спасибо


person Boopathy Chandran    schedule 11.10.2016    source источник
comment
Ваш ожидаемый xml такой же, как ваш фактический результат! Пожалуйста, отредактируйте его, прежде чем мы сможем вам помочь. Пожалуйста, укажите ваш процессор xslt. XSLT 2 приветствуется.   -  person uL1    schedule 11.10.2016
comment
(1) Какой процессор XSLT вы будете использовать? Доступен ли XSLT 2.0? (2) Существует (много) преобразований Docbook в Dita. Своим вопросом вы решите примерно 1-значный процент от реальной работы. Мой совет: найдите xsl for-each-group group-ending-with или используйте Oxygen и трансформируйте его с помощью встроенной трансформации полного покрытия.   -  person uL1    schedule 11.10.2016
comment
Моя версия XSLT — 2.0. я скачал папку dbdita по этой ссылке sourceforge.net /projects/dita-ot/files/Plug-in_%20dockbook2dita/ Основная роль в этом принадлежит dbReader.xsl. Я конвертирую только через кислород. пожалуйста, посмотрите эту ссылку   -  person Boopathy Chandran    schedule 11.10.2016
comment
Почему бы вам просто не использовать это: oxygenxml.com/doc/versions/18/ug-author/topics/ ? Это решит и ваш вопрос.   -  person uL1    schedule 11.10.2016
comment
Да @uL1. Я попробовал это по вашей ссылке. но я получаю ошибки проверки с несколькими темами в качестве вывода.   -  person Boopathy Chandran    schedule 11.10.2016


Ответы (1)


В вашем конкретном примере вы можете попробовать интегрировать следующий шаблон в свой XSLT:

<xsl:template match="section">
    <section>
        <xsl:apply-templates select="node()[not(self::section)]"/>
    </section>
    <xsl:apply-templates select="section"/>
</xsl:template>
person uL1    schedule 11.10.2016
comment
Супер. Он работает нормально. Спасибо, и еще одно, я хочу, чтобы тег ‹section›‹para› был похож на тег ‹p› на выходе. не могли бы вы помочь в этом - person Boopathy Chandran; 11.10.2016
comment
Извините, это не является частью вашего ожидаемого результата! Измените свой вопрос или закройте этот вопрос, приняв прочитать это. - person uL1; 11.10.2016
comment
Спасибо @uL1. Я подниму это как отдельный счет - person Boopathy Chandran; 11.10.2016