nokogiri 1.1.1-java → 1.2.0-java

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

Files changed (88) hide show
  1. data/History.ja.txt +34 -0
  2. data/History.txt +36 -0
  3. data/Manifest.txt +21 -0
  4. data/README.ja.txt +1 -1
  5. data/README.txt +1 -1
  6. data/Rakefile +26 -88
  7. data/ext/nokogiri/extconf.rb +48 -63
  8. data/ext/nokogiri/html_document.c +90 -29
  9. data/ext/nokogiri/html_sax_parser.c +23 -2
  10. data/ext/nokogiri/native.c +18 -8
  11. data/ext/nokogiri/native.h +22 -0
  12. data/ext/nokogiri/xml_attr.c +83 -0
  13. data/ext/nokogiri/xml_attr.h +9 -0
  14. data/ext/nokogiri/xml_cdata.c +1 -1
  15. data/ext/nokogiri/xml_document.c +84 -18
  16. data/ext/nokogiri/xml_document_fragment.c +38 -0
  17. data/ext/nokogiri/xml_document_fragment.h +10 -0
  18. data/ext/nokogiri/xml_dtd.c +2 -22
  19. data/ext/nokogiri/xml_entity_reference.c +41 -0
  20. data/ext/nokogiri/xml_entity_reference.h +9 -0
  21. data/ext/nokogiri/xml_io.c +10 -3
  22. data/ext/nokogiri/xml_io.h +1 -0
  23. data/ext/nokogiri/xml_node.c +116 -66
  24. data/ext/nokogiri/xml_node_set.c +5 -1
  25. data/ext/nokogiri/xml_processing_instruction.c +44 -0
  26. data/ext/nokogiri/xml_processing_instruction.h +9 -0
  27. data/ext/nokogiri/xml_reader.c +20 -4
  28. data/ext/nokogiri/xml_sax_parser.c +51 -15
  29. data/ext/nokogiri/xml_sax_push_parser.c +85 -0
  30. data/ext/nokogiri/xml_sax_push_parser.h +9 -0
  31. data/ext/nokogiri/xml_syntax_error.c +12 -8
  32. data/ext/nokogiri/xml_syntax_error.h +2 -1
  33. data/ext/nokogiri/xml_xpath_context.c +11 -2
  34. data/ext/nokogiri/xslt_stylesheet.c +1 -6
  35. data/lib/nokogiri.rb +10 -13
  36. data/lib/nokogiri/css.rb +1 -1
  37. data/lib/nokogiri/css/generated_parser.rb +287 -295
  38. data/lib/nokogiri/css/generated_tokenizer.rb +36 -51
  39. data/lib/nokogiri/css/node.rb +1 -3
  40. data/lib/nokogiri/css/parser.rb +21 -12
  41. data/lib/nokogiri/css/parser.y +55 -44
  42. data/lib/nokogiri/css/syntax_error.rb +2 -1
  43. data/lib/nokogiri/css/tokenizer.rex +23 -32
  44. data/lib/nokogiri/decorators/hpricot/node_set.rb +1 -1
  45. data/lib/nokogiri/html.rb +10 -4
  46. data/lib/nokogiri/html/document.rb +6 -2
  47. data/lib/nokogiri/syntax_error.rb +4 -0
  48. data/lib/nokogiri/version.rb +2 -1
  49. data/lib/nokogiri/xml.rb +3 -1
  50. data/lib/nokogiri/xml/attr.rb +3 -4
  51. data/lib/nokogiri/xml/cdata.rb +1 -1
  52. data/lib/nokogiri/xml/document.rb +4 -7
  53. data/lib/nokogiri/xml/document_fragment.rb +9 -0
  54. data/lib/nokogiri/xml/dtd.rb +3 -0
  55. data/lib/nokogiri/xml/node.rb +144 -40
  56. data/lib/nokogiri/xml/node/save_options.rb +32 -0
  57. data/lib/nokogiri/xml/node_set.rb +11 -20
  58. data/lib/nokogiri/xml/processing_instruction.rb +6 -0
  59. data/lib/nokogiri/xml/reader.rb +5 -0
  60. data/lib/nokogiri/xml/sax.rb +1 -0
  61. data/lib/nokogiri/xml/sax/push_parser.rb +47 -0
  62. data/lib/nokogiri/xml/syntax_error.rb +3 -1
  63. data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
  64. data/tasks/test.rb +136 -0
  65. data/test/css/test_parser.rb +4 -0
  66. data/test/css/test_tokenizer.rb +30 -17
  67. data/test/css/test_xpath_visitor.rb +11 -0
  68. data/test/helper.rb +11 -0
  69. data/test/hpricot/test_builder.rb +2 -9
  70. data/test/hpricot/test_parser.rb +4 -4
  71. data/test/html/test_builder.rb +7 -7
  72. data/test/html/test_document.rb +90 -4
  73. data/test/html/test_node.rb +1 -0
  74. data/test/test_css_cache.rb +1 -3
  75. data/test/test_reader.rb +19 -1
  76. data/test/test_xslt_transforms.rb +1 -1
  77. data/test/xml/node/test_save_options.rb +20 -0
  78. data/test/xml/sax/test_parser.rb +17 -0
  79. data/test/xml/sax/test_push_parser.rb +67 -0
  80. data/test/xml/test_attr.rb +16 -0
  81. data/test/xml/test_cdata.rb +1 -1
  82. data/test/xml/test_document.rb +45 -0
  83. data/test/xml/test_document_fragment.rb +18 -0
  84. data/test/xml/test_dtd.rb +2 -4
  85. data/test/xml/test_entity_reference.rb +16 -0
  86. data/test/xml/test_node.rb +149 -80
  87. data/test/xml/test_processing_instruction.rb +24 -0
  88. metadata +28 -2
data/lib/nokogiri/css.rb CHANGED
@@ -18,7 +18,7 @@ module Nokogiri
18
18
  ###
19
19
  # Get the XPath for +selector+.
20
20
  def xpath_for selector, options={}
