Can two xsi:type attributes exist in the same element?

106 Views Asked by At

Within XML there exits elements and attributes. There is a special attribute called xsi:type. Can an element have two xsi:type declarations? Example using Dublin Core.

Element Example

 <dc:date>1091</dc:date>

Attribute Example

 <dc:date xsi:type="dcterms:dateCopyrighted">2022</dc:date>

Question: Is the following Valid?

 <dc:date xsi:type="dcterms:dateCopyrighted" xsi:type:="dcterms:W3CDTF">2012-11-11</dc:date>

I've looked in various W3C documents and various XML books. I can't find anyone talking about two instances of xsi:type. My suspicion is that the second type will overwrite the first especially if the two values are in the same namespace as is provided in the question example.

1

There are 1 best solutions below

0
On BEST ANSWER

No, there cannot be two xsi:type attributes on the same element because XML in general prohibits any two attributes from having the same name:

3.1 Start-Tags, End-Tags, and Empty-Element Tags

Well-formedness constraint: Unique Att Spec

An attribute name must not appear more than once in the same start-tag or empty-element tag.

See also