I do not know the basic in depth …but I am trying to make a tag that print text automatically.This text in the tag is fixed.
I add the text in the attribute value ?? Is it right ??? so if I want to use the tag to print the fixed text in attribute will be in xml like this :
This is my code :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ex
[
<!ELEMENT ex (#PCDATA)>
<!ATTLIST ex value CDATA #FIXED "stack">
]>
<ex />
Result :
it will printed : stack
You’re not really creating a tag (element) with fixed content, but you are creating an attribute with a fixed value.
Your XML instance, including DTD, is correct. This can be verified by using an XPath to display the value of the “value” attribute:
However there isn’t anything “automatic” about printing this value. That will have to be handled by whatever is processing the XML.
I don’t think you can specify a default element value with DTD, but you can with an XML Schema. Read “W3 – OccurrenceConstraints” for more details.