hxt: How to Unpickle Multiple Adjacent Elements

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

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-Pick...
On Mon, Jan 5, 2015 at 12:15 AM, Jimmy Lu
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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

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.
participants (3)
-
Erik Hesselink
-
Jimmy Lu
-
Michael Orlitzky