[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Grammars for XPath 2.0: which to use?
Recently I've been having fun with parsing context-free languages using a general parser for LR languages, written in XSLT 2.0. The first and easier language was JSON, leading to the addition of two new functions to FXSL: f:json-document() and f:json-file-document() as reported in this list and in my blog. The second language I played with was XPath. As I mentioned earlier in this list, it was almost straightforward and non-problematic to create a working parser (right now constructing just a parse tree for an XPath expression). The reason for this easiness is that Dr. Kay's XPath 2.0 book is an excellent reference material both in describing the terminal symbols (lexical tokens) of the language and its grammar. My question is whether the XPath 2.0 grammar as described in the book is still equivalent to the one described in the XPath 2.0 recommendation (http://www.w3.org/TR/xpath20/#id-grammar) or if there are any differences? Certainly, I could try comparing both grammars myself, but why not ask and get this valuable information straight from the horse's mouth? I believe this is also valuable to the readers of xsl-list.
The same question can be asked about the definition of the terminal symbols. Here we have: 1. Dr. Kay's book. 2. The official W3 XPath 2.0 recommendation (http://www.w3.org/TR/xpath20/#terminal-symbols) 3. A seemingly outdated W3 document "Building a Tokenizer for XPath or XQuery" (http://www.w3.org/TR/xquery-xpath-parsing/) In implementing the lexical scanner (again in pure XSLT 2.0) I again used Dr. Kay's book (1), found (2) quite confusing, and definitely decided not to use any of the approaches described in (3). It might be interesting to know that determining the next terminal symbol can be accomplished based on a the evaluation of a single regular expression (shall I call this "one-pass approach" ?). -- Cheers, Dimitre Novatchev --------------------------------------- Truly great madness cannot be achieved without significant intelligence. --------------------------------------- To invent, you need a good imagination and a pile of junk ------------------------------------- You've achieved success in your field when you don't know whether what you're doing is work or play
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|