• 0

Issues Validating XML with DTD


Question

Hey guys.  So I've been taking an XML class but I am having trouble getting this file to validate correctly.  Keep getting that it is not well-formed.  Not sure where I am going wrong and can't find a solid answer, not to mention the teacher doesn't seem to know much about what she is teaching.

This is the error I get from xmlvalidation.com:

 

 

Errors in file photos.dtd: 

errorjump.png 13: 3 The markup declarations contained or pointed to by the document type declaration must be well-formed.

 

And when I use Notepad++ XML Tools validation I get:

XML Parsing error at line 31:

Start tag expected, '<' not found

 

Here is the XML:

 

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!--
   New Perspectives on XML
   Tutorial 2
   Case Problem 1

   Catalog of photos from the Our Lady of Bergen Historical Society
   Author: <removed>
   Date:   1/28/2016

   Filename:         photos.xml
   Supporting file:  photos.dtd
-->
<!DOCTYPE catalog SYSTEM "photos.dtd">
 
<catalog type="photos">

   <photo cid="c1748" donatedBy="John Borelli">
      <name metadata="tunis cooper property museum">Tunis R. Cooper property</name>
      <description>
      <![CDATA[ 
         This photo was taken by John Borelli's great-grandfather. It is believed to have been taken around 1830.
         David Demarest originally purchased the site of the chair factory in 1663. This site was under the ownership 
         of the Demarest family until 1758.  The property is listed in the National and New Jersey Registers of Historic Places.
      ]]>
      </description>
      <date>1830 circa</date>
      <images>
         <img src="1748a.jpg" />
         <img src="1748b.jpg" />
      </images>
   </photo>

   <photo cid="c1749" donatedBy="John Borelli">
      <name metadata="tunis cooper property museum">Tunis R. Cooper property</name>
      <description>
      <![CDATA[ 
         A more recent picture of the property taken by the Borelli family.  The property is listed in the 
         National and New Jersey Registers of Historic Places.
      ]]>
      </description>
      <date>1950 circa</date>
      <images>
         <img src="1749a.jpg" />
      </images>
   </photo>

   <photo cid="c1411" donatedBy="Saint Johns Catholic Church">
      <name metadata="saint johns catholic church">Saint Johns Church</name>
      <description>
      <![CDATA[ 
         A more recent picture of the property taken by the Borelli family.  The property is listed in the 
         National and New Jersey Registers of Historic Places.
      ]]>
      </description>      
      <date>1921</date>
   </photo>

   <photo cid="c2003" donatedBy="Linda Choo">
      <name metadata="bergenfield elementary school">Bergenfield School</name>
      <description>
      <![CDATA[ 
         The No. 5 Public School, a.k.a. Bergenfield School
      ]]>
      </description>
      <date>1920 circa</date>
      <images>
         <img src="2003a.jpg" />
         <img src="2003b.jpg" />
      </images>
   </photo>

   <photo cid="c2078" donatedBy="Maria Giodelli">
      <name metadata="coopers pond water">Coopers Pond</name>
      <description>
      <![CDATA[ 
         A favorite spot where we used to go hang out as kids.  The picture shows my brothers Robert and Michael.
      ]]>
      </description>
      <date>May 4, 1941</date>
      <images>
         <img src="2078a.jpg" />
      </images>
   </photo>

   <photo cid="c2079" donatedBy="Linda Uffington">
      <name metadata="watch timekeeping pocket railway">Pocket Watch</name>
      <description>
      <![CDATA[ 
         A more recent picture of the property taken by the Borelli family.  The property is listed in the 
         National and New Jersey Registers of Historic Places.
      ]]>
      </description>
      <date>1870 circa</date>
      <images>
         <img src="2079a.jpg" />
         <img src="2079b.jpg" />
      </images>
   </photo>

   <photo cid="c3233">
      <name metadata="hotel">Bergenfield Hotel</name>
      <description>
      <![CDATA[ 
         The Knollfield Hotel was known as the Bergenfield Hotel.  The property is listed in the 
         National and New Jersey Registers of Historic Places.
      ]]>
      </description>
      <date>circa 1920</date>
   </photo>

   <photo cid="c3433">
      <name metadata="sweeney coal fuel">Sweeney Coal</name>
      <description>
      <![CDATA[ 
         Sweeny Fuel Company located near New Bridge Road and railroad tracks.
      ]]>
      </description>
      <date>1920</date>
      <images>
         <img src="3433a.jpg" />
         <img src="3433b.jpg" />
         <img src="3433c.jpg" />
      </images>
   </photo>

</catalog>

 

And the DTD file:

 

<!--
   New Perspectives on XML
   Tutorial 2
   Case Problem 1

   Catalog of photos from the Our Lady of Bergen Historical Society
   Author: <removed>
   Date:   1/28/2016

   Filename:         photos.dtd
   Supporting File:  photos.xml
