XML Operators
For a long time I wanted to use
E4X's operators for XML operations, but now I changed my mind: I think it's a bad idea to use '.' for accessing child elements. One problem is that you can't tell '.' for property access from '.' for child elements. But even worse is that re-adding a property later to a class that uses '.' for child elements would break source code.
So another operator for child elements is needed. I think the best alternative is '..' (used by E4X for accessing descendants). My replacement for E4X's '..' is '.~', probably. Because of typed NodeLists (see last entry) I also need another operator to narrow down a NodeList and make it typed, and '.?' looks good for that.
So the list of XML operators is
- '..' + QName to get all children with the given QName
- '.~' + QName to get all decendants with the given QName
- '.@' + QName to get the value of the attribute with the given QName
- '.?' + QName to remove all nodes from a list that are not elements with the given QName
- '.()' to keep only those elements in the list, that fulfill the given conditon (filter)
written at 20:15. (0 Comments, Permalink)