21
- Parser.new.xpath_for selector, options
21
+ Parser.new(options[:ns] || {}).xpath_for selector, options
22
22
  end
23
23
  end
24
24
  end
@@ -13,159 +13,153 @@ module Nokogiri
13
13
  ##### State transition tables begin ###
14
14
 
15
15
  racc_action_table = [
16
- 5, 28, 27, 22, 10, 5, 27, 5, 24, 1,
17
- 43, 10, 31, 29, 49, 27, 1, 5, 27, 53,
18
- 54, 31, 87, 89, 31, 59, 67, 87, 89, 54,
19
- 10, 68, 102, 101, 26, 7, 9, 12, 15, 10,
20
- 7, 18, 7, 9, 12, 15, 10, 10, 18, 90,
21
- 92, 93, 7, 86, 90, 92, 93, 5, 86, 43,
22
- 43, 10, 9, 85, 15, 10, 1, 18, 85, 10,
23
- 43, 9, 57, 15, 43, 43, 18, 44, 9, 9,
24
- 15, 15, 56, 18, 18, 38, 39, 40, 43, 43,
25
- 44, 72, 7, 9, 12, 15, 73, 9, 18, 15,
26
- 43, 9, 18, 15, 43, 55, 18, 43, 43, 43,
27
- 52, 34, 82, 35, 36, 51, 44, 43, 32, 95,
28
- 43, 97, 43, 99, 100, 15, 43, 43 ]
16
+ 4, 22, 24, 26, 10, 62, 4, 72, 50, 1,
17
+ 10, 21, 4, 23, 25, 1, 10, 10, 59, 18,
18
+ 51, 1, 5, 10, 8, 18, 11, 14, 5, 10,
19
+ 8, 18, 11, 14, 5, 5, 8, 8, 11, 14,
20
+ 14, 5, 10, 8, 4, 57, 14, 5, 10, 8,
21
+ 56, 40, 14, 46, 10, 33, 52, 40, 54, 58,
22
+ 5, 77, 8, 18, 4, 14, 5, 78, 8, 64,
23
+ 66, 14, 5, 34, 8, 35, 49, 14, 64, 66,
24
+ 65, 67, 69, 18, 70, 60, 61, 56, 63, 65,
25
+ 67, 69, 80, 70, 61, 33, 28, 63, 32, 33,
26
+ 52, 5, 54, 33, 52, 82, 54, 83, 31, 33,
27
+ 52, 40, 54, 87, 86, 42, -22, 88, 89, 90,
28
+ 91 ]
29
29
 
30
30
  racc_action_check = [
31
- 0, 6, 5, 5, 0, 18, 74, 58, 5, 0,
32
- 38, 58, 74, 6, 18, 7, 58, 42, 75, 24,
33
- 24, 7, 77, 77, 75, 30, 42, 78, 78, 31,
34
- 14, 42, 98, 98, 5, 0, 0, 0, 0, 70,
35
- 18, 0, 58, 58, 58, 58, 16, 11, 58, 77,
36
- 77, 77, 42, 77, 78, 78, 78, 37, 78, 34,
37
- 35, 37, 14, 77, 14, 3, 37, 14, 78, 4,
38
- 36, 70, 28, 70, 29, 39, 70, 16, 16, 11,
39
- 16, 11, 27, 16, 11, 13, 13, 13, 43, 44,
40
- 46, 51, 37, 37, 37, 37, 53, 3, 37, 3,
41
- 54, 4, 3, 4, 56, 25, 4, 66, 67, 68,
42
- 23, 13, 73, 13, 13, 22, 17, 15, 9, 79,
43
- 81, 88, 91, 94, 96, 2, 101, 102 ]
31
+ 0, 2, 2, 2, 0, 33, 20, 35, 17, 0,
32
+ 20, 2, 51, 2, 2, 20, 51, 3, 30, 0,
33
+ 17, 51, 0, 40, 0, 20, 0, 0, 20, 15,
34
+ 20, 51, 20, 20, 51, 3, 51, 3, 51, 51,
35
+ 3, 40, 6, 40, 14, 28, 40, 15, 7, 15,
36
+ 28, 38, 15, 14, 13, 18, 18, 6, 18, 29,
37
+ 6, 49, 6, 14, 5, 6, 7, 50, 7, 34,
38
+ 34, 7, 13, 5, 13, 5, 16, 13, 36, 36,
39
+ 34, 34, 34, 5, 34, 32, 32, 52, 34, 36,
40
+ 36, 36, 53, 36, 54, 4, 4, 36, 4, 62,
41
+ 62, 12, 62, 61, 61, 57, 61, 60, 4, 56,
42
+ 56, 9, 56, 68, 68, 8, 1, 71, 73, 76,
43
+ 83 ]
44
44
 
45
45
  racc_action_pointer = [
46
- -2, nil, 85, 59, 63, -8, 1, 5, nil, 107,
47
- nil, 41, nil, 78, 24, 108, 40, 79, 3, nil,
48
- nil, nil, 108, 68, 8, 63, nil, 70, 72, 65,
49
- -17, 17, nil, nil, 50, 51, 61, 55, 1, 66,
50
- nil, nil, 15, 79, 80, nil, 53, nil, nil, nil,
51
- nil, 75, nil, 89, 91, nil, 95, nil, 5, nil,
52
- nil, nil, nil, nil, nil, nil, 98, 99, 100, nil,
53
- 33, nil, nil, 96, -4, 8, nil, 19, 24, 78,
54
- nil, 111, nil, nil, nil, nil, nil, nil, 80, nil,
55
- nil, 113, nil, nil, 82, nil, 82, nil, 22, nil,
56
- nil, 117, 118, nil, nil ]
46
+ -2, 89, -6, 11, 85, 62, 36, 42, 104, 90,
47
+ nil, nil, 77, 48, 42, 23, 49, 8, 45, nil,
48
+ 4, nil, nil, nil, nil, nil, nil, nil, 38, 36,
49
+ -5, nil, 74, -7, 66, -18, 75, nil, 30, nil,
50
+ 17, nil, nil, nil, nil, nil, nil, nil, nil, 50,
51
+ 67, 10, 75, 69, 82, nil, 99, 92, nil, nil,
52
+ 100, 93, 89, nil, nil, nil, nil, nil, 103, nil,
53
+ nil, 92, nil, 93, nil, nil, 96, nil, nil, nil,
54
+ nil, nil, nil, 107, nil, nil, nil, nil, nil, nil,
55
+ nil, nil ]
57
56
 
