Thanks Gerald for this great XML Editor. I've spent all of yesterday sorting through the cruft on SourceForge and yours is the best running. Heck, it's one of the few that hasn't totally croaked when opening a 10Mb file.
However,I'm having a bit of a problem with DTDs. I posted in an existing thread yesterday but thought I would start my own since I'm using the newest version (1.1.0.7) and there some additional behavior I was wondering about. Thanks for any help you can give me.
Here's the test XML file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ONIXmessage SYSTEM "http://www.editeur.org/onix/2.1/short/onix-international.dtd">
<ONIXmessage>
</ONIXmessage>
I get the following error when trying to validate it:
Error at line 3, column 13: Validation failed: no DTD found !
If I change the path to just "onix-international.dtd" and make sure the DTD file is in the same directory then I get this warning:
Error at line 4, column3: No declaration for element ONIXmessage
What I would expect to happen here is that it would complain about missing elements in ONIXmessage.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The first error just means that the DTD can't be found because the parser can't establish a connection to web-based resources.
The second error is caused by missing files. The DTD you are linking to links to another (http://www.editeur.org/onix/2.1/short/short.elt) which in turn suggests there are 24 files in total. Unless you have all of the relevant files you will continue to get strange errors.
I fetched a copy of the short Onix DTD with supporting files from the web, but it's different from the file(s) you've got (the archive I downloaded was called onixDTD11.zip).
If you copy the files into a folder containing your XML source file, you get a meaningful validation error:
Error at line 4, column 3: Element ONIXmessage content does not follow the DTD, expecting ((((m172 | m173) , m174?) | m174) , m175 , m176? , m177? , m178? , m179? , m180? , m181? , m182 , m183? , m184? , m185? , m186? , m187? , m188? , m193? , product+), got ()
Regards,
Gerald
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the response Gerald. I was able to download the all the files locally and get it to work as you did.
Is it a reasonable feature request that the parser can use web-based resources? If not, you might want to indicate this somewhere. Maybe when you validate and the string starts with http: you give them a pop-up warning.
Thanks again,
Bryan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, absolutely. The other parser I'm using (libxml) has a neat parameter for this (a simple 'nonet' flag that's false or true), but the solution seems to be less obvious in Xerces-C (which I'm using for XSD and DTD validation).
The second point I'd make is that typically you wouldn't want the editor to fetch resources over the net. The typical solution would be to use a PUBLIC identifier and map that identifier to a local copy of the DTD.
See C:\Program Files\xml copy editor\catalog\catalog for details.
Best,
Gerald
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yep, just checked using your file and it seems to work fine with this setting enabled. (The reason I didn't enable it by default is the parser has been known to lock the parser for ages while it's trying to retrieve the relevant files.)
Local copies linked via the catalog are definitely the way to go.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I too am having trouble with stuff in my DTD not being recognized.
I am very new to XML and am just trying to do the exercises in a book.
On the below XML, I get the error "Entity danny-description not defined".
I also tried adding the following line to the catalog file:
<public publicId="-//Beginning XML//DTD Contact Example//EN" uri="file:///d:documents%20and%20settings/mzkx19/my%20documents/training/contacts5.dtd"/>
Here is my DTD:
<!ELEMENT contacts (contact*)>
<!ATTLIST contacts version CDATA #FIXED "1.0">
<!ATTLIST contacts source CDATA #IMPLIED>
<!ELEMENT contact (name, location, phone, knows, description)>
<!ELEMENT name (first+, middle?, last)>
<!ATTLIST contact person ID #REQUIRED>
<!ATTLIST contact tags NMTOKENS #IMPLIED>
<!ELEMENT name (first+, middle?, last)>
<!ELEMENT first (#PCDATA)>
<!ELEMENT middle (#PCDATA)>
<!ELEMENT last (#PCDATA)>
<!ELEMENT description (#PCDATA | em | strong | br)*>
<!ELEMENT em (#PCDATA)>
<!ELEMENT strong (#PCDATA)>
<!ELEMENT br EMPTY>
<!ENTITY source-text "The source of this contacts list is Beginning XML 4E">
<!ENTITY address-unknown "The address for this location is "Unknown"">
<!ENTITY empty-gps "<latitude></latitude><longitude></longitude>">
<!ENTITY jeff-description PUBLIC
"-//Beginning XML//Jeff Description//EN" "jeff.txt">
<!ENTITY david-description PUBLIC
"-//Beginning XML//David Description//EN" "david.txt">
<!ENTITY danny-description PUBLIC
"-//Beginning XML//Danny Description//EN" "danny.txt">
<!ENTITY % DefaultPhoneKind '"Home"'>
Here are my external files:
jeff.txt:
Jeff is a developer & author for Begining XML <em>4th edition</em> © 2006
Wiley Publishing.<br/>Jeff <strong>loves</strong> XML!
david.txt:
Senior Technical Consultant for CGI
danny.txt:
<description>A Semantic Web developer and technical author specializing in cutting-
edge technologies.</description>
Any help anyone can give would be greatly appreciated.
Thanks,
Jim Shaw
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Jim, only had time to look at your document briefly, but there seem to be some problems in the DTD. The first error that was flagged up is that name is defined twice.
Validation is handled by heavyweight parsers (Xerces-C and RELAX NG) so validation errors tend to be genuine. (This isn't to say that the application isn't at fault in the way it's calling these parsers, but the aim has been simply to let the parsers do their work.)
I'm hoping to find some time to investigate your file properly, but I can't make any promises right now :-(
Best wishes,
Gerald
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I see that the name element is defined twice. I added that after I got the error, when I was grasping at straws, not noticing that it was already there above the ATTLIST lines.
So, at first glance, you think that my DTD file is being found but it's got some errors?
Thanks again,
Jim
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Gerald for this great XML Editor. I've spent all of yesterday sorting through the cruft on SourceForge and yours is the best running. Heck, it's one of the few that hasn't totally croaked when opening a 10Mb file.
However,I'm having a bit of a problem with DTDs. I posted in an existing thread yesterday but thought I would start my own since I'm using the newest version (1.1.0.7) and there some additional behavior I was wondering about. Thanks for any help you can give me.
Here's the test XML file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ONIXmessage SYSTEM "http://www.editeur.org/onix/2.1/short/onix-international.dtd">
<ONIXmessage>
</ONIXmessage>
I get the following error when trying to validate it:
Error at line 3, column 13: Validation failed: no DTD found !
If I change the path to just "onix-international.dtd" and make sure the DTD file is in the same directory then I get this warning:
Error at line 4, column3: No declaration for element ONIXmessage
What I would expect to happen here is that it would complain about missing elements in ONIXmessage.
Hi Bryan
The first error just means that the DTD can't be found because the parser can't establish a connection to web-based resources.
The second error is caused by missing files. The DTD you are linking to links to another (http://www.editeur.org/onix/2.1/short/short.elt) which in turn suggests there are 24 files in total. Unless you have all of the relevant files you will continue to get strange errors.
I fetched a copy of the short Onix DTD with supporting files from the web, but it's different from the file(s) you've got (the archive I downloaded was called onixDTD11.zip).
If you copy the files into a folder containing your XML source file, you get a meaningful validation error:
Error at line 4, column 3: Element ONIXmessage content does not follow the DTD, expecting ((((m172 | m173) , m174?) | m174) , m175 , m176? , m177? , m178? , m179? , m180? , m181? , m182 , m183? , m184? , m185? , m186? , m187? , m188? , m193? , product+), got ()
Regards,
Gerald
Thanks for the response Gerald. I was able to download the all the files locally and get it to work as you did.
Is it a reasonable feature request that the parser can use web-based resources? If not, you might want to indicate this somewhere. Maybe when you validate and the string starts with http: you give them a pop-up warning.
Thanks again,
Bryan
Yes, absolutely. The other parser I'm using (libxml) has a neat parameter for this (a simple 'nonet' flag that's false or true), but the solution seems to be less obvious in Xerces-C (which I'm using for XSD and DTD validation).
The second point I'd make is that typically you wouldn't want the editor to fetch resources over the net. The typical solution would be to use a PUBLIC identifier and map that identifier to a local copy of the DTD.
See C:\Program Files\xml copy editor\catalog\catalog for details.
Best,
Gerald
Bryan, I've just been through the source of 1.1.0.7 and I wonder if there's a setting already that will enable internet access for DTD validation.
Have you tried activating 'Enable network access for DTD validation'? (Under Edit>Preferences in Linux, Tools>Options in Windows.)
Best,
Gerald
Yep, just checked using your file and it seems to work fine with this setting enabled. (The reason I didn't enable it by default is the parser has been known to lock the parser for ages while it's trying to retrieve the relevant files.)
Local copies linked via the catalog are definitely the way to go.
Ah, quite right; sorry for not seeing that myself. Thanks for pointing that out.
Bryan
I too am having trouble with stuff in my DTD not being recognized.
I am very new to XML and am just trying to do the exercises in a book.
On the below XML, I get the error "Entity danny-description not defined".
I also tried adding the following line to the catalog file:
<public publicId="-//Beginning XML//DTD Contact Example//EN" uri="file:///d:documents%20and%20settings/mzkx19/my%20documents/training/contacts5.dtd"/>
Here is my XML:
<?xml version="1.0"?>
<!DOCTYPE contacts PUBLIC "-//Beginning XML//DTD Name Example//EN" "D:/Documents%20and%20Settings/mzkx19/My%20Documents/Training/contacts5.dtd">
<contacts source="" version="1.0">
<contact person="Jeff_Rafter" tags="author xml poetry">
<name>
<first>Jeff</first>
<first>Craig</first>
<last>Rafter</last>
</name>
<location>
<address>Redlands, CA, USA</address>
<latitude>34.031892</latitude>
<longitude>117.207642</longitude>
</location>
<phone kind="Home">001-909-555-1212</phone>
<knows contacts="David_Hunter Danny_Ayers"></knows>
<description>&jeff-description;</description>
</contact>
<contact person="David_Hunter" tags="author consultant CGI">
<name>
<first>David</first>
<last>Hunter</last>
</name>
<location>
<address>&address-unknown;</address>
&empty-gps;
</location>
<phone kind="Work">416 555 1212</phone>
<knows contacts="Jeff_Rafter Danny_Ayers"></knows>
<description>&david-description;</description>
</contact>
<contact person="Danny_Ayers" tags="author semantics animals">
<name>
<first>Daniel</first>
<middle>John</middle>
<last>Ayers</last>
</name>
<location>
<latitude>43.847156</latitude>
<longitude>10.50808</longitude>
<address>Mozanella, 7 Castiglione di Garfagnana, 55033 Lucca Italy</address>
</location>
<phone>+39-0555-11-22-33-</phone>
<knows contacts="Jeff_Rafter David_Hunter"></knows>
&danny-description;
</contact>
</contacts>
Here is my DTD:
<!ELEMENT contacts (contact*)>
<!ATTLIST contacts version CDATA #FIXED "1.0">
<!ATTLIST contacts source CDATA #IMPLIED>
<!ELEMENT contact (name, location, phone, knows, description)>
<!ELEMENT name (first+, middle?, last)>
<!ATTLIST contact person ID #REQUIRED>
<!ATTLIST contact tags NMTOKENS #IMPLIED>
<!ELEMENT name (first+, middle?, last)>
<!ELEMENT first (#PCDATA)>
<!ELEMENT middle (#PCDATA)>
<!ELEMENT last (#PCDATA)>
<!ELEMENT location (address | (latitude, longitude))*>
<!ELEMENT address (#PCDATA)>
<!ELEMENT latitude (#PCDATA)>
<!ELEMENT longitude (#PCDATA)>
<!ELEMENT phone (#PCDATA)>
<!ATTLIST phone kind (Home | Work | Cell | Fax) %DefaultPhoneKind;>
<!ELEMENT knows EMPTY>
<!ATTLIST knows contacts IDREFS #IMPLIED>
<!ELEMENT description (#PCDATA | em | strong | br)*>
<!ELEMENT em (#PCDATA)>
<!ELEMENT strong (#PCDATA)>
<!ELEMENT br EMPTY>
<!ENTITY source-text "The source of this contacts list is Beginning XML 4E">
<!ENTITY address-unknown "The address for this location is "Unknown"">
<!ENTITY empty-gps "<latitude></latitude><longitude></longitude>">
<!ENTITY jeff-description PUBLIC
"-//Beginning XML//Jeff Description//EN" "jeff.txt">
<!ENTITY david-description PUBLIC
"-//Beginning XML//David Description//EN" "david.txt">
<!ENTITY danny-description PUBLIC
"-//Beginning XML//Danny Description//EN" "danny.txt">
<!ENTITY % DefaultPhoneKind '"Home"'>
Here are my external files:
jeff.txt:
Jeff is a developer & author for Begining XML <em>4th edition</em> © 2006
Wiley Publishing.<br/>Jeff <strong>loves</strong> XML!
david.txt:
Senior Technical Consultant for CGI
danny.txt:
<description>A Semantic Web developer and technical author specializing in cutting-
edge technologies.</description>
Any help anyone can give would be greatly appreciated.
Thanks,
Jim Shaw
Hi Jim, only had time to look at your document briefly, but there seem to be some problems in the DTD. The first error that was flagged up is that name is defined twice.
Validation is handled by heavyweight parsers (Xerces-C and RELAX NG) so validation errors tend to be genuine. (This isn't to say that the application isn't at fault in the way it's calling these parsers, but the aim has been simply to let the parsers do their work.)
I'm hoping to find some time to investigate your file properly, but I can't make any promises right now :-(
Best wishes,
Gerald
Thanks Gerald!
I see that the name element is defined twice. I added that after I got the error, when I was grasping at straws, not noticing that it was already there above the ATTLIST lines.
So, at first glance, you think that my DTD file is being found but it's got some errors?
Thanks again,
Jim