[Haskell-cafe] hxt: How to Unpickle Multiple Adjacent Elements

Erik Hesselink hesselink at gmail.com
Mon Jan 5 10:25:27 UTC 2015


Hi Jimmy,

Doesn't xpPair [0] do what you want? Then afterwards, use `xpWrap` to
convert the pair(s) to your custom data type.

Erik

[0] http://hackage.haskell.org/package/hxt-9.3.1.10/docs/Text-XML-HXT-Arrow-Pickle-Xml.html#v:xpPair

On Mon, Jan 5, 2015 at 12:15 AM, Jimmy Lu <gongchuo.lu at gmail.com> 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
>
>     data Headword = Hw { hwText       :: String
>                        , hwSl         :: Maybe String
>                        , hwPr         :: Maybe Pronunciation
>                        }
>
> However in the hxt pickle API I cannot found a way to extract a sequence
> of adjacent elements.  Is there any one knowing how to do it?
>
> Thanks,
>
>
> Jimmy Lu
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list