58
57
  racc_action_default = [
59
- -63, -19, -12, -46, -45, -63, -63, -63, -2, -63,
60
- -48, -47, -20, -17, -44, -62, -39, -15, -63, -13,
61
- -42, -41, -35, -63, -30, -63, -24, -31, -63, -62,
62
- -63, -30, -18, -43, -62, -62, -62, -63, -62, -62,
63
- -6, -40, -63, -62, -62, -9, -38, -11, -14, -37,
64
- -36, -63, -25, -34, -62, -26, -62, 105, -63, -27,
65
- -5, -8, -7, -16, -3, -4, -62, -62, -62, -61,
66
- -63, -10, -33, -63, -63, -63, -1, -51, -51, -63,
67
- -60, -62, -32, -28, -29, -52, -56, -57, -63, -58,
68
- -53, -62, -54, -55, -63, -23, -63, -22, -63, -21,
69
- -59, -62, -62, -49, -50 ]
58
+ -23, -20, -17, -51, -65, -65, -43, -48, -65, -15,
59
+ -52, -21, -12, -50, -65, -49, -65, -65, -65, -2,
60
+ -23, -5, -3, -8, -4, -7, -6, -47, -36, -65,
61
+ -65, -27, -34, -35, -55, -65, -55, -9, -42, -11,
62
+ -65, -44, -18, -14, -13, -46, -41, -40, -45, -65,
63
+ -65, -23, -36, -65, -34, -16, -65, -65, -28, -29,
64
+ -39, -65, -65, -56, -61, -57, -62, -58, -65, -59,
65
+ -60, -65, -26, -65, -10, -64, -65, -19, 92, -1,
66
+ -30, -33, -38, -65, -31, -32, -53, -54, -24, -25,
67
+ -63, -37 ]
70
68
 
71
69
  racc_goto_table = [
72
- 42, 23, 50, 30, 6, 20, 21, 8, 47, 48,
73
- 88, 94, 19, 33, 58, 45, 41, 37, 46, 60,
74
- 61, 62, 25, 64, 65, 81, 66, nil, 69, 70,
75
- nil, nil, nil, nil, nil, nil, nil, nil, 71, 74,
76
- nil, 75, nil, nil, 63, nil, nil, nil, nil, nil,
77
- nil, 77, 78, 79, nil, nil, nil, nil, nil, nil,
78
- nil, nil, nil, nil, nil, 76, 96, nil, nil, nil,
79
- 83, 84, 80, nil, nil, nil, 98, nil, nil, nil,
80
- nil, nil, nil, nil, nil, nil, 103, 104 ]
70
+ 29, 27, 19, 39, 38, 41, 43, 36, 71, 17,
71
+ 73, 45, 44, 48, 53, 37, 47, 20, 30, 76,
72
+ nil, nil, 55, nil, nil, nil, nil, nil, nil, nil,
73
+ nil, nil, nil, nil, nil, 74, nil, nil, 75, nil,
74
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
75
+ nil, nil, 81, 79, nil, nil, nil, 84, 85 ]
81
76
 
82
77
  racc_goto_check = [
83
- 2, 14, 10, 14, 1, 8, 8, 3, 9, 9,
84
- 13, 13, 11, 8, 2, 7, 8, 4, 8, 2,
85
- 2, 2, 15, 2, 2, 19, 10, nil, 2, 2,
86
- nil, nil, nil, nil, nil, nil, nil, nil, 9, 2,
87
- nil, 2, nil, nil, 3, nil, nil, nil, nil, nil,
88
- nil, 2, 2, 2, nil, nil, nil, nil, nil, nil,
89
- nil, nil, nil, nil, nil, 3, 2, nil, nil, nil,
90
- 14, 14, 8, nil, nil, nil, 2, nil, nil, nil,
91
- nil, nil, nil, nil, nil, nil, 2, 2 ]
78
+ 14, 7, 2, 8, 7, 7, 8, 9, 13, 1,
79
+ 13, 7, 10, 7, 14, 6, 9, 3, 15, 19,
80
+ nil, nil, 2, nil, nil, nil, nil, nil, nil, nil,
81
+ nil, nil, nil, nil, nil, 8, nil, nil, 7, nil,
82
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
83
+ nil, nil, 14, 2, nil, nil, nil, 14, 14 ]
92
84
 
93
85
  racc_goto_pointer = [
94
- nil, 4, -15, 7, 4, nil, nil, -1, 2, -8,
95
- -16, 10, nil, -67, -4, 17, nil, nil, nil, -45 ]
86
+ nil, 9, 2, 15, nil, nil, 9, -2, -3, 2,
87
+ 0, nil, nil, -26, -4, 14, nil, nil, nil, -21 ]
96
88
 
97
89
  racc_goto_default = [
98
- nil, nil, nil, nil, nil, 13, 16, nil, 17, nil,
99
- 2, 3, 4, nil, nil, nil, 11, 14, 91, nil ]
90
+ nil, nil, nil, nil, 2, 6, nil, 9, nil, 12,
91
+ 13, 15, 16, nil, nil, nil, 3, 7, 68, nil ]
100
92
 
