Page Menu
Home
Xreate
Search
Configure Global Search
Log In
Docs
Questions
Repository
Issues
Patches
Internal API
Files
F3998339
input.xreate
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jul 8, 11:54 PM
Size
1 KB
Mime Type
text/plain
Expires
Fri, Jul 10, 11:54 PM (1 d, 7 h)
Engine
blob
Format
Raw Data
Handle
272871
Attached To
rXR Xreate
input.xreate
View Options
/* 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
}
*/
Event Timeline
Log In to Comment