`< seg>`和`< span>`之间有什么区别 [英] What's the difference between `<seg>` and `<span>`

查看:41
本文介绍了`< seg>`和`< span>`之间有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< seg> 格式的XML和英语圣经 Christodouloupoulos和Steedman的大规模平行圣经语料库中

<?xml version="1.0" ?>
<cesDoc version="4">
    …
    <text>
        <body id="Bible" lang="en">
            <div id="b.GEN" type="book">
                <div id="b.GEN.1" type="chapter">
                    <seg id="b.GEN.1.1" type="verse">
                        In the beginning God created the heaven and the earth.
                    </seg>
                    <seg id="b.GEN.1.2" type="verse">
                        And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.
                    </seg>
                    …

以及NIV英语圣经中的另一本书,位于圣经门户,这是他们从中获取大部分文字的地方:

and the other from the NIV English Bible at Bible Gateway, which is where they got most of their texts from:

<p class="chapter-1">
    <span id="en-NIV-27932" class="text Rom-1-1">
        <span class="chapternum">1&nbsp;</span>
        Paul, a servant of Christ Jesus, called to be an apostle and set apart for the gospel of God—
    </span> 
    <span id="en-NIV-27933" class="text Rom-1-2">
        <sup class="versenum">2&nbsp;</sup>the gospel he promised beforehand through his prophets in the Holy Scriptures
    </span> 
    …

在HTML中,似乎< span> 可以代替< seg> ,除了HTML在; span> .哦,这些章节在< div> 中.因此,它不是一对一的.

In the HTML, a it seems a <span> can replace a <seg>, except that the HTML has added verse numbers in <span>. Oh, and the chapters are in <div>. So it's not one-to-one.

当然,我意识到HTML和XML是不同的,并且这仅仅是一种并列;我确定那里还有其他人.但是我将需要能够将XML显示为HTML,并且我不想激怒 doctype 神.因此,从概念上讲,< seg> &span> 的目的,意义和用法有何不同?

Of course, I realize that HTML and XML are different, and this is only one juxtaposition; I'm sure there are others out there. But I'm going to need to be able to display XML as HTML, and I don't want to anger the doctype gods. So, conceptually, how is <seg> different from <span> in purpose, meaning and usage?

更新:@ jim-garrison,说我将需要阅读模式来理解XML,但是我对此也很陌生.特别是,我确实找到了一些TEI为< seg> 提供的具有官方外观的文档,这使我认为它的用途不止是任意的,但我不知道如何解释该文档.它应该给我们比吉姆已经写的更具体的答案吗?

Update: @jim-garrison, says I'm going to need to read the schema to understand the XML, but I'm a neophyte at that, too. In particular, I did find some official-looking documentation for <seg> by TEI that makes me think it's use is a little more than arbitrary, but I have no idea how to interpret this documentation. Should it give us a more specific answer than what Jim has already written?

推荐答案

XML和HTML之间的区别通常是XML中可以存在的标签列表由DTD或XML Schema定义,并且标签表示文档语义,而不是演示.因此标签可以命名为任何东西.在HTML中,标记集通常是预定义的,就好像存在一个预先存在的HTML DTD或架构一样,但是HTML是 not XML,并且不遵循XML的所有规则.尽管从某种意义上说,HTML与XML(SGML)源自同一父级,并且两者在表面上非常相似,但它们绝对不是一回事.

The difference between XML and HTML generally is that the list of tags that can be present in XML is defined by a DTD or XML Schema, and tags represent document semantics and not presentation. So tags can be named anything. In HTML the set of tags is generally predefined, as if there was a pre-existing HTML DTD or schema, but HTML is not XML and doesn't follow all the rules of XML. While HTML was in some sense derived from the same parent as XML (SGML), and the two are superficially very similar, they are most definitely NOT the same thing.

您的特定问题的答案是XML的编写者选择使用名为< seg> ("segment"?)的标记来表示广义的文本字符串,而属性则提供了附加的语义信息.有关更多详细信息,您将需要找到控制XML内容的DTD或XML模式,并阅读其附带的文档.

The answer to your specific question is that the writers of the XML chose to use a tag named <seg> ("segment"?) to represent generalized strings of text, with attributes providing additional semantic information. For more details you'll need to find the DTD or XML schema that governs the content of the XML and read the documentation that goes with it.

但是我将需要能够将XML显示为HTML,并且我不想激怒文档类型的上帝.那么,从概念上讲,它与目的,含义和用法有何不同?

But I'm going to need to be able to display XML as HTML, and I don't want to anger the doctype gods. So, conceptually, how does different from in purpose, meaning and usage?

在这里您将使用XSLT将输入的XML 转换成有效的HTML.为了弄清楚如何进行转换,您将需要了解所有可能出现的标签的完整语义(同样,请参见DTD/Schema的文档)并确定数据的可视表示形式.对于应如何转换< seg> ",没有答案.这完全取决于您对演示的要求.一种可能的转换将< seg> 标签转换为&span> ,但是可能取决于某些属性的值( type ="verse" 与其他类型).甚至可能取决于输出媒体(台式机,平板电脑,手机,手表,...?)

This is where you will use XSLT to transform the input XML into valid HTML. To figure out how to do that transformation you will need to know the full semantics of all the tags that can appear (again, go to the documentation for the DTD/Schema) and decide on a visual representation for the data. There's no one answer to "how should a <seg>" be transformed. That's up to your requirements regarding presentation. One possible transformation converts <seg> tags to <span>, but that may depend on the value of certain attributes (type="verse" vs some other type). It might even differ depending on output medium (desktop vs tablet vs phone vs watch vs ...?)

从XML转换为HTML之后,您就离开了Doctype神的领域,他们对您的工作不再感兴趣:-)那里有一系列完全不同的神灵,例如CSS-Cthulhu,Javascript-Janai'ngo(等等),他会很高兴让您的生活痛苦不堪.

Once you convert from XML to HTML you have left the realm of the Doctype gods and they have no interest in what you do :-) There's a whole different set of deities such as CSS-Cthulhu, Javascript-Janai'ngo (look it up), et al who will take great pleasure making your life miserable.

这篇关于`&lt; seg&gt;`和`&lt; span&gt;`之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