【发布时间】:2010-03-10 00:59:03
【问题描述】:
我已经尝试了几个在这里找到的解决方案,但似乎没有一个适用于我正在使用的模型。在我的示例 XML 中,我试图将混杂的章节按正确的顺序排序。
源 XML:
<?xml version="1.0" encoding="utf-8"?>
<library>
<book>
<title>A Fascinating Tale</title>
<chapter num="4">
<text>...and rambles to the end.</text>
</chapter>
<chapter num="2">
<text>The hero would...</text>
</chapter>
<chapter num="3">
<text>This went rambling on...</text>
</chapter>
<chapter num="1">
<text>Once upon a time...</text>
</chapter>
</book>
</library>
应该导致:
<?xml version="1.0" encoding="utf-8"?>
<library>
<book>
<title>A Fascinating Tale</title>
<chapter num="1">
<text>Once upon a time...</text>
</chapter>
<chapter num="2">
<text>The hero would...</text>
</chapter>
<chapter num="3">
<text>This went rambling on...</text>
</chapter>
<chapter num="4">
<text>...and rambles to the end.</text>
</chapter>
</book>
</library>
所以从我在这里找到的样式表解决方案中,我无法得到任何工作。我让这太难了吗?看起来应该相当简单。
【问题讨论】:
-
我认为有些东西已经吃掉了您发布的 XML 示例...
-
是的,我在每行的开头添加了“4 个空格”,但它似乎不起作用,所以我添加了“反哈希”,以强制它们出现。这是我的第一篇文章,所以我不知道如何解决它。
-
您需要在普通文本和缩进四文本之间有一个空行。我刚刚解决了这个问题。
-
谢谢!这样就更有意义了。