101
93
  racc_reduce_table = [
102
94
  0, 0, :racc_error,
103
- 4, 46, :_reduce_1,
104
- 1, 46, :_reduce_2,
105
- 2, 49, :_reduce_3,
106
- 2, 49, :_reduce_4,
107
- 2, 49, :_reduce_5,
108
- 1, 49, :_reduce_6,
109
- 2, 49, :_reduce_7,
110
- 2, 49, :_reduce_8,
111
- 2, 50, :_reduce_9,
112
- 3, 50, :_reduce_10,
113
- 2, 50, :_reduce_11,
114
- 1, 50, :_reduce_none,
115
- 2, 50, :_reduce_13,
116
- 2, 50, :_reduce_14,
117
- 1, 50, :_reduce_15,
118
- 3, 48, :_reduce_16,
95
+ 3, 31, :_reduce_1,
96
+ 1, 31, :_reduce_2,
97
+ 1, 33, :_reduce_3,
98
+ 1, 33, :_reduce_4,
99
+ 1, 33, :_reduce_5,
100
+ 1, 33, :_reduce_6,
101
+ 1, 33, :_reduce_7,
102
+ 1, 33, :_reduce_8,
103
+ 2, 34, :_reduce_9,
104
+ 3, 34, :_reduce_10,
105
+ 2, 34, :_reduce_11,
106
+ 1, 34, :_reduce_none,
107
+ 2, 34, :_reduce_13,
108
+ 2, 34, :_reduce_14,
109
+ 1, 34, :_reduce_15,
110
+ 3, 32, :_reduce_16,
111
+ 1, 32, :_reduce_none,
112
+ 2, 41, :_reduce_18,
113
+ 3, 35, :_reduce_19,
114
+ 1, 35, :_reduce_20,
115
+ 1, 35, :_reduce_21,
116
+ 1, 42, :_reduce_22,
117
+ 0, 42, :_reduce_none,
118
+ 4, 40, :_reduce_24,
119
+ 4, 40, :_reduce_25,
120
+ 3, 40, :_reduce_26,
121
+ 2, 39, :_reduce_27,
122
+ 3, 39, :_reduce_28,
123
+ 3, 39, :_reduce_29,
124
+ 3, 39, :_reduce_30,
125
+ 3, 44, :_reduce_31,
126
+ 3, 44, :_reduce_32,
127
+ 3, 44, :_reduce_33,
128
+ 1, 44, :_reduce_none,
129
+ 1, 44, :_reduce_none,
130
+ 1, 44, :_reduce_36,
131
+ 4, 45, :_reduce_37,
132
+ 3, 45, :_reduce_38,
133
+ 2, 45, :_reduce_39,
134
+ 2, 46, :_reduce_40,
135
+ 2, 46, :_reduce_41,
136
+ 1, 36, :_reduce_none,
137
+ 0, 36, :_reduce_none,
138
+ 2, 37, :_reduce_44,
139
+ 2, 37, :_reduce_45,
140
+ 2, 37, :_reduce_46,
141
+ 2, 37, :_reduce_47,
142
+ 1, 37, :_reduce_none,
143
+ 1, 37, :_reduce_none,
144
+ 1, 37, :_reduce_none,
145
+ 1, 37, :_reduce_none,
146
+ 1, 47, :_reduce_52,
147
+ 2, 43, :_reduce_53,
148
+ 2, 43, :_reduce_54,
149
+ 0, 43, :_reduce_none,
119
150
  1, 48, :_reduce_none,
120
- 2, 57, :_reduce_18,
121
- 1, 51, :_reduce_19,
122
- 1, 51, :_reduce_20,
123
- 6, 56, :_reduce_21,
124
- 6, 56, :_reduce_22,
125
- 5, 56, :_reduce_23,
126
- 2, 55, :_reduce_24,
127
- 3, 55, :_reduce_25,
128
- 3, 55, :_reduce_26,
129
- 3, 55, :_reduce_27,
130
- 4, 59, :_reduce_28,
131
- 4, 59, :_reduce_29,
132
- 1, 59, :_reduce_none,
133
- 1, 59, :_reduce_none,
134
- 4, 60, :_reduce_32,
135
- 3, 60, :_reduce_33,
136
- 2, 60, :_reduce_34,
137
- 1, 60, :_reduce_35,
138
- 2, 61, :_reduce_36,
139
- 2, 61, :_reduce_37,
140
- 1, 52, :_reduce_none,
141
- 0, 52, :_reduce_none,
142
- 2, 53, :_reduce_40,
143
- 2, 53, :_reduce_41,
144
- 2, 53, :_reduce_42,
145
- 2, 53, :_reduce_43,
146
- 1, 53, :_reduce_none,
147
- 1, 53, :_reduce_none,
148
- 1, 53, :_reduce_none,
149
- 1, 53, :_reduce_none,
150
- 1, 62, :_reduce_48,
151
- 4, 58, :_reduce_49,
152
- 4, 58, :_reduce_50,
153
- 0, 58, :_reduce_none,
154
- 1, 63, :_reduce_none,
155
- 1, 63, :_reduce_none,
156
- 1, 63, :_reduce_none,
157
- 1, 63, :_reduce_none,
158
- 1, 63, :_reduce_none,
159
- 1, 63, :_reduce_none,
160
- 1, 63, :_reduce_none,
161
- 5, 54, :_reduce_59,
162
- 1, 64, :_reduce_none,
163
- 2, 47, :_reduce_none,
164
- 0, 47, :_reduce_none ]
165
-
166
- racc_reduce_n = 63
167
-
168
- racc_shift_n = 105
151
+ 1, 48, :_reduce_none,
152
+ 1, 48, :_reduce_none,
153
+ 1, 48, :_reduce_none,
154
+ 1, 48, :_reduce_none,
155
+ 1, 48, :_reduce_none,
156
+ 1, 48, :_reduce_none,
157
+ 3, 38, :_reduce_63,
158
+ 1, 49, :_reduce_none ]
159
+
160
+ racc_reduce_n = 65
161
+
162
+ racc_shift_n = 92
169
163
 
