{-# LANGUAGE FlexibleContexts #-}-- | This module ported from Text.XML.Light.ProcmoduleText.XML.Expat.ProcwhereimportText.XML.Expat.Internal.NodeClassimportText.XML.Expat.SAXimportControl.MonadimportData.List.Class(filter)importData.Maybe(listToMaybe)importData.MonoidimportPreludehiding(filter)-- | Select only the elements from a list of XML content.onlyElems::NodeClassnc=>c(nctagtext)->c(nctagtext)onlyElems=filterisElement-- | Select only the text from a list of XML content.onlyText::(NodeClassnc,Monoidtext)=>c(nctagtext)->ctextonlyText=fmapgetText.filterisText-- | Find all immediate children with the given name.findChildren::(NodeClassnc,Eqtag,Monoidtag)=>tag->nctagtext->c(nctagtext)findChildrenqe=filterChildren((q==).getName)e-- | Filter all immediate children wrt a given predicate.filterChildren::NodeClassnc=>(nctagtext->Bool)->nctagtext->c(nctagtext)filterChildrenpe|isElemente=filterp(onlyElems(getChildrene))filterChildren__=mzero-- | Filter all immediate children wrt a given predicate over their names.filterChildrenName::(NodeClassnc,Monoidtag)=>(tag->Bool)->nctagtext->c(nctagtext)filterChildrenNamepe|isElemente=filter(p.getName)(onlyElems(getChildrene))filterChildrenName__=mzero-- | Find an immediate child with the given name.findChild::(NodeClassn[],GenericXMLStringtag)=>tag->n[]tagtext->Maybe(n[]tagtext)findChildqe=listToMaybe(findChildrenqe)-- | Find an immediate child with the given name.filterChild::NodeClassn[]=>(n[]tagtext->Bool)->n[]tagtext->Maybe(n[]tagtext)filterChildpe=listToMaybe(filterChildrenpe)-- | Find an immediate child with name matching a predicate.filterChildName::(NodeClassn[],Monoidtag)=>(tag->Bool)->n[]tagtext->Maybe(n[]tagtext)filterChildNamepe=listToMaybe(filterChildrenNamepe)-- | Find the left-most occurrence of an element matching given name.findElement::(NodeClassn[],Eqtag,Monoidtag)=>tag->n[]tagtext->Maybe(n[]tagtext)findElementqe=listToMaybe(findElementsqe)-- | Filter the left-most occurrence of an element wrt. given predicate.filterElement::NodeClassn[]=>(n[]tagtext->Bool)->n[]tagtext->Maybe(n[]tagtext)filterElementpe=listToMaybe(filterElementspe)-- | Filter the left-most occurrence of an element wrt. given predicate.filterElementName::(NodeClassn[],Monoidtag)=>(tag->Bool)->n[]tagtext->Maybe(n[]tagtext)filterElementNamepe=listToMaybe(filterElementsNamepe)-- | Find all non-nested occurances of an element.-- (i.e., once we have found an element, we do not search-- for more occurances among the element's children).findElements::(NodeClassnc,Eqtag,Monoidtag)=>tag->nctagtext->c(nctagtext)findElementsqne=filterElementsName(qn==)e-- | Find all non-nested occurrences of an element wrt. given predicate.-- (i.e., once we have found an element, we do not search-- for more occurances among the element's children).filterElements::NodeClassnc=>(nctagtext->Bool)->nctagtext->c(nctagtext)filterElementspe|pe=returne|isElemente=join$fmap(filterElementsp)$onlyElems$getChildrene|otherwise=mzero-- | Find all non-nested occurences of an element wrt a predicate over element names.-- (i.e., once we have found an element, we do not search-- for more occurances among the element's children).filterElementsName::(NodeClassnc,Monoidtag)=>(tag->Bool)->nctagtext->c(nctagtext)filterElementsNamepe|isElemente=filterElements(p.getName)efilterElementsName__=mzero