问题
Im trying to validate an XML document against a DTD while using the Oxygen XML Editor tool Towards the end of my code, an error message comes with E{XERCES} ENTITY "myent" is not unparsed.
Does anyone know what this error means, and if so how to fix it to make it runs so I can validate the XML?
The parameters are closed and an example of what it looks like is as so.
<authentication board="myent"/>
Any help would be greatly appreciated!
回答1:
What the Xerces error is saying, basically, is that the ENTITY "myent" is not declared as an unparsed entity.
What is most likely the case (I'm guessing since you haven't supplied the DTD) is that the attribute board
is declared as the type ENTITY
. Attributes with the type ENTITY
must match the name of a corresponding unparsed entity that is declared in the DTD.
Attribute type ENTITY
validity constraint from the spec:
Values of type ENTITY MUST match the Name production, values of type ENTITIES MUST match Names; each Name MUST match the name of an unparsed entity declared in the DTD.
Definition of unparsed entity from the spec:
An unparsed entity is a resource whose contents may or may not be text, and if text, may be other than XML. Each unparsed entity has an associated notation, identified by name. Beyond a requirement that an XML processor make the identifiers for the entity and notation available to the application, XML places no constraints on the contents of unparsed entities.
Here's an example of the board
attribute being declared as the type ENTITY
with no corresponding unparsed entity declaration:
<!DOCTYPE authentication [
<!ELEMENT authentication EMPTY>
<!ATTLIST authentication
board ENTITY #REQUIRED>
]>
<authentication board="myent"/>
The above example will generate the error (copied directly from oXygen using my first example below):
E [Xerces] ENTITY "myent" is not unparsed.
If we add the entity declaration (and the notation (NDATA) declaration; see spec), the XML is now valid:
<!DOCTYPE authentication [
<!ELEMENT authentication EMPTY>
<!ATTLIST authentication
board ENTITY #REQUIRED>
<!NOTATION bar SYSTEM "bar">
<!ENTITY myent SYSTEM "FOO" NDATA bar>
]>
<authentication board="myent"/>
来源:https://stackoverflow.com/questions/22411695/trying-to-validate-xml-to-dtd-error-saying-entity-is-not-unparsed