A Step Back & Ahead

Well adding selector to class seemed pretty easy, eh? I was feeling pretty accomplished unless I became aware I am heading not towards the target. Yesterday morning, I was told that selector was not to be added to the class attribute and rather to style attribute to the object. And this messy head confused style element with style attribute.

Selectors should be a part of style element and not style attribute. After spending entire June 8 playing and making it almost work with style attribute and moving to style element today, things seem to be working to some extent. Yes, on clicking the + at bottom of style dialog, the text in entry box is written as selector to style element. A new style element is created on a click on + of the form shown below:

Screenshot from 2016-06-09 23:04:00

Making use of attributeList() to get the style properties posed a challenge in itself, it kept returning a 0 or a 1 and no attributes. Finally iterated them using List<AttributeRecord> to get only the style property’s value and then suffixing it to the selector name gave me what is visible in the style element in the picture above.

Next I used createElement() to create a node svg:style. The content is set using createTextNode() and adding it to the svg:style element. While writing this, I encountered the issue: parsing error: 1:0:could not recognize next production, solved it by enclosing the content value in braces {}.

Currently, I am working on a map, that maps a selector’s name to style properties. Using this map will help in selection of objects corresponding to a selector and vice-versa. Any manipulation to this map will also keep the stylesheet updated.

Also using this map, I am trying to populate the treeview, whenever a stylesheet with some selectors entailed is opened, with the selecotor names available.