简体   繁体   中英

Validating XML with external DTD

Given below are my note.xml and Note.dtd files. I am validating a XML file with external DTD using XMLStarlet from Cygwin. When I give the command

xml val --dtd Note.dtd note.xml

I get

cannot parse DTD file

Can someone help me to rectify this?

note.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE note SYSTEM "Note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

Note.dtd

<!ELEMENT note (to,from,heading,body)>
<!ELEMENT  (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>

Cygwin的命令

Change

<!ELEMENT (#PCDATA)>

to

<!ELEMENT to (#PCDATA)>

and your XML will be valid against your DTD

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM