且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

`< seg>`和`< span>`之间有什么区别

更新时间:2023-02-19 15:23:38

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.