[Haskell-cafe] hxt: How to Unpickle Multiple Adjacent Elements
Michael Orlitzky
michael at orlitzky.com
Thu Jan 8 03:40:54 UTC 2015
On 01/04/2015 06:15 PM, Jimmy Lu wrote:
> Hi,
>
> With xml element having DTD like following:
>
> <!ELEMENT entry ((art*, formula?, table?), hw, hsl?, (pr | altpr)?, (ahw, hsl?, (pr | altpr)?)*, vr?, fl?, lb*, in*, ((dx) | (cx?, def?))?, dro*, dxnl*, uro*, syns*)>
>
> I want to unpickle the sequence
>
> hw, hsl?, (pr | altpr)?, (ahw, hsl?, (pr | altpr)?)*
>
> into Haskell data type [Headword] where
Are you asking how to extract ONLY that sequence? If so, it's not
possible: you have to provide a pickler/unpickler for the whole thing,
and then ignore the parts you don't want.
That aside, you might not want to make a list out of the elements you've
shown. That's a sequence of a fixed number of heterogeneous things. The
first one is an "hw", the second is an "(optional) hsl", the third is an
"(optional) pr or altpr",...
The last expression with the star is what you'd want to (un)pickle into
a list.
More information about the Haskell-Cafe
mailing list