[erlang-patches] [PATCH] Fix XPath tokenising behaviour with attributes, commas

Anneli Cuss <>
Tue Nov 22 12:31:43 CET 2011


Hi all,

I have a one-line patch to xmerl_xpath_scan.erl which corrects
tokenising behaviour when attributes and commas get too friendly:

   git fetch git://github.com/anneli/otp.git fix_xmerl_xpath_scan

To view changes:

  https://github.com/anneli/otp/compare/fix_xmerl_xpath_scan
  https://github.com/anneli/otp/compare/fix_xmerl_xpath_scan.patch

I have a question about testing; the xmerl code seems to have come
from its own world, and appears to be very much set up to test the
extent of W3C conformance. Hence, I'm not sure where a test belongs,
or indeed, where or how to implement it.

At any rate, here's how to reproduce the bug this fixes:

1> xmerl_xpath_scan:tokens("concat(' ', @a)").
** exception error: no function clause matching
xmerl_xpath_scan:operator_name([],"attribute","::a)")
(xmerl_xpath_scan.erl, line 151)
    in function  xmerl_xpath_scan:tokens/2 (xmerl_xpath_scan.erl, line 66)
2>

This is a valid XPath snippet, but the tokeniser appears to confuse
part of the fragment for a boolean operator.

Post-patch:

1> xmerl_xpath_scan:tokens("concat(' ', @a)").
[{function_name,1,concat},
 {'(',1,'('},
 {literal,1," "},
 {',',1,','},
 {axis,1,attribute},
 {'::',1,'::'},
 {name,1,{a,[],"a"}},
 {')',1,')'},
 {'$end',1,'$end'}]
2>

Best,

Anneli Cuss


More information about the erlang-patches mailing list