Я переводил эту полу-html, полу-xml-вики в DITA. Моя конечная цель - достичь гнездования в соответствии с заголовками h. В основном перемещайте узлы после заголовка узлов (например, h2) за пределами узла body
и заверните их в topic/body
. Уровень заголовка потенциально может снизиться до h6
.XSLT: перемещение следующих сиблингов заголовков тегов в отдельные темы
Я видел это post, который решает аналогичную проблему, но я недостаточно осведомлен, чтобы изменить его, чтобы закрыть тег тела перед другими вложенными элементами.
HTML/XML
<topic id="pageTitle">
<title>Page Title</title>
<body>
<p>some contents.</p>
<h2>heading title</h2>
<p>some more content under h heading</p>
<h3>sub-heading title</h3>
<p>some more content under sub heading</p>
<p>some more content under sub heading</p>
<h2>heading title</h2>
<p>some more content under h heading</p>
</body>
</topic>
Я хочу добиться гнездования в DITA
<topic id="pageTitle">
<title>Page Title</title>
<body>
<p>some contents.</p>
</body>
<topic id="headingtitle">
<title>heading title</title>
<body>
<p>some more content under h heading</p>
</body>
<topic id="sub-headingtitle">
<title>sub-heading title</title>
<body>
<p>some more content under sub heading</p>
<p>some more content under sub heading</p>
</body>
</topic>
</topic>
<topic id="headingtitle">
<title>heading title</title>
<body>
<p>some more content under h heading</p>
</body>
</topic>
</topic>
Обратите внимание: <body>
тег закрывается до другой темы начать. Это стандарт DITA, эта тема не должна входить в тело другой темы.
Кроме того, если узел тела немедленно следует узлу заголовка, то узел тела будет удален.
Например, XML
<topic id="pageTitle">
<title>Page Title</title>
<body>
<h2>heading title</h2>
<p>some more content under h heading</p>
</body>
</topic>
Гол
<topic id="pageTitle">
<title>Page Title</title>
<topic id="headingtitle">
<title>h2 heading</title>
<body>
<p>some more content under h heading</p>
</body>
</topic>
</topic>