这是我的要求。我的示例输入文档如下所示。(我添加了白线以使其清晰)
<body>
<p name="h-title" other="main">Introduction</p>
<p name="h-titledesc " other="other-desc">XSLT and XQuery</p>
<p name=""> XSLT is used to write stylesheets.</p>
<p name="section-title" other=" other-section">XSLT</p>
<p name="section-desc" other=" other-sectionsdesc">XSLT</p>
<p name=""> Some text.</p>
<p name="">
<p1 name="bold"> XQuery is used to query XML databases.</p1>
</p>
<p name="h1-title" other=" other-h1">XSLT</p>
<p name=""> Some text.</p>
<p name="h2-title " name="other-h2">XQuery</p>
<p name="">
<p1 name="bold"> XQuery is used to query XML databases.</p1>
</p>
<p name="h3-title" name="other-h3">XQuery and stylesheets</p>
<p name="">
<p1 name="bold"> XQuery is used to query XML databases.</p1>
</p>
<p name="section-title" other=" other-section">XSLT</p>
<p name="section-desc" other=" other-sectionsdesc">XSLT</p>
<p name=""> Some text.</p>
<p name="">
<p1 name="bold"> XQuery is used to query XML databases.</p1>
</p>
<p name="h1-title" other=" other-h1">XSLT</p>
<p name=""> Some text.</p>
<p name="h2-title " name="other-h2">XQuery</p>
<p name="">
<p1 name="bold"> XQuery is used to query XML databases.</p1>
</p>
<p name="h3-title" name="other-h3">XQuery and stylesheets</p>
<p name="">
<p1 name="bold"> XQuery is used to query XML databases.</p1>
</p>
<p name ="summary-title">this is summary</p>
<p name="summary-desc " other="other-summarydesc">the summary</p>
</body>
现在我想要的输出是这个。
<body>
<p name="h-title" other="main">Introduction</p>
<p name="h-titledesc " other="other-desc">XSLT and XQuery</p>
<p name=""> XSLT is used to write stylesheets.</p>
<body-contents>
<p name="section-title" other=" other-section">XSLT</p>
<p name="section-desc" other=" other-sectionsdesc">XSLT</p>
<p name=""> Some text.</p>
<p name="">
<p1 name="bold"> XQuery is used to query XML databases.</p1>
</p>
<h1>
<p name="h1-title" other=" other-h1">XSLT</p>
<p name=""> Some text.</p>
<h2>
<p name="h2-title " name="other-h2">XQuery</p>
<p name="">
<p1 name="bold"> XQuery is used to query XML databases.</p1>
</p>
<h3>
<p name="h3-title" name="other-h3">XQuery and stylesheets</p>
<p name="">
<p1 name="bold"> XQuery is used to query XML databases.</p1>
</p>
</h3>
</h2>
</h1>
</body-contents>
<body-contents>
<p name="section-title" other=" other-section">XSLT</p>
<p name="section-desc" other=" other-sectionsdesc">XSLT</p>
<p name=""> Some text.</p>
<p name="">
<p1 name="bold"> XQuery is used to query XML databases.</p1>
</p>
<h1>
<p name="h1-title" other=" other-h1">XSLT</p>
<p name=""> Some text.</p>
<h2>
<p name="h2-title " name="other-h2">XQuery</p>
<p name="">
<p1 name="bold"> XQuery is used to query XML databases.</p1>
</p>
<h3>
<p name="h3-title" name="other-h3">XQuery and stylesheets</p>
<p name="">
<p1 name="bold"> XQuery is used to query XML databases.</p1>
</p>
</h3>
</h2>
</h1>
</body-contents>
<body-contents>
<p name ="summary-title">this is summary</p>
<p name="summary-desc " other="other-summarydesc">the summary</p>
</body-contents>
</body>
请帮我解决这个问题。
{可选 有如下限制:
- h1、h2、h3 依次出现(也就是说,h3 不在 h1 和 h2 之间)
- name="section-title" 的行应该在 name="section-desc" 之前
- h1、h2、h3 等应该在 section-desc 之后。
我在这里解决了 h1、h2、h3 等的问题。我知道这很了不起。任何帮助都很棒。
如果违反这些规则,则不应发生转换。}