Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
198 views
in Technique[技术] by (71.8m points)

Is an xml attribute without a value, 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...