最新消息:20210917 已从crifan.com换到crifan.org

【已解决】Docbook中,将section从chapter中独立出去,放到单独的xml文件中

Docbook crifan 1512浏览 0评论

【问题】

docbook中,已经对各个chapter实现了分割为单独的xml了。

但是现在个别chapter中内容太多,所以希望将各个section部分的内容,也都再次分割独立出去,这样利于内容编辑和管理。

【解决过程】

1.打算参考chapter的做法:

<?xml version='1.0' encoding="utf-8"?>

<!DOCTYPE chapter
[

<!ENTITY % crl_ent PUBLIC "crl.ent" 'null'>%crl_ent;

]>

<chapter
    xmlns="http://docbook.org/ns/docbook"
    xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:xl="http://www.w3.org/1999/xlink"
    
    xml:id="ch03_uppper_lan">
<title>上层语言</title>
<abstract></abstract>
    <sect1><title>上层语言综述</title>
...
    </sect1>
    
    <sect1 xml:id="lan.cpp"><title>C++</title>
...
    </sect1>

</chapter>

然后主xml中再包含进去:

<xi:include href="ch03_uppper_lan.xml" />

然后去弄出个sect1的xml文件,然后再在chapter中xi:include此sect1的xml。

2.然后弄成了这样子的:

子文件ch02s1_python.xml:

<?xml version='1.0' encoding="utf-8"?>

<!DOCTYPE sect1
[

<!ENTITY % crl_ent PUBLIC "crl.ent" 'null'>%crl_ent;

]>

<sect1
    xmlns="http://docbook.org/ns/docbook"
    xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:xl="http://www.w3.org/1999/xlink"
    
    xml:id="lan.python">
<title>Python</title>
    <sect2><title>Python特点</title>
......
    </sect2>
    
    <sect2><title>如何在Windows环境下使用Python脚本</title>
......
    </sect2>
    
    <sect2 xml:id="lan.python.crifanlib"><title>crifan的Python库:crifanLib.py</title>
......
    </sect2>
</sect1>

而上一级文件ch02_script_lan.xml是这样的:

<?xml version='1.0' encoding="utf-8"?>

<!DOCTYPE chapter
[

<!ENTITY % crl_ent PUBLIC "crl.ent" 'null'>%crl_ent;

]>

<chapter
    xmlns="http://docbook.org/ns/docbook"
    xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:xl="http://www.w3.org/1999/xlink"
    
    xml:id="ch02_script_lan">
<title>脚本语言</title>
<abstract></abstract>
    <sect1><title>脚本语言综述</title>
......
    </sect1>
    
    <xi:include href="ch02s1_python.xml" />
    ......
</chapter>

这样就成功实现了将sect1从chapter中分离出来,放到一个单独的xml文件中了。

【总结】

将sect1/section从chapter中分离出来,和把chapter从主xml文件中分离出来,方法是类似的,

都是主文件中包含子文件:

<xi:include href="sub_file.xml" />

然后子文件sub_file.xml中根元素是sect1,即可:

<?xml version='1.0' encoding="utf-8"?>

<!DOCTYPE sect1
[

<!ENTITY % crl_ent PUBLIC "crl.ent" 'null'>%crl_ent;

]>

<sect1
    xmlns="http://docbook.org/ns/docbook"
    xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:xl="http://www.w3.org/1999/xlink"
    
    xml:id="lan.python">
<title>Python</title>
    <sect2><title>Python特点</title>
......
    </sect2>
    
    <sect2><title>如何在Windows环境下使用Python脚本</title>
......
    </sect2>
    
    <sect2 xml:id="lan.python.crifanlib"><title>crifan的Python库:crifanLib.py</title>
......
    </sect2>
</sect1>

转载请注明:在路上 » 【已解决】Docbook中,将section从chapter中独立出去,放到单独的xml文件中

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
92 queries in 0.187 seconds, using 23.57MB memory