
XML Is Not Injective - code-faster
https://codefaster.substack.com/p/8a68a85d-ad03-4e38-b4fc-b4a9a65788ff
======
compressedgas
I think there might be an error in the examples as the second example does not
have a single root element.

If you need to spot an array vs an element, you have to use a container tag to
express it. This is the same structure as is needed to encode algebraic data
types.

    
    
      element: <a>b0</a>
      array of two elements: <array><a>b0</a><a>b1</a></array>
      array of one element: <array><a>b0</a></array>

~~~
code-faster
Ah, they're meant to be xml fragments, not full xml documents.

In my limited experience I haven't seen people use the <array> container and
the xml parser still works, although it is a good idea.

~~~
compressedgas
It might be something other than <array>. The name depends on the DTD. It does
need a DTD that has the concept of allowing either a single item or a
container.

------
icedchai
This seems like a misunderstanding of XML. XML has no built in concept of
arrays or properties. This is a problem with your application of XML, not XML
itself.

