Description
A feature is needed to make it easier for users of our APIs to communicate from the DFDL schema to software called via our APIs such as an InfosetOutputter.
The idea here is to provide an extension property (dfdlx prefix/namespace) which allows a whitespace separated list of name-value pairs to be attached to the runtime data corresponding to a term (element or model group).
This enables the extensible parts of Daffodil, such as an InfosetOutputter or InfosetInputter to get custom behaviors that go beyond what is expressed only with DFDL properties.
An example of a need for this is a data format which is binary data, but which contains embedded strings that are XML. This XML has its own XML Schema.
Suppose one of those strings contains <foo attrib="bar"/> which is XML that cannot be described in a DFDL schema because it uses XML attributes. That piece of XML would normally show up in Daffodil's XML output with escaping like
"<foo attrib="bar"'/>"
That is because the DFDL schema for such data must model these strings as that, strings. So the XML output from Daffodil might altogether look like:
<data> <xmlString><foo attrib="bar"'/></xmlString> </data>
As SAX events, one would get a Start Element for 'data' a Start Element for 'xmlString' with a simple value - the string, which would have to be escaped to be legal in XML - then End Element 'xmlString' and End Element 'data'.
However, an application may want this XML embedded within the XML created by Daffodil's XML infoset outputter, so that the whole data document in XML looks like a uniform piece of XML like:
<data><xmlString><foo attrib="bar"'/></xmlString></data>
The SAX events would want to be Start Element 'data', Start Element 'xmlString', Start Element 'foo' carrying metadata for the attribute 'attrib' with value "bar", End Element 'foo', End Element 'xmlString' and End Element 'data'.
A DFDL schema, with a dfdlx:runtimeProperties can be used to make this happen:
<xs:element name="xmlString" type="xs:string" dfdlx:runtimeProperties="stringAsXML=true" .../>
The runtime ERD for this element will contain a Map[String, String] which would contain this pair "stringAsXML" and "true", which would be ignored by parsing/unparsing, excepting a custom InfosetOutputter that generates SAX XML events could be created that looks at each element ERD to see if it carries this pair. If so it could parse the string as XML and generate the SAX events corresponding to the string, so that the ultimate set of SAX events appears as if the document didn't contain a string of XML, but contained that XML substructure.
The symmetric unparser InfosetOutputter is a little trickier, but the principle is the same, the events for that element ERD would consume all the events corresponding to a full element, convert that element and all its children into a string of textual XML, and use that as the value of the simple type element named 'xmlString'.
This dfdlx:runtimeProperties property is a very general extension hook that can be used to transmit information from the DFDL schema to layer transformers, infoset inputters/outputters, etc.