all.xreate
No OneTemporary

File Metadata

Created
Wed, Jul 8, 7:35 AM

all.xreate

/* C++ SECTION
Example of c++ code:
xmlDocPtr doc;
xmlNodePtr cur;
doc = xmlParseFile(docname.c_str());
if (doc == NULL ) {
fprintf(stderr,"Document not parsed successfully. \n");
return;
}
cur = xmlDocGetRootElement(doc);
if (cur == NULL) {
fprintf(stderr,"empty document\n");
xmlFreeDoc(doc);
return;
}
cur = cur->xmlChildrenNode;
while (cur != NULL) {
printf("child: %s\n", cur->name);
cur = cur->next;
}
*/
/* FEATURES SECTION
Default strategies:
- what to do with unspecified nodes
Node content strategy:
- send as-is
- apply transforms (all / named)
- ?? skip
Processing order:
- dependencies
Mapping:
* tree -> list
*/
/* TODO SECTION
-- gather types aliases (tree->list mapping)
-- flyweight implementation (doc calculation, for example. based on are there more than one opened document )
*/
// REQUIREMENTS SECTION
/* require ptrvalid */
/* local scope doc ptr */
/* singleton element check(::single) */
XmlAttr = type alias {
name:: String,
content:: String
}.
XmlNode = type alias {
name:: String, /* the name of the node, or the entity */
children:: [xmlNode], /* parent->childs link */
content:: String, /* the content */
attributes::[XmlAttr] /* properties list */
/*
void *_private; // application data
struct _xmlNode *parent; // child->parent link
struct _xmlNode *next; // next sibling link
struct _xmlNode *prev; // previous sibling link
struct _xmlDoc *doc; // the containing document
unsigned short line; // line number
*/
}.
interface(extern-c){
xml2 = library:: pkgconfig("libxml-2.0").
include {
xml2 = ["libxml/tree.h", "string.h"]
}.
}
Tree = type Tree(Leaf) [Leaf, [Tree(Leaf)]].
XmlTree = type alias Tree(XmlNode).
find = ..
[xmlNodePtr]; containers:linkedlist(next, null).
test1 = function():: int; entry {
dictAliases = dictAliases():: AliasList.
count = loop fold(dictAliases->alias::Alias, 0->count::int):: int{
aliasName = alias[0]:: String; logging.
aliasOrigClass = alias[1]::String; logging.
count + 1
}
count
}
/*
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
}
*/
Alias = type alias {
alias: String,
original: String
}.
AliasList = type alias [Alias].
classesPar = ["pgess1", "pgess2"] :: [String].
classesAliasQuery = function(node:: xmlNodePtr):: Alias
{
result =
case default {none}
case node[tag] == "style", class in classesPara,
classAlias = node[attrs, "name"],
class=node[attrs, "parent-style-name"],
{
[classAlias. class]
}.
result.
}
dictAliases = function():: AliasList{
filename = "project/documentation.fodt" :: string.
docRaw = xmlParseFile(filename) :: xmlDocPtr.
tree= xmlDocGetRootElement(docRaw) :: xmlNodePtr.
nodeStylesRoot = findNodes(tree, "office:automatic-styles"):: xmlNodePtr; single.
nodesStyles= findNodes(nodeStylesRoot, "style:style"):: [xmlNodePtr].
nodesChildAliases = filter(nodeStyles){
"style:parent-style-name" in classesPar
}
dictChildAliases = loop fold(nodesChilds->node:: xmlNodePtr, []->aliases::[Alias]) {
aliases + {alias = attr(node, "style:name"), original = attr(node, "style:parent-style-name")}
}.
nodesDisplayAliases = filter(nodesStyles){
"style:parent-style-name" in classesPar
}
dictDisplayAliases = loop fold(nodesDisplayAliases->node:: xmlNodePtr, []->aliases::[Alias]) {
aliases + {alias = attr(node, "style:display-name"), original = attr(node, "style:name")}
}.
nodesDisplayAliases + dictDisplayAliases
}

Event Timeline