Freelance software grandad
software created
extended or repaired
Follow me on Mastodon
Applications, Libraries, Code
Talks & Presentations
When it's an XSLT pattern, that's when.
As an XPath
para[@ref]selects, for a given node, its child
para
elements which have ref
attributes. As an XSLT pattern it tests whether a given node is a para
element which has a ref
attribute.
Similarly, something like
chapter/paratests whether a given node is a
para
element with a chapter
element parent. In XPath terms, you'd express it as something like boolean(self::para[parent::chapter])
.
Aside from this sematic difference, syntactically XSLT patterns are an XPath subset. I don't have these things evaluating yet but, thanks to the miracle that is Boost::Spirit, I've extended Arabica::XPath to parse them. Took about half an hour, including writing a pile of test cases and getting them passing. It really is a top piece of work. While it's not hard to find people rambling on about how Python or Lisp or whatever really is the thing for writing little domain specific languages, this kind of thing really shows just how deadly cool template metaprogramming can be. Read the EBNF, transcribe it into code, compile, and go. Easy, expressive and type-safe. What more could you want?
Freelance software grandad
software created
extended or repaired
Follow me on Mastodon
Applications, Libraries, Code
Talks & Presentations