Serusar
Serusar

Reputation: 57

Can XML DTD force different values for two attributes on same element?

Is there a way in XML DTD to force two attributes of the same element to have different values?

I'm writing an XML application representing a graph, using DTD and not XML Schema.

I declared the element Link, having two attributes host1 and host2 referring to the attribute hostName of the Host element with IDREF.

I would like to add a kind of constraint (if any) to forbid host1 and host2 having the same value (referring to the same host).

Upvotes: 1

Views: 262

Answers (1)

kjhughes
kjhughes

Reputation: 111541

No, DTD can't express that constraint. Other options include:

  • XSD
  • Schematron [Credit: Thanks, @C.M.Sperberg-McQueen]
  • Application-level validation

Upvotes: 2

Related Questions