MACHINE LibraryXML
/* This Library Machine provides a convenient access to XML data
   converted by ProB's external function READ_XML (and READ_JSON_AS_XML)
   from LibraryXML.def.

   Usage: SEES LibraryXML
*/
DEFINITIONS "LibraryXML.def"; "SORT.def"
ABSTRACT_CONSTANTS
    elementsOfType,
    elementOfId,
    childs,
    childsOfType,
    idOfElement,
    allIdsOfType,
    contentOfElement
PROPERTIES
      elementsOfType = %(data,t).(data:seq(XML_ELement_Type) & t:STRING|{e|e:ran(data) & e'element=t})
    & elementOfId    = %(data,i).(data:seq(XML_ELement_Type) & i:STRING|{e|e:ran(data) & i : e'attributes[{"id"}]})
    & childs         = %(data,e).(data:seq(XML_ELement_Type) & e:ran(data)|{c|c:ran(data) & e'recId = c'pId})
    & childsOfType   = %(data,e,t).(data:seq(XML_ELement_Type) & e:ran(data) & t:STRING|{c|c:ran(data) & e'recId = c'pId & c'element=t})
    & idOfElement    = %(data,e).(data:seq(XML_ELement_Type) & e:ran(data)|{i|i:STRING & i : e'attributes[{"id"}]})
    & allIdsOfType   = %(data,t).(data:seq(XML_ELement_Type) & t:STRING|dom({i,e|e:ran(data) & e'element=t & i : e'attributes[{"id"}]}))
    & contentOfElement = %(data,e).(data:seq(XML_ELement_Type) & e:ran(data)|
                                SQUASH({cr,txt | #ce.(ce:elementsOfType(data,"CText") &
                                                 e'recId=ce'pId & cr=ce'recId & txt : ce'attributes[{"text"}])}))
END
