3
我正在将此半html,semi xml wiki翻译成DITA。我的最终目标是根据h标题实现嵌套。基本上移动body
节点外的标题节点(例如h2)之后的节点,并用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>