This sort of thing is used in an update of the mil-std-2045 schema.
<xs:group name="tString50">
|
<xs:sequence>
|
<xs:element name="value" type="xs:string" dfdl:lengthKind="pattern"
|
dfdl:lengthPattern="[^\x7F]{0,49}(?=\x7F)|.{50}" />
|
<xs:sequence
|
dfdl:terminator="{if (fn:string-length(./value) eq 50) then '%ES;' else '%DEL;'}" />
|
<!-- can replace %ES with WSP* if ES doesn't work -->
|
</xs:sequence>
|
</xs:group>
|
If you look at the second sequence where there is an expression for the terminator, in a test there are exactly 50 chars, so it correctly decides the terminator is %ES;, but fails to behave properly at runtime in this case. Note that the format is NOT delimited, so there's no scanning for a delimiter here, we are just choosing to parse zero characters, or a single DEL character.