I am trying to parse an XML file with hxt. In the code below, I need to parse the inner elements with an extra parameter obtained from an attribute in the outer tag. But i is not available in the second line (second arrow?). How can I pass i to the getTerminal?
getSentence = atTag "s" >>> proc x -> do i <- getAttrValue "id" -< x ts <- listA (getTerminal i) <<< atTag "terminals" -< x returnA -< Sentence { sid = i, terminals = ts } ... getTerminal sid = atTag "t" >>> proc x -> do i <- getAttrValue "id" -< x lem <- getAttrValue "lemma" -< x returnA -< Terminal { lemma = lem, tid = nid i } where nid x = fromMaybe x (stripPrefix (sid ++ "_") x) That is, i contains the value that I would like to pass to getTerminal.
没有评论:
发表评论