user1985273
user1985273

Reputation: 1967

Add attribute to xml element not allowed in DTD

I have to use a external DTD, that specifies that a certain element can only have id attribute:

<!ELEMENT x (y | z)>
<!ATTLIST x id ID #IMPLIED>

So something like this is valid

<x id="x">...</x>

But if i try something like this:

<x id="x" custom="custom">...</x>

My parser gives me the following error:

Attribute "custom" must be declared for element type "x".

So I understand what the error says and why its happening, but as i said the DTD is external and sadly i cant change it. Is there a workaround or a hack that can use to add my own custom attribute?

Upvotes: 0

Views: 227

Answers (1)

Lie Ryan
Lie Ryan

Reputation: 64845

You can either disable DTD validation in your parser, or try defining internal DTD.

Upvotes: 1

Related Questions