Primitive data types as XML attribute and element


I’ve been dealing with FHIR for some time now and came across something that irritates me to some extent.

In the normal case elements do not contain any attributes unless they are primitive data types like string, code, etc. In these the element consists of the name of the data type and the attribute value followed by the content.

Additionally I saw that the xml representation of element should look like this.

Next to it Extension looks like this:

Since both Url and Id are primitive data types, it concerns thus elements and they may possess thus also Extensions, how would the XML representation look then? Since they are attributes on the one hand, but they are also elements again.

My guess would be the following:
—<url value ="">

This would mean, however, that one must consider both the case that the Url is contained as attributes in the XML element and that it can be contained as an independent element.
Wouldn’t it have been better to demand in principle that everything must be XML elements and only the primitive data types may contain the XML attribute Value?

This behavior makes parsing the XML much more difficult, because you have to be able to catch and distinguish between the case of primitive data type as attribute and element.

I hope I could formulate my question sufficiently clearly.

Thanks a lot for the answers and Extension.url are special cases, in that extensions are not allowed on them. That’s why they are able to be attributes. But yes, they are special cases. In R4, this is reflected in how they are defined

Thanks for the answer.