element :: XParser (Element Posn)
element = do
    tok TokAnyOpen
    (ElemTag n as) <- elemtag
    return (Elem n as) `apply`
        ( do tok TokEndClose
             return []
          `onFail`
          do tok TokAnyClose
             commit $ manyFinally content
                                  (do p <- posn
                                      m <- bracket (tok TokEndOpen)
                                                   (commit $ tok TokAnyClose) qname
                                      checkmatch p n m)
          ) `adjustErrBad` (("in element tag "++printableName n++",\n")++)
element :: XParser (Element Posn)
element = do
    tok TokAnyOpen
    (ElemTag n as) <- elemtag
    return (Elem n as) `apply`
        ( do tok TokEndClose
             return []
          `onFail`
          do tok TokAnyClose
             commit $ manyFinally content
                                  (do p <- posn
                                      m <- bracket (tok TokEndOpen)
                                                   (commit $ tok TokAnyClose) qname
                                      checkmatch p n m)
          ) `adjustErrBad` (("in element tag "++printableName n++",\n")++)
element = do
    tok TokAnyOpen
    (ElemTag n as) <- elemtag
    return (Elem n as) `apply`
        ( do tok TokEndClose
             return []
          `onFail`
          do tok TokAnyClose
             commit $ manyFinally content
                                  (do p <- posn
                                      m <- bracket (tok TokEndOpen)
                                                   (commit $ tok TokAnyClose) qname
                                      checkmatch p n m)
          ) `adjustErrBad` (("in element tag "++printableName n++",\n")++)