Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
There is tag

XML
<messagetype>ichicsr_ASdeerr</messagetype>


And DTD Tag Validation is

HTML
<!ELEMENT messagetype (#PCDATA)>
<!ATTLIST messagetype %lang.att;>


it's only Validating attribute of Node. it possible to Check VALUE of Node
i.e Value Of Node "Messagetype" Should Be -"ichicsr". or Say value of "MessageType" can Not be Null or Empty

Not Valid XML :
XML
<messagetype>ichicsr_ASdeerr</messagetype>

XML
<messagetype></messagetype>


And Valid :
XML
<messagetype>ichicsr</messagetype>

THanks in Advance
Posted
Updated 2-Feb-16 0:19am
v3

1 solution

You cannot do at element level but it is possible at attribute level.


C#
when defining an element in a DTD, there is no way to restrict the text inside the element. you can only tell what other element (child elements) it might contain and their order, or you can tell that the element contains text, or a mixture of the 2. 

so, basically you have 2 options for restricting the <fuel-system>: either declare it as an attribute (<fuel-system type="fuel-injected"/>), or declare children elements <fuel-injected> and <carburated>. the choice between those 2 options depends on what you are trying to describe and what will change depending on the type of fuel-system.

(the grammar for the declaration of an element is defined here)

examples: first option, attributes
<!ELEMENT fuel-system EMPTY>
<!ATTLIST fuel-system (fuel-injected|carburated) #REQUIRED>

second option, child elements
<!ELEMENT fuel-system (fuel-injected|carburated)>
<!ELEMENT fuel-injected ...>
<!ELEMENT carburated ...>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900