What is Default Attributes in XML
Posted in
XML | DTD July 06, 2019
In this article you will about default attributes in XML.
Default Attribute value
The default value can be also . These are following
Value |
description |
value |
default value of the attributes |
#REQUIRED |
The value must be required |
#IMPLIED |
The Attribute is not required |
#FIXED value |
Attribute value fixed |
Default Attribute value
DTD:
<!ELEMENT square EMPTY>
<!ATTLIST height width CDATA "0">
Valid XML:
<square height="200" />
|
#REQUIRED
Declaration syntax
<!ATTLIST element-name attribute-name attribute-type #REQUIRED>
Note : This is the declaration of #REQUIRED
Example:
DTD:
<!ATTLIST personal number CDATA #REQUIRED>
Valid XML:
<personal number="677" />
Invalid XML:
<personal/>
|
#IMPLIED
<!ATTLIST element-name attribute-name attribute-type #IMPLIED>
Note : This is only declaration part of #IMPLIED
Example:
DTD:
<!ATTLIST fax no CDATA #IMPLIED>
Valid XML:
<fax no="555-9995588" />
Valid XML:
<fax />
|
#FIXED value
Note: This is only the declaration portion of the #FIXED value
<!ATTLIST element-name attribute-name attribute-type #FIXED "value">
Example :
DTD:
<!ATTLIST company CDATA #FIXED "MCN Private solution">
Valid XML:
< company="MCN private solution" />
Invalid XML:
< company="dotnet factor" />
|
Further Readings
You may also want to read these related articles :
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here