Reputation: 357
I am trying to get my DTD and XML to match perfectly and am using a validator to check if my XML and DTD files are both matching. When I run the validator I am given an error and I cannot seem to make sense of it, I have checked my XML and DTD multiple times.
The Error is:
Error Code: -1072898028
Error Reason: Element content is invalid according to the DTD/Schema.
Error Line: 46
My XML file:
<?xml version="1.0"?>
<!DOCTYPE wcms_ontology SYSTEM "wcms_ontology.dtd">
<wcms_ontology>
<wcms>
<name>Joomla!</name>
<homepage>http://www.joomla.org/</homepage>
<version>2.5.4</version>
<versiondate>5/2/2012</versiondate>
<license>Open Source</license>
<cost>Free</cost>
<type>General Purpose</type>
<system_requirements>
<server_env>CGIM</server_env>
<operating_system>Any</operating_system>
<programming_language>PHP</programming_language>
</system_requirements>
<security>
<captcha>Add-on</captcha>
<login_history>Yes</login_history>
<session_management>Yes</session_management>
</security>
<features>
<commercial_support>Yes</commercial_support>
<drag_and_drop>No</drag_and_drop>
<load_balancing>Yes</load_balancing>
<page_caching>Yes</page_caching>
</features>
</wcms>
<wcms>
<name>WordPress</name>
<homepage>http://www.wordpress.org/</homepage>
<version>3.3.2</version>
<versiondate>5/29/2012</versiondate>
<license>Open Source</license>
<cost>Free</cost>
<type>General Purpose</type>
<system_requirements>
<server_env>None</server_env>
<operating_system>Any</operating_system>
<programming_language>PHP</programming_language>
</system_requirements>
<security>
<captcha>Add-on</captcha>
<login_history>Add-on</login_history>
<session_management>Add-on</session_management>
<features>
<commercial_support>Yes</commercial_support>
<drag_and_drop>Yes</drag_and_drop>
<load_balancing>Yes</load_balancing>
<page_caching>Add-on</page_caching>
</features>
</wcms>
<wcms>
<name>Alfresco</name>
<homepage>http://www.alfresco.com/products/</homepage>
<version>Enterprise + Community</version>
<versiondate>2/20/2008</versiondate>
<license>Open Source</license>
<cost>$15000/year</cost>
<type>Document Management</type>
<system_requirements>
<server_env>J2EE</server_env>
<operating_system>Any</operating_system>
<programming_language>Java</programming_language>
</system_requirements>
<security>
<captcha>No</captcha>
<login_history>Yes</login_history>
<session_management>Limited</session_management>
<features>
<commercial_support>Yes</commercial_support>
<drag_and_drop>Limited</drag_and_drop>
<load_balancing>Yes</load_balancing>
<page_caching>Limited</page_caching>
</features>
</wcms>
<wcms>
<name>Kentico CMS for ASP.NET</name>
<homepage>http://www.kentico.com</homepage>
<version>7</version>
<versiondate>11/30/2012</versiondate>
<license>Closed Source</license>
<cost>$2000</cost>
<type>Document Management</type>
<system_requirements>
<server_env>IIS/.Net</server_env>
<operating_system>Windows Only</operating_system>
<programming_language>C#</programming_language>
</system_requirements>
<security>
<captcha>Yes</captcha>
<login_history>Yes</login_history>
<session_management>Yes</session_management>
<features>
<commercial_support>Yes</commercial_support>
<drag_and_drop>Yes</drag_and_drop>
<load_balancing>Yes</load_balancing>
<page_caching>Yes</page_caching>
</features>
</wcms>
<wcms>
<name>TYPO3 Enterprise CMS</name>
<homepage>http://www.typo3.org</homepage>
<version>6.1</version>
<versiondate>2/03/2014</versiondate>
<license>Open Source</license>
<cost>Free</cost>
<type>Enterprise</type>
<system_requirements>
<server_env>Apache</server_env>
<operating_system>Any</operating_system>
<programming_language>PHP</programming_language>
</system_requirements>
<security>
<captcha>Add-on</captcha>
<login_history>Yes</login_history>
<session_management>Yes</session_management>
<features>
<commercial_support>Yes</commercial_support>
<drag_and_drop>Add-on</drag_and_drop>
<load_balancing>Yes</load_balancing>
<page_caching>Yes</page_caching>
</features>
</wcms>
</wcms_ontology>
My DTD file:
<!ELEMENT wcms_ontology (wcms+)>
<!ELEMENT wcms (name, homepage, version, versiondate, license, cost, type, system_requirements, security, features)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT homepage (#PCDATA)>
<!ELEMENT version (#PCDATA)>
<!ELEMENT versiondate (#PCDATA)>
<!ELEMENT license (#PCDATA)>
<!ELEMENT cost (#PCDATA)>
<!ELEMENT type (#PCDATA)>
<!ELEMENT system_requirements (server_env, operating_system, programming_language)>
<!ELEMENT server_env (#PCDATA)>
<!ELEMENT operating_system (#PCDATA)>
<!ELEMENT programming_language (#PCDATA)>
<!ELEMENT security (captcha, login_history, session_management)>
<!ELEMENT captcha (#PCDATA)>
<!ELEMENT login_history (#PCDATA)>
<!ELEMENT session_management (#PCDATA)>
<!ELEMENT features (commercial_support, drag_and_drop, load_balancing, page_caching)>
<!ELEMENT commercial_support (#PCDATA)>
<!ELEMENT drag_and_drop (#PCDATA)>
<!ELEMENT load_balancing (#PCDATA)>
<!ELEMENT page_caching (#PCDATA)>
Since stackoverflow doesn't number the lines, I'll provide a screenshot of line 46:
Thanks in advance guys!
Upvotes: 1
Views: 1844
Reputation: 66783
Your XML is not well-formed. The <security>
elements are not closed with </security>
end tags prior to the <features>
elements.
Xerces error description:
Unexpected element "features". The content of the parent element type must match "(captcha,login_history,session_management)"
The validation error is telling you that the <features>
element is not expected as a child of <security>
.
If you remove the DTD association, you would see an XML parsing error instead:
The element type "security" must be terminated by the matching end-tag
"</security>"
.
Once you close the <security>
elements, it will validate against the DTD and become a well-formed XML document.
Upvotes: 4