I want to have an XML attribute without any value, which simply has one meaning when it exists or does not exist.
Is that valid?
I want to have an XML attribute without any value, which simply has one meaning when it exists or does not exist.
Is that valid?
An attribute must be specified with the following syntax:
Name Eq AttValue
where Name is a legal XML name, Eq is = optionally preceded or followed by whitespace, and AttValue is a legal attribute value.
This definition is true for both XML 1.0 and XML 1.1.
If you are trying to specify an attribute as below:
<car owned/>
then no, that is not valid. If you are trying to specify it this way:
<car owned=""/>
then yes, that is valid.
No.
Boolean attributes in XML are of the form foo="foo"
.
Even in SGML, you must provide the value, (it is the name, =
and quotes that you can omit, which is why you have things like <select multiple>
in HTML).
<OPTION selected>
instead of <OPTION selected="selected">
– w3.org/TR/html4/appendix/notes.html#sgmlfeatures –
Heptode selected
is the value not the name of the attribute (HTML happens to only use values which are the same as the name for boolean attributes). –
Anchorage <car owned />
) is used by Schema.org and "microdata". I guess this just underscores that HTML is not valid XML, but is it valid SGML (i.e. <div> is defined with an attribute Itemscope
that can only take the value "itemscope"
? schema.org/docs/gs.html#microdata_why –
Feudatory You can have an attribute whose only permitted value is the empty string, "". I'm not sure it's good design, though; I would normally suggest a boolean attribute with values true/false, and a default value of false.
© 2022 - 2024 — McMap. All rights reserved.
attribute=""
: #184514 – Fore