[英]DTD and XML don't match?
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. 我试图使我的DTD和XML完全匹配,并使用验证器检查我的XML和DTD文件是否都匹配。 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.
运行验证器时,出现错误,并且似乎无法理解,我多次检查了XML和DTD。
The Error is: 错误是:
Error Code: -1072898028
Error Reason: Element content is invalid according to the DTD/Schema.
Error Line: 46
My XML file: 我的XML文件:
<?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: 我的DTD文件:
<!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: 由于stackoverflow不会对行进行编号,因此我将提供第46行的屏幕截图:
Thanks in advance guys! 在此先感谢大家!
Your XML is not well-formed. 您的XML格式不正确。 The
<security>
elements are not closed with </security>
end tags prior to the <features>
elements. 在
<features>
元素之前, <security>
元素不会用</security>
结束标记关闭。
Xerces error description: Xerces错误说明:
Unexpected element "features".
意外的元素“功能”。 The content of the parent element type must match "(captcha,login_history,session_management)"
父元素类型的内容必须匹配“(captcha,login_history,session_management)”
The validation error is telling you that the <features>
element is not expected as a child of <security>
. 验证错误告诉您
<features>
元素不应该作为<security>
的子元素。
If you remove the DTD association, you would see an XML parsing error instead: 如果删除DTD关联,则会看到XML解析错误:
The element type "security" must be terminated by the matching end-tag
"</security>"
.元素类型“ security”必须由匹配的结束标记
"</security>"
终止。
Once you close the <security>
elements, it will validate against the DTD and become a well-formed XML document. 一旦关闭
<security>
元素,它将根据DTD进行验证,并成为格式正确的XML文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.