Both snippets work for me and end up with "<prefix>:</prefix>" in the infoset
for lines that have a colon prefix.
Can you provide more of your schema or example data? Sounds like there is
something else going on, maybe bad data or a schema bug somewhere else.
On 2024-03-27 01:14 PM, Larry Barber wrote:
I’m parsing at text file which allows an optional ‘:’ at the beginning of lines.
The following code works at capturing this character:
<!-- optional prefix ":" -->
<xs:elementname="prefix"type="xs:string"maxOccurs="1"minOccurs="0"
dfdl:lengthKind="pattern"dfdl:lengthPattern=":"dfdl:encoding="ISO-8859-1">
<xs:annotation>
<xs:appinfosource=http://www.ogf.org/dfdl/ <http://www.ogf.org/dfdl/>>
<dfdl:discriminatortest="{ (dfdl:valueLength(.,'bytes')eq1)}" />
</xs:appinfo>
</xs:annotation>
</xs:element>
I wanted to avoid using REGEX and changed the code as follows:
<!-- optional prefix ":" -->
<xs:elementname="prefix"type="xs:string"maxOccurs="1"minOccurs="0"
dfdl:lengthKind="explicit"dfdl:length="1">
<xs:annotation>
<xs:appinfosource=http://www.ogf.org/dfdl/ <http://www.ogf.org/dfdl/>>
<dfdl:discriminatortest="{ xs:string(.)eq':'}" />
</xs:appinfo>
</xs:annotation>
</xs:element>
I thought that this was working initially, but now it seems to just consume the
‘:’ character, but not put it into the infoset.
Not sure what’s happening. Guess I’ll just stick with the REGEX – it’s only one
character….