XML:跨越其他元素的里程碑或元素

发布于 2024-08-12 00:14:53 字数 2129 浏览 10 评论 0原文

我正在使用 OSIS(开放圣经信息标准),这是一种用于描述经文和相关文本的 XML 模式。当我第一次查看 XML 示例时,我注意到一些以前在 XML 中从未见过的奇怪之处。主要是关闭的标签,然后是逻辑上属于关闭标签内的内容。查看文档后< /a>,我发现他们将这种类型的标记称为“里程碑”。

在这种情况下,使用它是因为引文可以从一节开始,并在结束之前跨越几节。这看起来像是一个 hack,我必须做一些编码来解析和搜索,并显示 Web 的 XML 部分。虽然我知道这是技术上有效的 XML,但无法[轻松]根据架构验证其正确性,并且标准 XML 解析 API 将无法获取里程碑之间的元素。我相信有更好的方法可以形成这个“标准”。您对这种类型的标记有何看法?我还没有真正找到任何其他关于这种做法的参考,它还用在哪里。有效吗?

从文档中...

XML 中元素的标准形式 是一个开始标签和一个结束标签: ...。用于处理标记 然而,跨越国界的特殊 必须使用表格。它由两个组成 相同的完全空的实例 元素类型:一个标记开始 一个点,一个标记结束 观点。两个空元素标识 他们自己知道哪个是开始 哪一个是结束,并共同识别 由 sID 属性本身 (传统元素的开始) 和一个 eID 属性(结尾 传统元素)、价值观 其中必须匹配。

空元素在 XML 中表示为 最后一个带有“/”的标签 “>”:因此是而不是 或者。以这种方式使用的元素是 通常称为“里程碑”,以及 OSIS 中的那些特定要素 允许这种替代编码是 因此称为“里程碑式”。

这是一个简短的例子......

<verse osisID="Acts.7.2" sID="a72"/>To this he replied:
<speech who=”Stephan”>Brothers and fathers, listen to me! The God of glory appeared
to our father Abraham while he was still in Mesopotamia, before he lived in Haran
<verse eID=”a72”/>

...

<verse osisID="Acts.7.6" sID="a76"/>God spoke to him in this way: <q
type=”embedded” marker=”'”>Your descendants will be strangers in a country not
their own, and they will be enslaved and mistreated four hundred years. <verse
eID="a76"/>
<verse osisID="Acts.7.7" sID="a77"/>But I will punish the nation they serve as
slaves,</q> God said, <q type=”embedded” marker=”'”>and afterward they will come out
of that country and worship me in this place.</q><verse eID="a77"/>

...

<verse osisID="Acts.7.53" sID="a79"/>you who have received the law that was put
into effect through angels but have not obeyed it.
<verse eID="a79"/>
</speech>

I'm working with OSIS (Open Scriptural Information Standard), an XML schema for describing scripture and related text. When I first looked at a sample of the XML I noticed some oddities that I have not seen in XML before. Mainly tags being closed followed by content that would logically belong inside the closed tag. After looking through the documentation, I found that they call this type of markup "Milestones."

In this instance it is being used because a quote can begin in one verse and span several verses before being closed. It seems like a hack and I am going to have to do some coding to parse and search through, and display sections of the XML for the web. While I understand that this is technically valid XML, it can't be verified [easily] against the schema for correctness and standard XML parsing APIs will not be able to grab elements between milestones. I believe there are better ways that this "standard" could have been formed. What are your thoughts on this type of markup? I haven't really found any other references to this practice, where else is it used. Is it valid?

From the documentation...

In XML the normal form of an element
is a start tag and an end tag:
<q>...</q>. For handling markup that
crosses boundaries, however, a special
form must be used. It consists of two
totally empty instances of the same
element type: one to mark the starting
point, and one to mark the ending
point. The two empty elements identify
themselves as to which is the start
and which is the end, and co-identify
themselves by an sID attribute
(the start of the traditional element)
and an eID attribute (the end of
the traditional element), the values
of which must match.

Empty elements are indicated in XML by
a tag with "/" preceding the final
">": thus <q/> rather than <q> or
</q>. Elements used in this way are
commonly called ‘milestones,’ and
those particular elements in OSIS that
permit this alternate encoding are
thus called ‘milestoneable.’

Here is a short example...

<verse osisID="Acts.7.2" sID="a72"/>To this he replied:
<speech who=”Stephan”>Brothers and fathers, listen to me! The God of glory appeared
to our father Abraham while he was still in Mesopotamia, before he lived in Haran
<verse eID=”a72”/>

...

<verse osisID="Acts.7.6" sID="a76"/>God spoke to him in this way: <q
type=”embedded” marker=”'”>Your descendants will be strangers in a country not
their own, and they will be enslaved and mistreated four hundred years. <verse
eID="a76"/>
<verse osisID="Acts.7.7" sID="a77"/>But I will punish the nation they serve as
slaves,</q> God said, <q type=”embedded” marker=”'”>and afterward they will come out
of that country and worship me in this place.</q><verse eID="a77"/>

...

<verse osisID="Acts.7.53" sID="a79"/>you who have received the law that was put
into effect through angels but have not obeyed it.
<verse eID="a79"/>
</speech>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神也荒唐 2024-08-19 00:14:53

该标记没有任何非法之处,至少就 XML 语法而言是如此。

这是一个巧妙的解决方案,解决了必须将文本字符串分成两个重叠方案中的片段的问题。您省略了封闭的标签,因此不可能直观地了解层次结构,但我会假设它在那里,并尝试以逻辑方式组织事物作为叙述。然后需要指出诗句中断的位置,一般来说,它们可以是完全任意的。它们实际上是流程中的点事件(术语:里程碑)。

我唯一不同意的是为诗句设置“开始”和“结束”标记。这会带来潜在的错误,因为无法在 XML 本身内验证开始和结束的括号。我只会使用“开始”标记。当然,这是假设每节经文的结尾对应于另一节经文的开头,或分层部分的结尾。也就是说,两节经文之间不可能有东西。

There's nothing illegal about this markup, at least as far as XML syntax is concerned.

It's a clever solution to the problem of having a string of text that must be broken up into segments in two overlapping schemes. You omitted the enclosing tags so it's impossible to intuit the hierarchical structure, but I will assume it's there and makes some attempt to organize things in a logical manner as a narrative. Then there's the need to indicate where the verse breaks are, and in general they can be totally arbitrary. They are really point-events in the flow (their term: milestones).

The only thing I'd disagree with is having 'start' and 'end' markers for verses. This introduces a potential for errors since the bracketing of start and end can't be validated within XML itself. I'd have used only 'start' markers. This assumes, of course, that the end of every verse corresponds to the start of another, or the end of a hierarchical section. I.e. it's not possible to have something 'between' two verses.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文