xml - 可以使用 'role' 属性对 DocBook 元素进行子类化吗?如果是这样,怎么办?

标签 xml xsd polymorphism reusability docbook

我正在尝试对 DocBook 进行微妙的自定义,我怀疑通过子类化 <informaltable> 可以最轻松地解决这个问题。元素。有几个语句暗示使用 role 对 DocBook 元素进行子类化。属性是可能的。

暗示使用角色进行子类化是可能的文档

示例 1 - 来自 DocBook 5.1:权威指南 - 自定义 DocBook

The role attribute, found on almost all of the elements in DocBook, is a text attribute that can be used to subclass an element.

示例 2 - 来自 DocBook 5.1:权威指南 - DocBook 元素引用

While role is a common attribute in the sense that it occurs on all DocBook elements, customizers will find that it is not part of any of the “common attribute” patterns. It is parameterized differently because it is useful to be able to subclass role independently on different elements.

示例 3 - CERN - 使用 DocBook 编写文档

Most DocBook tags contain a common set of attributes. The most often-used such common attributes are lang, which specifies the language of the data inside the element, id labels an element so that it can be referenced by other elements, and role, which allows one to subclass an element, to make it information-wise more specific.

Google 一般调查结果。

谷歌搜索“扩展文档元素角色属性”的组合会显示有关处理新元素的模板的页面,但除了下面的自定义示例之外,似乎没有显示任何页面,甚至考虑使用 role 子类化元素。属性。

确实存在的自定义示例

存在examples自定义现有 DocBook 元素的格式,但这些是 XSLT 自定义,并不涉及扩展 DocBook 架构。

还存在an example添加 <sect6>元素,但它似乎过于冗长,无法成为子类化的有效方法,而且我怀疑从技术上讲,该示例根本不是子类化。另外,该示例似乎没有对 role 有任何特殊用途。属性。

可以使用 role 进行子类化属性真的可以实现吗?

从上面的示例看来,DocBook 模式是专门设计来促进使用 role 对元素进行子类化的。属性,但似乎没有发布具体示例。

我对 XML 和 DocBook 都很陌生。 DocBook 元素的子类化是否如此微不足道以至于没有被注意到?如果是这样,有人可以展示它是如何实现的吗?

正在使用 role 子类化 DocBook 元素一个好主意就是行不通?如果是这样,为什么它不起作用?

注释 1: 是否子类化<informaltable>解决我原来问题的正确方法完全是另一个问题。

注释 2: 我的问题中有更多超链接,但显然我的声誉不允许我发布超过 2 个:(

最佳答案

It seems from the above examples that the DocBook schema was specifically designed to facilitate subclassing of elements using the role attribute, however, no concrete example seems to be published.

Example 5.14 TDG 是一个非常具体的示例,展示了如何约束 role <procedure> 上的属性元素,以便只允许两个值(默认情况下,允许任何值)。此定制需要修改架构。您可以使用 <informaltable> 执行类似的操作如果你愿意的话。

没有什么可以阻止您使用类似的东西

<informaltable role="myspecialtable">
 ...
</informaltable>

这是最简单的“子类化”;不需要更改架构。如何role="myspecialtable"是否应该被解释或处理完全取决于您。

There also exists an example that adds a <sect6> element, but it seems too verbose to be an efficient means of subclassing, and I suspect that technically that example isn't subclassing at all. Also, that example doesn't seem to make any special use of the role attribute.

那么你对子类化的想法是什么?

也许术语“子类化”可能有点误导。 DocBook 是一个标记系统,而不是一种编程语言。子类化(定制)DocBook 元素与在 Java 或 C++ 中创建子类之间的类比不应太过分。

role 并没有什么神奇之处。 。它只是一个没有预定义语义的属性。您无需对其进行任何特殊操作即可创建 DocBook 自定义。

Is subclassing a DocBook element so trivial that it goes unnoted?

为什么这么说?整体"Customizing DocBook"这一章是关于 DocBook 元素的定制。这不是被忽视的事情。

Is subclassing a DocBook element using role a nice idea that just doesn't work?

它确实有效,但可能不是你期望的那样。

如上所述,只需确定 role 的特定值即可元素上的属性并在文档中使用它,您实际上是在创建该元素的子类(自定义、变体)。就是这样。

如何使用自定义元素——如何转换它、过滤它、可视化它等等——是一个不同的故事。

关于xml - 可以使用 'role' 属性对 DocBook 元素进行子类化吗?如果是这样,怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11679769/

相关文章:

android - 图像未出现在 HTC One M8 上

android - 选择器与 android :drawable ="@color/transparent" attribute

c++ - xmlReadMemory - 未知 'url' 参数

c++ - 在父类的 vector 上调用子类的方法

python - 将 XML 文件转换为 CSV

android - Android 如何处理未知的 XML 标签?

xml - 使用 XSD 和 xmlns 验证 XML =""

java - "com.sun.xml.bind.xmlDeclaration=false"和 "jaxb.fragment=true"之间有什么区别?

Java - 当涉及到继承、多态、重载和覆盖时调用哪个函数?

子类中未调用 C++ 虚函数