170
164
  racc_token_table = {
171
165
  false => 0,
@@ -181,40 +175,25 @@ racc_token_table = {
181
175
  :STRING => 10,
182
176
  :IDENT => 11,
183
177
  :COMMA => 12,
184
- :URI => 13,
185
- :CDO => 14,
186
- :CDC => 15,
187
- :NUMBER => 16,
188
- :PERCENTAGE => 17,
189
- :LENGTH => 18,
190
- :EMS => 19,
191
- :EXS => 20,
192
- :ANGLE => 21,
193
- :TIME => 22,
194
- :FREQ => 23,
195
- :IMPORTANT_SYM => 24,
196
- :IMPORT_SYM => 25,
197
- :MEDIA_SYM => 26,
198
- :PAGE_SYM => 27,
199
- :CHARSET_SYM => 28,
200
- :DIMENSION => 29,
201
- :PREFIXMATCH => 30,
202
- :SUFFIXMATCH => 31,
203
- :SUBSTRINGMATCH => 32,
204
- :TILDE => 33,
205
- :NOT_EQUAL => 34,
206
- :SLASH => 35,
207
- :DOUBLESLASH => 36,
208
- :NOT => 37,
209
- "." => 38,
210
- "*" => 39,
211
- "[" => 40,
212
- "]" => 41,
213
- ")" => 42,
214
- ":" => 43,
215
- "=" => 44 }
216
-
217
- racc_nt_base = 45
178
+ :NUMBER => 13,
179
+ :PREFIXMATCH => 14,
180
+ :SUFFIXMATCH => 15,
181
+ :SUBSTRINGMATCH => 16,
182
+ :TILDE => 17,
183
+ :NOT_EQUAL => 18,
184
+ :SLASH => 19,
185
+ :DOUBLESLASH => 20,
186
+ :NOT => 21,
187
+ :EQUAL => 22,
188
+ :RPAREN => 23,
189
+ :LSQUARE => 24,
190
+ :RSQUARE => 25,
191
+ "." => 26,
192
+ "|" => 27,
193
+ "*" => 28,
194
+ ":" => 29 }
195
+
196
+ racc_nt_base = 30
218
197
 
219
198
  racc_use_result_var = true
220
199
 
