Tim Yates
Tim Yates
I'll have a think... Came up with this in the mean-time: ``` groovy def xml = ''' | | Tim | Dave | Alice | | Yates | | |'''.stripMargin()...
Of course, `XmlParser` and `XmlSlurper` not having a concept of `` or comments doesn't help... Think we have to start with a SAX `DefaultHandler` with an implemented `LexicalHandler` if we're...
ie: ``` groovy import org.xml.sax.* import org.xml.sax.helpers.DefaultHandler import org.xml.sax.ext.LexicalHandler import javax.xml.parsers.SAXParserFactory import javax.xml.parsers.ParserConfigurationException import javax.xml.parsers.SAXParser class ToMapParser extends DefaultHandler implements LexicalHandler { private attrsToList( Attributes a ) { (0.. validating...
Maybe something that takes this: ``` xml ' Tim Dave Alice Yes ]]> Yates ``` And takes defaults of `#` to denote TEXT, `€` to denote CDATA, `?` to denote...
ie: this: ``` groovy import org.xml.sax.* import org.xml.sax.helpers.DefaultHandler import org.xml.sax.ext.LexicalHandler import javax.xml.parsers.SAXParserFactory import javax.xml.parsers.ParserConfigurationException import javax.xml.parsers.SAXParser class ToMapParser extends DefaultHandler implements LexicalHandler { boolean trimCharacters = true String textKey =...
Of course, the natural progression for this is: ``` groovy import org.xml.sax.* import org.xml.sax.helpers.DefaultHandler import org.xml.sax.ext.LexicalHandler import javax.xml.parsers.SAXParserFactory import javax.xml.parsers.ParserConfigurationException import javax.xml.parsers.SAXParser import groovy.transform.* class Node { String name ArrayList...
> Things really get hairy when we get into dealing with nodes that have embedded content. Which nodes do you mean? The `CDATA` ones, or the `textandtext` ones? It might...
I agree ;-) And currently, the n-1 solution converts that CDATA block to: ``` ['¢':'Yes'], ``` So, as you say, it just grabs the content as a single chunk. I...
So currently `Project n-1` returns that as: ``` ['user':[['var':[['#':'Tim'], ['emphasis':[[.role:'bold'], ['#':'Yates']]]]]]] ``` Interesting idea to basically have a rule that > if we hit a node with text in it,...
That's spooky :scream_cat: Last thing I was trying was to extract the text for structured elements Will try again as soon as I get a chance