I try to validate some xml data with a dtd. For that I have to use libxml2. The produced xml data looks like this:
<?xml version="1.0"?>
<root>
<vent id="1">
<usb_device_id>1</usb_device_id>
<usb_device_channel>2</usb_device_channel>
<vent_box_id>3</vent_box_id>
<vent_box_channel>4</vent_box_channel>
</vent>
</root>
My dtd looks like this:
<!ELEMENT root (vent) >
<!ELEMENT vent (usb_device_id, usb_channel, vent_box_id, vent_box_channel) >
<!ATTLIST vent id (ID) #REQUIRED >
<!ELEMENT usb_device_id (CDATA) >
<!ELEMENT usb_channel (CDATA) >
<!ELEMENT vent_box_id (CDATA) >
I use http://xmlsoft.org/html/libxml-valid.html#xmlValidateDtd on the parsed tree. With this setup I get the error message:
element vent: validity error : Value "1" for attribute id of vent is not among the enumerated set
Where I am wrong? Thanks in advance...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.