@@ -248,23 +227,7 @@ Racc_token_to_s_table = [
248
227
  "STRING",
249
228
  "IDENT",
250
229
  "COMMA",
251
- "URI",
252
- "CDO",
253
- "CDC",
254
230
  "NUMBER",
255
- "PERCENTAGE",
256
- "LENGTH",
257
- "EMS",
258
- "EXS",
259
- "ANGLE",
260
- "TIME",
261
- "FREQ",
262
- "IMPORTANT_SYM",
263
- "IMPORT_SYM",
264
- "MEDIA_SYM",
265
- "PAGE_SYM",
266
- "CHARSET_SYM",
267
- "DIMENSION",
268
231
  "PREFIXMATCH",
269
232
  "SUFFIXMATCH",
270
233
  "SUBSTRINGMATCH",
@@ -273,16 +236,16 @@ Racc_token_to_s_table = [
273
236
  "SLASH",
274
237
  "DOUBLESLASH",
275
238
  "NOT",
239
+ "EQUAL",
240
+ "RPAREN",
241
+ "LSQUARE",
242
+ "RSQUARE",
276
243
  "\".\"",
244
+ "\"|\"",
277
245
  "\"*\"",
278
- "\"[\"",
279
- "\"]\"",
280
- "\")\"",
281
246
  "\":\"",
282
- "\"=\"",
283
247
  "$start",
284
248
  "selector",
285
- "s_0toN",
286
249
  "simple_selector_1toN",
287
250
  "combinator",
288
251
  "simple_selector",
@@ -293,6 +256,7 @@ Racc_token_to_s_table = [
293
256
  "function",
294
257
  "attrib",
295
258
  "class",
259
+ "namespace",
296
260
  "attrib_val_0or1",
297
261
  "expr",
298
262
  "an_plus_b",
@@ -307,7 +271,7 @@ Racc_debug_parser = false
307
271
 
308
272
  # reduce 0 omitted
309
273
 
310
- module_eval(<<'.,.,', 'parser.y', 11)
274
+ module_eval(<<'.,.,', 'parser.y', 9)
311
275
  def _reduce_1(val, _values, result)
312
276
  result = [val.first, val.last].flatten
313
277
 
@@ -315,56 +279,56 @@ module_eval(<<'.,.,', 'parser.y', 11)
315
279
  end
316
280
  .,.,
317
281
 
318
- module_eval(<<'.,.,', 'parser.y', 13)
282
+ module_eval(<<'.,.,', 'parser.y', 11)
319
283
  def _reduce_2(val, _values, result)
320
284
  result = val.flatten
321
285
  result
322
286
  end
323
287
  .,.,
324
288
 
325
- module_eval(<<'.,.,', 'parser.y', 16)
289
+ module_eval(<<'.,.,', 'parser.y', 14)
326
290
  def _reduce_3(val, _values, result)
327
291
  result = :DIRECT_ADJACENT_SELECTOR
328
292
  result
329
293
  end
330
294
  .,.,
331
295
 
332
- module_eval(<<'.,.,', 'parser.y', 17)
296
+ module_eval(<<'.,.,', 'parser.y', 15)
333
297
  def _reduce_4(val, _values, result)
334
298
  result = :CHILD_SELECTOR
335
299
  result
336
300
  end
337
301
  .,.,
338
302
 
339
- module_eval(<<'.,.,', 'parser.y', 18)
303
+ module_eval(<<'.,.,', 'parser.y', 16)
340
304
  def _reduce_5(val, _values, result)
341
305
  result = :PRECEDING_SELECTOR
342
306
  result
343
307
  end
344
308
  .,.,
345
309
 
346
- module_eval(<<'.,.,', 'parser.y', 19)
310
+ module_eval(<<'.,.,', 'parser.y', 17)
347
311
  def _reduce_6(val, _values, result)
348
312
  result = :DESCENDANT_SELECTOR
349
313
  result
350
314
  end
351
315
  .,.,
352
316
 
353
- module_eval(<<'.,.,', 'parser.y', 20)
317
+ module_eval(<<'.,.,', 'parser.y', 18)
354
318
  def _reduce_7(val, _values, result)
355
319
  result = :DESCENDANT_SELECTOR
356
320
  result
357
321
  end
358
322
  .,.,
359
323
 
360
- module_eval(<<'.,.,', 'parser.y', 21)
324
+ module_eval(<<'.,.,', 'parser.y', 19)
361
325
  def _reduce_8(val, _values, result)
362
326
  result = :CHILD_SELECTOR
363
327
  result
364
328
  end
365
329
  .,.,
366
330
 
367
- module_eval(<<'.,.,', 'parser.y', 25)
331
+ module_eval(<<'.,.,', 'parser.y', 23)
368
332
  def _reduce_9(val, _values, result)
369
333
  result = if val[1].nil?
370
334
  val.first
@@ -376,7 +340,7 @@ module_eval(<<'.,.,', 'parser.y', 25)
376
340
  end
377
341
  .,.,
378
342
 
379
- module_eval(<<'.,.,', 'parser.y', 32)
343
+ module_eval(<<'.,.,', 'parser.y', 30)
380
344
  def _reduce_10(val, _values, result)
381
345
  result = Node.new(:CONDITIONAL_SELECTOR,
382
346
  [
@@ -389,7 +353,7 @@ module_eval(<<'.,.,', 'parser.y', 32)
389
353
  end
390
354
  .,.,
391
355
 
392
- module_eval(<<'.,.,', 'parser.y', 40)
356
+ module_eval(<<'.,.,', 'parser.y', 38)
393
357
  def _reduce_11(val, _values, result)
394
358
  result = Node.new(:CONDITIONAL_SELECTOR, val)
395
359
 
@@ -399,7 +363,7 @@ module_eval(<<'.,.,', 'parser.y', 40)
399
363
 
400
364
  # reduce 12 omitted
401
365
 
402
- module_eval(<<'.,.,', 'parser.y', 44)
366
+ module_eval(<<'.,.,', 'parser.y', 42)
403
367
  def _reduce_13(val, _values, result)
404
368
  result = Node.new(:CONDITIONAL_SELECTOR, val)
405
369
 
@@ -407,7 +371,7 @@ module_eval(<<'.,.,', 'parser.y', 44)
407
371
  end
408
372
  .,.,
409
373
 
410
- module_eval(<<'.,.,', 'parser.y', 47)
374
+ module_eval(<<'.,.,', 'parser.y', 45)
411
375
  def _reduce_14(val, _values, result)
412
376
  result = Node.new(:CONDITIONAL_SELECTOR,
413
377
  [
@@ -420,7 +384,7 @@ module_eval(<<'.,.,', 'parser.y', 47)
420
384
  end
421
385
  .,.,
422
386
 
423
- module_eval(<<'.,.,', 'parser.y', 55)
387
+ module_eval(<<'.,.,', 'parser.y', 53)
424
388
  def _reduce_15(val, _values, result)
425
389
  result = Node.new(:CONDITIONAL_SELECTOR,
426
390
  [Node.new(:ELEMENT_NAME, ['*']), val.first]
@@ -430,7 +394,7 @@ module_eval(<<'.,.,', 'parser.y', 55)
430
394
  end
431
395
  .,.,
432
396
 
433
- module_eval(<<'.,.,', 'parser.y', 62)
397
+ module_eval(<<'.,.,', 'parser.y', 60)
434
398
  def _reduce_16(val, _values, result)
435
399
  result = Node.new(val[1], [val.first, val.last])
436
400
 
@@ -440,110 +404,158 @@ module_eval(<<'.,.,', 'parser.y', 62)
440
404
 
441
405
  # reduce 17 omitted
442
406
 
443
- module_eval(<<'.,.,', 'parser.y', 67)
407
+ module_eval(<<'.,.,', 'parser.y', 65)
444
408
  def _reduce_18(val, _values, result)
445
409
  result = Node.new(:CLASS_CONDITION, [val[1]])
446
410
  result
447
411
  end
448
412
  .,.,
449
413
 
450
- module_eval(<<'.,.,', 'parser.y', 70)
414
+ module_eval(<<'.,.,', 'parser.y', 69)
451
415
  def _reduce_19(val, _values, result)
452
- result = Node.new(:ELEMENT_NAME, val)
416
+ result = Node.new(:ELEMENT_NAME,
417
+ [[val.first, val.last].compact.join(':')]
418
+ )
419
+
453
420
  result
454
421
  end
455
422
  .,.,
456
423
 
457
- module_eval(<<'.,.,', 'parser.y', 71)
424
+ module_eval(<<'.,.,', 'parser.y', 74)
458
425
  def _reduce_20(val, _values, result)
459
- result = Node.new(:ELEMENT_NAME, val)
426
+ name = @namespaces.key?('xmlns') ? "xmlns:#{val.first}" : val.first
427
+ result = Node.new(:ELEMENT_NAME, [name])
428
+
460
429
  result
461
430
  end
462
431
  .,.,
463
432
 
464
- module_eval(<<'.,.,', 'parser.y', 75)
433
+ module_eval(<<'.,.,', 'parser.y', 77)
465
434
  def _reduce_21(val, _values, result)
435
+ result = Node.new(:ELEMENT_NAME, val)
436
+ result
437
+ end
438
+ .,.,
439
+
440
+ module_eval(<<'.,.,', 'parser.y', 80)
441
+ def _reduce_22(val, _values, result)
442
+ result = val[0]
443
+ result
444
+ end
445
+ .,.,
446
+
447
+ # reduce 23 omitted
448
+
449
+ module_eval(<<'.,.,', 'parser.y', 85)
450
+ def _reduce_24(val, _values, result)
466
451
  result = Node.new(:ATTRIBUTE_CONDITION,
467
- [Node.new(:ELEMENT_NAME, [val[2]])] + (val[4] || [])
452
+ [Node.new(:ELEMENT_NAME, [val[1]])] + (val[2] || [])
468
453
  )
469
454
 
470
455
  result
471
456
  end
472
457
  .,.,
473
458
 
474
- module_eval(<<'.,.,', 'parser.y', 80)
475
- def _reduce_22(val, _values, result)
459
+ module_eval(<<'.,.,', 'parser.y', 90)
460
+ def _reduce_25(val, _values, result)
476
461
  result = Node.new(:ATTRIBUTE_CONDITION,
477
- [val[2]] + (val[4] || [])
462
+ [val[1]] + (val[2] || [])
478
463
  )
479
464
 
480
465
  result
481
466
  end
482
467
  .,.,
483
468
 
484
- module_eval(<<'.,.,', 'parser.y', 85)
485
- def _reduce_23(val, _values, result)
469
+ module_eval(<<'.,.,', 'parser.y', 95)
470
+ def _reduce_26(val, _values, result)
486
471
  # Non standard, but hpricot supports it.
487
472
  result = Node.new(:PSEUDO_CLASS,
488
- [Node.new(:FUNCTION, ['nth-child(', val[2]])]
473
+ [Node.new(:FUNCTION, ['nth-child(', val[1]])]
489
474
  )
490
475
 
491
476
  result
492
477
  end
493
478
  .,.,
494
479
 
495
- module_eval(<<'.,.,', 'parser.y', 93)
496
- def _reduce_24(val, _values, result)
480
+ module_eval(<<'.,.,', 'parser.y', 103)
481
+ def _reduce_27(val, _values, result)
497
482
  result = Node.new(:FUNCTION, [val.first.strip])
498
483
 
499
484
  result
500
485
  end
501
486
  .,.,
502
487
 
503
- module_eval(<<'.,.,', 'parser.y', 96)
504
- def _reduce_25(val, _values, result)
488
+ module_eval(<<'.,.,', 'parser.y', 106)
489
+ def _reduce_28(val, _values, result)
505
490
  result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
506
491
 
507
492
  result
508
493
  end
509
494
  .,.,
510
495
 
511
- module_eval(<<'.,.,', 'parser.y', 99)
512
- def _reduce_26(val, _values, result)
496
+ module_eval(<<'.,.,', 'parser.y', 109)
497
+ def _reduce_29(val, _values, result)
513
498
  result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
514
499
 
515
500
  result
516
501
  end
517
502
  .,.,
518
503
 
519
- module_eval(<<'.,.,', 'parser.y', 102)
520
- def _reduce_27(val, _values, result)
504
+ module_eval(<<'.,.,', 'parser.y', 112)
505
+ def _reduce_30(val, _values, result)
521
506
  result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
522
507
 
523
508
  result
524
509
  end
525
510
  .,.,
526
511
 
527
- module_eval(<<'.,.,', 'parser.y', 106)
528
- def _reduce_28(val, _values, result)
512
+ module_eval(<<'.,.,', 'parser.y', 116)
513
+ def _reduce_31(val, _values, result)
529
514
  result = [val.first, val.last]
530
515
  result
531
516
  end
532
517
  .,.,
533
518
 
534
- module_eval(<<'.,.,', 'parser.y', 107)
535
- def _reduce_29(val, _values, result)
519
+ module_eval(<<'.,.,', 'parser.y', 117)
520
+ def _reduce_32(val, _values, result)
521
+ result = [val.first, val.last]
522
+ result
523
+ end
524
+ .,.,
525
+
526
+ module_eval(<<'.,.,', 'parser.y', 118)
527
+ def _reduce_33(val, _values, result)
536
528
  result = [val.first, val.last]
537
529
  result
538
530
  end
539
531
  .,.,
540
532
 
541
- # reduce 30 omitted
533
+ # reduce 34 omitted
542
534
 
543
- # reduce 31 omitted
535
+ # reduce 35 omitted
544
536
 
545
- module_eval(<<'.,.,', 'parser.y', 114)
546
- def _reduce_32(val, _values, result)
537
+ module_eval(<<'.,.,', 'parser.y', 123)
538
+ def _reduce_36(val, _values, result)
539
+ if val[0] == 'even'
540
+ val = ["2","n","+","0"]
541
+ result = Node.new(:AN_PLUS_B, val)
542
+ elsif val[0] == 'odd'
543
+ val = ["2","n","+","1"]
544
+ result = Node.new(:AN_PLUS_B, val)
545
+ else
546
+ # This is not CSS standard. It allows us to support this:
547
+ # assert_xpath("//a[foo(., @href)]", @parser.parse('a:foo(@href)'))
548
+ # assert_xpath("//a[foo(., @a, b)]", @parser.parse('a:foo(@a, b)'))
549
+ # assert_xpath("//a[foo(., a, 10)]", @parser.parse('a:foo(a, 10)'))
550
+ result = val
551
+ end
552
+
553
+ result
554
+ end
555
+ .,.,
556
+
557
+ module_eval(<<'.,.,', 'parser.y', 141)
558
+ def _reduce_37(val, _values, result)
547
559
  if val[1] == 'n'
548
560
  result = Node.new(:AN_PLUS_B, val)
549
561
  else
@@ -554,8 +566,8 @@ module_eval(<<'.,.,', 'parser.y', 114)
554
566
  end
555
567
  .,.,
556
568
 
557
- module_eval(<<'.,.,', 'parser.y', 120)
558
- def _reduce_33(val, _values, result)
569
+ module_eval(<<'.,.,', 'parser.y', 147)
570
+ def _reduce_38(val, _values, result)
559
571
  # n+3, -n+3
560
572
  if val[0] == 'n'
561
573
  val.unshift("1")
@@ -572,8 +584,8 @@ module_eval(<<'.,.,', 'parser.y', 120)
572
584
  end
573
585
  .,.,
574
586
 
575
- module_eval(<<'.,.,', 'parser.y', 134)
576
- def _reduce_34(val, _values, result)
587
+ module_eval(<<'.,.,', 'parser.y', 161)
588
+ def _reduce_39(val, _values, result)
577
589
  if val[1] == 'n'
578
590
  val << "+"
579
591
  val << "0"
@@ -586,110 +598,86 @@ module_eval(<<'.,.,', 'parser.y', 134)
586
598
  end
587
599
  .,.,
588
600
 
589
- module_eval(<<'.,.,', 'parser.y', 144)
590
- def _reduce_35(val, _values, result)
591
- if val[0] == 'even'
592
- val = ["2","n","+","0"]
593
- result = Node.new(:AN_PLUS_B, val)
594
- elsif val[0] == 'odd'
595
- val = ["2","n","+","1"]
596
- result = Node.new(:AN_PLUS_B, val)
597
- else
598
- raise Racc::ParseError, "parse error on IDENT '#{val[0]}'"
599
- end
600
-
601
- result
602
- end
603
- .,.,
604
-
605
- module_eval(<<'.,.,', 'parser.y', 157)
606
- def _reduce_36(val, _values, result)
601
+ module_eval(<<'.,.,', 'parser.y', 172)
602
+ def _reduce_40(val, _values, result)
607
603
  result = Node.new(:PSEUDO_CLASS, [val[1]])
608
604
 
609
605
  result
610
606
  end
611
607
  .,.,
612
608
 
613
- module_eval(<<'.,.,', 'parser.y', 159)
614
- def _reduce_37(val, _values, result)
609
+ module_eval(<<'.,.,', 'parser.y', 174)
610
+ def _reduce_41(val, _values, result)
615
611
  result = Node.new(:PSEUDO_CLASS, [val[1]])
616
612
  result
617
613
  end
618
614
  .,.,
619
615
 
620
- # reduce 38 omitted
616
+ # reduce 42 omitted
621
617
 
622
- # reduce 39 omitted
618
+ # reduce 43 omitted
623
619
 
624
- module_eval(<<'.,.,', 'parser.y', 167)
625
- def _reduce_40(val, _values, result)
620
+ module_eval(<<'.,.,', 'parser.y', 182)
621
+ def _reduce_44(val, _values, result)
626
622
  result = Node.new(:COMBINATOR, val)
627
623
 
628
624
  result
629
625
  end
630
626
  .,.,
631
627
 
632
- module_eval(<<'.,.,', 'parser.y', 170)
633
- def _reduce_41(val, _values, result)
628
+ module_eval(<<'.,.,', 'parser.y', 185)
629
+ def _reduce_45(val, _values, result)
634
630
  result = Node.new(:COMBINATOR, val)
635
631
 
636
632
  result
637
633
  end
638
634
  .,.,
639
635
 
640
- module_eval(<<'.,.,', 'parser.y', 173)
641
- def _reduce_42(val, _values, result)
636
+ module_eval(<<'.,.,', 'parser.y', 188)
637
+ def _reduce_46(val, _values, result)
642
638
  result = Node.new(:COMBINATOR, val)
643
639
 
644
640
  result
645
641
  end
646
642
  .,.,
647
643
 
648
- module_eval(<<'.,.,', 'parser.y', 176)
649
- def _reduce_43(val, _values, result)
644
+ module_eval(<<'.,.,', 'parser.y', 191)
645
+ def _reduce_47(val, _values, result)
650
646
  result = Node.new(:COMBINATOR, val)
651
647
 
652
648
  result
653
649
  end
654
650
  .,.,
655
651
 
656
- # reduce 44 omitted
652
+ # reduce 48 omitted
657
653
 
658
- # reduce 45 omitted
654
+ # reduce 49 omitted
659
655
 
660
- # reduce 46 omitted
656
+ # reduce 50 omitted
661
657
 
662
- # reduce 47 omitted
658
+ # reduce 51 omitted
663
659
 
664
- module_eval(<<'.,.,', 'parser.y', 184)
665
- def _reduce_48(val, _values, result)
660
+ module_eval(<<'.,.,', 'parser.y', 199)
661
+ def _reduce_52(val, _values, result)
666
662
  result = Node.new(:ID, val)
667
663
  result
668
664
  end
669
665
  .,.,
670
666
 
671
- module_eval(<<'.,.,', 'parser.y', 187)
672
- def _reduce_49(val, _values, result)
673
- result = [val.first, val[2]]
667
+ module_eval(<<'.,.,', 'parser.y', 202)
668
+ def _reduce_53(val, _values, result)
669
+ result = [val.first, val[1]]
674
670
  result
675
671
  end
676
672
  .,.,
677
673
 
678
- module_eval(<<'.,.,', 'parser.y', 188)
679
- def _reduce_50(val, _values, result)
680
- result = [val.first, val[2]]
674
+ module_eval(<<'.,.,', 'parser.y', 203)
675
+ def _reduce_54(val, _values, result)
676
+ result = [val.first, val[1]]
681
677
  result
682
678
  end
683
679
  .,.,
684
680
 
685
- # reduce 51 omitted
686
-
687
- # reduce 52 omitted
688
-
689
- # reduce 53 omitted
690
-
691
- # reduce 54 omitted
692
-
693
681
  # reduce 55 omitted
694
682
 
695
683
  # reduce 56 omitted
@@ -698,13 +686,7 @@ module_eval(<<'.,.,', 'parser.y', 188)
698
686
 
699
687
  # reduce 58 omitted
700
688
 
701
- module_eval(<<'.,.,', 'parser.y', 202)
702
- def _reduce_59(val, _values, result)
703
- result = Node.new(:NOT, [val[2]])
704
-
705
- result
706
- end
707
- .,.,
689
+ # reduce 59 omitted
708
690
 
709
691
  # reduce 60 omitted
710
692
 
@@ -712,6 +694,16 @@ module_eval(<<'.,.,', 'parser.y', 202)
712
694
 
713
695
  # reduce 62 omitted
714
696
 
697
+ module_eval(<<'.,.,', 'parser.y', 217)
698
+ def _reduce_63(val, _values, result)
699
+ result = Node.new(:NOT, [val[1]])
700
+
701
+ result
702
+ end
703
+ .,.,
704
+
705
+ # reduce 64 omitted
706
+
715
707
  def _reduce_none(val, _values, result)
716
708
  val[0]
717
709
  end