/* local scope doc ptr */ XmlNode = type alias { tag:: string, /* attrs:: [string],*/ content:: string }. interface(extern-c){ xml2 = library:: pkgconfig("libxml-2.0"). include { xml2 = ["libxml/tree.h"] }. } Tree = type Tree(Leaf) [Leaf, [Tree(Leaf)]]. XmlTree = type alias Tree(XmlNode). test= function():: num; entry { filename = "project/documentation.fodt" :: string. docRaw = xmlParseFile(filename) :: xmlDocPtr. tree= xmlDocGetRootElement(docRaw) :: xmlNodePtr. childrenRaw = tree["xmlChildrenNode"]:: [xmlNodePtr]; containers:linkedlist(next, null). size = loop fold(childrenRaw->child:: xmlNodePtr, 0->count::int) : int { count +1 }. size } /* toXmlNode = function (nodeRaw:: xmlNodePtr):: XmlNode { {tag = nodeRaw["name"], content=null} } children = function (tree:: xmlNodePtr):: XmlTree { childrenRaw = tree["xmlChildrenNode"]:: [xmlNodePtr]; containers:linkedlist(next, null). loop map (childrenRaw->childRaw:: xmlNodePtr):: XmlTree { [toXmlNode(childRaw), children(childRaw)] } } document = function (filename:: string):: XmlTree { docRaw = xmlParseFile(filename) :: xmlDocPtr. nodeRaw= xmlDocGetRootElement(docRaw) :: xmlNodePtr. [toXmlNode(nodeRaw), children(nodeRaw)]:: XmlTree } */ /* query = function (tree:: XmlTree):: [string, string] { children = switch :: context(children) case default { [] } case tree[0]:: NeedChildren(childrenFilters); ApplyTransform(transFilters) { loop fold (tree[1]->child:: Tree(Leaf) | childrenFilters, null->accum:: [Tree(Leaf)]) :: [Tree(Leaf)] {accum + traverse(child):: cases(transFilters) } }. node = case node_tag == "style::style", class = node[attrs, "style::name"], exists(class, ParaKnownClasses) { [class, node[attrs, "style::display-name"]] } case default {null}. node + children } */