外部子集存在XML-DTD内容错误,请求验证指定DTD代码
Let’s work through fixing the issues in your DTD snippet step by step. From what you’ve shared, there are several clear syntax gaps and missing declarations causing validation failures, plus key checks if you’re using an external subset.
Key Issues in Your Provided DTD
Incomplete Element Declaration: The
miastoelement is cut off mid-declaration. Every element needs a fully defined content model. For a plain text element, this should look like:<!ELEMENT miasto (#PCDATA)>Missing Element Declarations: Multiple elements referenced in your DTD aren’t defined anywhere in the snippet:
kraj: Used as a child ofautor_adresbut has no declaration. Add<!ELEMENT kraj (#PCDATA)>to fix this.informacje_o_dokumencieandzatrudnieni: Both are required children of the rootlista_plac_dokumentelement. You need to define their structure—whether they contain plain text or nested elements.zip: This is an alternative tokod_pocztowyinautor_adres, but it’s not declared either. Add<!ELEMENT zip (#PCDATA)>to support this choice.
External Subset Errors: If your full DTD references an external subset (e.g., via
<!ENTITY % external SYSTEM "external.dtd"> %external;), verify:- The file path or URL to the external DTD is correct and accessible.
- The external DTD has valid syntax and no conflicting declarations with your internal subset.
- You’ve properly included the entity reference to pull in the external content.
Corrected DTD Example
Here’s a complete, valid version of your DTD (with placeholder declarations for missing elements—adjust these to match your actual requirements):
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE PERSON [ <!-- Root element --> <!ELEMENT lista_plac_dokument (autor, informacje_o_dokumencie, zatrudnieni)> <!-- Autor-related elements --> <!ELEMENT autor (autor_imię, autor_nazwisko, autor_adres+)> <!ELEMENT autor_imię (#PCDATA)> <!ELEMENT autor_nazwisko (#PCDATA)> <!-- Address elements --> <!ELEMENT autor_adres (ulica, (kod_pocztowy|zip), miasto, kraj)> <!ELEMENT ulica (#PCDATA)> <!ELEMENT kod_pocztowy (#PCDATA)> <!ELEMENT zip (#PCDATA)> <!ELEMENT miasto (#PCDATA)> <!ELEMENT kraj (#PCDATA)> <!-- Document info elements (customize as needed) --> <!ELEMENT informacje_o_dokumencie (tytuł, data_wytworzenia)> <!ELEMENT tytuł (#PCDATA)> <!ELEMENT data_wytworzenia (#PCDATA)> <!-- Employee elements (customize as needed) --> <!ELEMENT zatrudnieni (zatrudniony+)> <!ELEMENT zatrudniony (imię, nazwisko, stanowisko, pensja)> <!ELEMENT imię (#PCDATA)> <!ELEMENT nazwisko (#PCDATA)> <!ELEMENT stanowisko (#PCDATA)> <!ELEMENT pensja (#PCDATA)> ]>
To validate this, create a sample XML document that adheres to this structure and run it through any standard XML/DTD validator. If you still hit external subset errors, double-check the path to your external DTD file and ensure its content is valid.
内容的提问来源于stack exchange,提问作者Johny Doe