-->
<!DOCTYPE catalog [
    <!ELEMENT catalog (photo+)>
    <!ATTLIST type catalog NMTOKEN #REQUIRED>

    <!ELEMENT photo (name, description, date, images?)>
    <!ATTLIST cid photo ID #REQUIRED>
    <!ATTLIST donatedBy photo CDATA #IMPLIED>

    <!ELEMENT name (#PCDATA)>
    <!ATTLIST metadata name NMTOKENS #REQUIRED>

    <!ELEMENT description (#PCDATA)>
    <!ELEMENT date (#PCDATA)>

    <!ELEMENT images (img+)>
    <!ELEMENT img (EMPTY)>
    <!ATTLIST src img CDATA #REQUIRED>
    ]>

Edited by Perfect72
Link to comment
https://www.neowin.net/forum/topic/1287978-issues-validating-xml-with-dtd/
Share on other sites

3 answers to this question

Recommended Posts

  • 0
<!--
   New Perspectives on XML
   Tutorial 2
   Case Problem 1
   Catalog of photos from the Our Lady of Bergen Historical Society
   Author: <removed>
   Date:   1/28/2016
   Filename:         photos.dtd
   Supporting File:  photos.xml
-->
<!DOCTYPE catalog [
    <!ELEMENT catalog (photo+)>
    <!ATTLIST type catalog NMTOKEN #REQUIRED>
    <!ELEMENT photo (name, description, date, images?)>
    <!ATTLIST cid photo ID #REQUIRED>
    <!ATTLIST donatedBy photo CDATA #IMPLIED>
    <!ELEMENT name (#PCDATA)>
    <!ATTLIST metadata name NMTOKENS #REQUIRED>
    <!ELEMENT description (#PCDATA)>
    <!ELEMENT date (#PCDATA)>
    <!ELEMENT images (img+)>
    <!ELEMENT img (EMPTY)>
    <!ATTLIST src img CDATA #REQUIRED>
]>

Should be:

<!--
   New Perspectives on XML
   Tutorial 2
   Case Problem 1
   Catalog of photos from the Our Lady of Bergen Historical Society
   Author: <removed>
   Date:   1/28/2016
   Filename:         photos.dtd
   Supporting File:  photos.xml
-->
<!ELEMENT catalog (photo+)>
<!ATTLIST type catalog NMTOKEN #REQUIRED>
<!ELEMENT photo (name, description, date, images?)>
<!ATTLIST cid photo ID #REQUIRED>
<!ATTLIST donatedBy photo CDATA #IMPLIED>
<!ELEMENT name (#PCDATA)>
<!ATTLIST metadata name NMTOKENS #REQUIRED>
<!ELEMENT description (#PCDATA)>
<!ELEMENT date (#PCDATA)>
<!ELEMENT images (img+)>
<!ELEMENT img (EMPTY)>
<!ATTLIST src img CDATA #REQUIRED>

The doctype is only needed when you put the dtd inline in the xml file.

Source: http://stackoverflow.com/questions/5455394/problem-with-external-referenced-dtd-in-xml

 

Also you're missing quite a few attribute declarations :rofl:

  • 0

Woops, I forgot I did end up removing that after figuring it out, but still keep getting errors. Is it the missing declarations?  I am completely new to XML and like I said, my teacher isn't much help besides just reading passages from the book which I'm not very good at learning with.

  • 0
  On 06/02/2016 at 17:02, Perfect72 said:

Woops, I forgot I did end up removing that after figuring it out, but still keep getting errors. Is it the missing declarations?  I am completely new to XML and like I said, my teacher isn't much help besides just reading passages from the book which I'm not very good at learning with.

Expand  

Your teacher isn't much help teaching you something as defunct as DTD.  Can I ask why you aren't learning XSD instead?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Ah .. lockout for suspicious activity. I bet they uploaded the SanDisk utility detected as malware
    • Microsoft 365 will soon disable outdated authentication protocols for file access by Usama Jawad On a fairly regular basis, Microsoft disables outdated protocols that are used to access its services. In the past few years, the company has deprecated Basic Auth in Exchange Online and cut access to Outlook for third-party apps relying on this protocol. Now, it has decided to get rid of old authentication protocols for file access across Microsoft 365 services. As reported by Bleeping Computer, Microsoft has posted a message on its Microsoft 365 Admin Center. Starting from mid-July 2025, the company will begin disabling legacy authentication protocols used to access files across Microsoft 365 and Office apps, SharePoint, and OneDrive. Essentially, applications or services which use the Relying Party Suite (RPS) or FrontPage Remote Procedure Call (FPRPC) will to perform browser-based authentication to perform open operations on Office files will no longer be able to do so. As expected, this is primarily being done to improve the cybersecurity posture of various services. Microsoft states that RPS can be brute-forced and phished with relative ease as it is fairly outdated. Similarly, FPRPC is typically used for remote web page authoring and it is susceptible to exploitation through various vulnerabilities too. As such, both of these protocols will be disabled by default starting from mid-July 2025, with the rollout of this change targeting completion by August 2025. The Redmond tech giant will update the protocol baseline by default without mandating any licensing changes for customers. In addition, once these modifications are rolled out, Microsoft 365 will require admin consent to get third-party access to files and sites. IT admins can view the guidance available here to configure admin consent workflows. Microsoft says that these changes align with the principles of its Secure Future Initiative (SFI). Earlier today, it announced the rollout of improved security defaults for Windows 365 citing the same reasons too.
    • It does and it can... I took an i3 board and upgraded it to my FX8350... no issues, just put in new drivers over the top that Windows didn't. Not the issue for me, (though I eventually did do a new install from 23H2 to 24H2)... I was on 22H2 at the time. The issue is activation. You may get hit with having to activate again.
  • Recent Achievements

    • First Post
      Fuzz_c earned a badge
      First Post
    • First Post
      TIGOSS earned a badge
      First Post
    • Week One Done
      slackerzz earned a badge
      Week One Done
    • Week One Done
      vivetool earned a badge
      Week One Done
    • Reacting Well
      pnajbar earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      708
    2. 2
      ATLien_0
      284
    3. 3
      Michael Scrip
      218
    4. 4
      +FloatingFatMan
      197
    5. 5
      Steven P.
      130
  • Tell a friend

    Love Neowin? Tell a friend!