HxQuery is a JQuery-like CSS Selectors engine written in Haxe, for quick visit any tree data structure.
On Github: https://github.com/rockswang/hxquery
HxQuery provides an abstract TreeVisitor interface for developers to implement so that the custom tree struction can be operated with HxQuery engine. Currently the engine has already included:
Play with display list demo for an intuitive understanding about this engine: https://github.com/rockswang/hxquery/blob/master/demo/hxquery-sample01.swf?raw=true
You can input any CSS selectors in bottom input field and click "Find" button to proceed the selectors matching against the display list tree starting rooting from Stage.
Valid selectors examples including:
Stage Circle -> all "Circle" in stage
Circle > Triangle -> all "Triangle" objects which are direct children of "Circle" objects
#circle2 Triangle -> all "Triangle" objects which are descendents of a DisplayObject with name "#circle2"
Stage .Base[name^='circle'] -> all objects derived from "Base" class (i.e. the super class of all 4 type of shapes) and with name starting with "circle"
Stage .ISmooth -> all objects implements "ISmooth" interface (i.e. Circle class& Round class)
:not(.ISmooth) -> all objects not implements "ISmooth" interface (i.e. Triangle class& Square class)
Xml example:
var input: Xml = Xml.parse(ResKeeper.loadAssetText("res/a.xhtml"));
var v: TreeVisitor<Xml> = new XmlVisitor();
var query = new HxQuery(v);
query.print(input);
var found: Array<Xml> = query.find(input, "div#box1 > form input[type='text']");
Flash/NME display list example:
var input = nme.Lib.current.stage;
var v: TreeVisitor<DisplayObject> = new DisplayListVisitor();
var query = new HxQuery(v);
query.print(input);
var found: Array<DisplayObject> = query.find(input, "MySprite > TextField:nth-child(2)");
Haxe object example:
var input: Wrapper = DynamicVisitor.wrapper({ name: [ "rocks", "wang" ], age: 35, mobiles: [{ type: "xiaomi", no: "1111" }, { type: "c8500" }] });
var v: TreeVisitor<Wrapper> = new DynamicVisitor();
var query = new HxQuery(v);
query.print(input);
var found: Array<Wrapper> = query.find(input, "Array#mobiles > :not([no])");
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/groups/opt_out.
Hi, that's cool !
Thanks, I'll look into it.
Yannick
Thanks, I hope you'll like it !