Hi Folks,
There is an Apache technology called NiFi. It is used to distribute data. [1]
A feature of NiFi is that a NiFi application will automatically generate metadata about the data it ingests. The metadata is formatted as XML, which has this form:
<properties>
<entry key="A">A content</entry>
<entry key="B">B content</entry>
<entry key="C">C content</entry>
<entry key="D">D content</entry>
...
</properties>
Each item of metadata is represented with an <entry> element. The “key” attribute contains the name of the metadata item, and the value of the <entry> element contains the value of the metadata item.
What are the advantages and disadvantages of this type of XML design?
Advantages:
- The markup is simple and regular: just a root element and one element that is repeated over and over. So, it’s easy to understand and use.
- The design is highly extensible: to represent new metadata items, simply add more <entry> elements. No changes to the markup (i.e., no change to the XML Schema).
Disadvantages:
There is likely to be a constraint (relation) between an <entry>’s @key value and the <entry>’s content:
Examples of co-constraints:
- “If @key has the value A, then the content must be a string restricted to 20 characters and must have this pattern: regex”
- “If @key has the value B, then the content must be a member of this enumeration list: foo, bar, blah”
- And so on.
XML Schema 1.0 doesn’t support co-constraints. [2] So, you need to supplement XSD with Schematron. In some environments, it is simply not feasible to perform both XML Schema validation and Schematron validation.
Consequently, co-constraints go unexpressed. The design hampers the ability to use XML Schema’s powerful constraint mechanisms. Thus, the design hampers the ability to perform powerful error-checking.
Do you agree with these advantages and disadvantages? Are there other advantages and disadvantages?
/Roger
[2] Yes, I know that XSD 1.1 supports co-constraints, but (I assert, without evidence that) there is lesser support for XSD 1.1 than for XSD 1.0 or for Schematron.