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:element name="prefix"
type="xs:string" maxOccurs="1" minOccurs="0"
dfdl:lengthKind="pattern" dfdl:lengthPattern=":" dfdl:encoding="ISO-8859-1" >
<xs:annotation>
<xs:appinfo
source=http://www.ogf.org/dfdl/>
<dfdl:discriminator test="{ (dfdl:valueLength(., 'bytes') eq 1) }" />
</xs:appinfo>
</xs:annotation>
</xs:element>
I wanted to avoid using REGEX and changed the code as follows:
<!-- optional prefix ":" -->
<xs:element name="prefix"
type="xs:string" maxOccurs="1" minOccurs="0"
dfdl:lengthKind="explicit" dfdl:length="1" >
<xs:annotation>
<xs:appinfo
source=http://www.ogf.org/dfdl/>
<dfdl:discriminator test="{ 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....
- Parsing optional line prefix Larry Barber
- Re: Parsing optional line prefix Steve Lawrence
