What terms are used to differentiate the two xml forms, “<element></element>” and “<element/>”?

softwareengineering.stackexchange https://softwareengineering.stackexchange.com/questions/333590

質問

I'm writing a boolean that will toggle between these two forms for writing markup into my strings, but I do not know what I should name my boolean.

bool setMarkupForm(bool markupForm); 

Is not obvious enough to me to tell me what it is doing. What terms are used to differentiate between:

<element></element>

and

<element/>

?

役に立ちましたか?

解決

In Extensible Markup Language (XML) 1.1 (Second Edition) Section 3.1 Start-Tags, End-Tags, and Empty-Element Tags, it's called an "empty-element tag". If you were using XML and needed the formal term, this is the one that I'd use.

However, other markup languages do use other terms for the same concept.

In XHTML™ 1.0 The Extensible HyperText Markup Language (Second Edition) Appendix C HTML Compatibility Guidelines Section C.2 (and later sections), it is called the "minimized tag syntax".

In HTML: The Markup Language (an HTML language reference) Section 4.3 Elements, they are referred to as "void elements".

I've also heard the term "self-closing tag" used. This term is also used in HTML5 A vocabulary and associated APIs for HTML and XHTML Section 8.2.4.43 Self-closing start tag state along with many other sources.

Any of these other terms may be used by someone who is coming from a different background and may not know the term as it's defined in the specification and formal documentations for your particular language.

Mark Byers answer on Stack Overflow to a similar question provides more information about these terms.

ライセンス: CC-BY-SA帰属
所属していません softwareengineering.stackexchange
scroll top