summaryrefslogtreecommitdiffstats
path: root/axiom/test/xpath
diff options
context:
space:
mode:
authorGravatar gmcdonald2010-02-13 01:32:03 +0000
committerGravatar gmcdonald2010-02-13 01:32:03 +0000
commit0425aadc78680e53000fd0108b540d6eca048516 (patch)
tree8ec7ab8e015d454c5ec586dfc91e05a2dce1cfc0 /axiom/test/xpath
downloadaxis2c-0425aadc78680e53000fd0108b540d6eca048516.tar.gz
axis2c-0425aadc78680e53000fd0108b540d6eca048516.tar.bz2
Moving axis svn, part of TLP move INFRA-2441
git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@909681 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'axiom/test/xpath')
-rw-r--r--axiom/test/xpath/Makefile.am20
-rw-r--r--axiom/test/xpath/results.txt616
-rw-r--r--axiom/test/xpath/test.ns2
-rw-r--r--axiom/test/xpath/test.xml55
-rw-r--r--axiom/test/xpath/test.xpath37
-rw-r--r--axiom/test/xpath/test_xpath.c513
-rw-r--r--axiom/test/xpath/test_xpath_streaming.c468
7 files changed, 1711 insertions, 0 deletions
diff --git a/axiom/test/xpath/Makefile.am b/axiom/test/xpath/Makefile.am
new file mode 100644
index 0000000..ed70ed6
--- /dev/null
+++ b/axiom/test/xpath/Makefile.am
@@ -0,0 +1,20 @@
+TESTS =
+noinst_PROGRAMS = test_xpath test_xpath_streaming
+check_PROGRAMS = test_xpath test_xpath_streaming
+SUBDIRS =
+test_xpath_SOURCES = test_xpath.c
+
+test_xpath_streaming_SOURCES = test_xpath_streaming.c
+
+test_xpath_LDADD = ../../../util/src/libaxutil.la \
+ $(top_builddir)/src/om/libaxis2_axiom.la \
+ $(top_builddir)/src/xpath/libaxis2_xpath.la
+
+test_xpath_streaming_LDADD = ../../../util/src/libaxutil.la \
+ $(top_builddir)/src/om/libaxis2_axiom.la \
+ $(top_builddir)/src/xpath/libaxis2_xpath.la
+
+INCLUDES = -I$(top_builddir)/include \
+ -I$(top_builddir)/src/parser \
+ -I ../../../include \
+ -I ../../../util/include
diff --git a/axiom/test/xpath/results.txt b/axiom/test/xpath/results.txt
new file mode 100644
index 0000000..10c7385
--- /dev/null
+++ b/axiom/test/xpath/results.txt
@@ -0,0 +1,616 @@
+
+"<child>20<grandchild>20</grandchild></child>"
+"<child>19<grandchild>19</grandchild></child>"
+"<child>18<grandchild>18</grandchild></child>"
+"<child>17<grandchild>17</grandchild></child>"
+"<child>16<grandchild>16</grandchild></child>"
+"<child>15<grandchild>15</grandchild></child>"
+"<child>14<grandchild>14</grandchild></child>"
+"<child>13<grandchild>13</grandchild></child>"
+"<child>12<grandchild>12</grandchild></child>"
+"<child>11<grandchild>11</grandchild></child>"
+"<child>10<grandchild>10</grandchild></child>"
+"<child>9<grandchild>9</grandchild></child>"
+"<child>8<grandchild>8</grandchild></child>"
+"<child>7<grandchild>7</grandchild></child>"
+"<child>6<grandchild>6</grandchild></child>"
+"<child>5<grandchild>5</grandchild></child>"
+"<child>4<grandchild>4</grandchild></child>"
+"<child>3<grandchild>3</grandchild></child>"
+"<child>2<grandchild>2</grandchild></child>"
+"<child>1<grandchild>1</grandchild></child>"
+"<child>20<grandchild>20</grandchild></child>"
+"<child>19<grandchild>19</grandchild></child>"
+"<child>18<grandchild>18</grandchild></child>"
+"<child>17<grandchild>17</grandchild></child>"
+"<child>16<grandchild>16</grandchild></child>"
+"<child>15<grandchild>15</grandchild></child>"
+"<child>14<grandchild>14</grandchild></child>"
+"<child>13<grandchild>13</grandchild></child>"
+"<child>12<grandchild>12</grandchild></child>"
+"<child>11<grandchild>11</grandchild></child>"
+"<child>10<grandchild>10</grandchild></child>"
+"<child>9<grandchild>9</grandchild></child>"
+"<child>8<grandchild>8</grandchild></child>"
+"<child>7<grandchild>7</grandchild></child>"
+"<child>6<grandchild>6</grandchild></child>"
+"<child>5<grandchild>5</grandchild></child>"
+"<child>4<grandchild>4</grandchild></child>"
+"<child xmlns:ns44="http://xpath/testsasd">3<grandchild>3</grandchild></child>"
+"<child>2<grandchild>2</grandchild></child>"
+"<child>1<grandchild>1</grandchild></child>"
+#
+"40.000000"
+#
+"<child>5<grandchild>5</grandchild></child>"
+#
+"<child>20<grandchild>20</grandchild></child>"
+"<child>19<grandchild>19</grandchild></child>"
+"<child>18<grandchild>18</grandchild></child>"
+"<child>17<grandchild>17</grandchild></child>"
+"<child>16<grandchild>16</grandchild></child>"
+"<child>15<grandchild>15</grandchild></child>"
+"<child>14<grandchild>14</grandchild></child>"
+"<child>13<grandchild>13</grandchild></child>"
+"<child>12<grandchild>12</grandchild></child>"
+"<child>11<grandchild>11</grandchild></child>"
+"<child>10<grandchild>10</grandchild></child>"
+"<child>9<grandchild>9</grandchild></child>"
+"<child>8<grandchild>8</grandchild></child>"
+"<child>7<grandchild>7</grandchild></child>"
+"<child>6<grandchild>6</grandchild></child>"
+"<child>5<grandchild>5</grandchild></child>"
+"<child>4<grandchild>4</grandchild></child>"
+"<child>3<grandchild>3</grandchild></child>"
+"<child>2<grandchild>2</grandchild></child>"
+"<child>1<grandchild>1</grandchild></child>"
+"<child>20<grandchild>20</grandchild></child>"
+"<child>19<grandchild>19</grandchild></child>"
+"<child>18<grandchild>18</grandchild></child>"
+"<child>17<grandchild>17</grandchild></child>"
+"<child>16<grandchild>16</grandchild></child>"
+"<child>15<grandchild>15</grandchild></child>"
+"<child>14<grandchild>14</grandchild></child>"
+"<child>13<grandchild>13</grandchild></child>"
+"<child>12<grandchild>12</grandchild></child>"
+"<child>11<grandchild>11</grandchild></child>"
+"<child>10<grandchild>10</grandchild></child>"
+"<child>9<grandchild>9</grandchild></child>"
+"<child>8<grandchild>8</grandchild></child>"
+"<child>7<grandchild>7</grandchild></child>"
+"<child>6<grandchild>6</grandchild></child>"
+"<child>5<grandchild>5</grandchild></child>"
+"<child>4<grandchild>4</grandchild></child>"
+"<child xmlns:ns44="http://xpath/testsasd">3<grandchild>3</grandchild></child>"
+"<child>2<grandchild>2</grandchild></child>"
+"<child>1<grandchild>1</grandchild></child>"
+#
+"<test xmlns:ns1="http://xpath/test">
+
+ <ns1:node1 attr1="attribute_value_1" xmlns:nsx="http://xpath/test">10</ns1:node1>
+
+ <ns1:node2>
+ <child>1<grandchild>1</grandchild></child>
+ <child>2<grandchild>2</grandchild></child>
+ <child xmlns:ns44="http://xpath/testsasd">3<grandchild>3</grandchild></child>
+ <child>4<grandchild>4</grandchild></child>
+ <child>5<grandchild>5</grandchild></child>
+ <child>6<grandchild>6</grandchild></child>
+ <child>7<grandchild>7</grandchild></child>
+ <child>8<grandchild>8</grandchild></child>
+ <child>9<grandchild>9</grandchild></child>
+ <child>10<grandchild>10</grandchild></child>
+ <child>11<grandchild>11</grandchild></child>
+ <child>12<grandchild>12</grandchild></child>
+ <child>13<grandchild>13</grandchild></child>
+ <child>14<grandchild>14</grandchild></child>
+ <child>15<grandchild>15</grandchild></child>
+ <child>16<grandchild>16</grandchild></child>
+ <child>17<grandchild>17</grandchild></child>
+ <child>18<grandchild>18</grandchild></child>
+ <child>19<grandchild>19</grandchild></child>
+ <child>20<grandchild>20</grandchild></child>
+ </ns1:node2>
+
+ <node1 attr1="attribute_value_2" xmlns:nsp="http://xpath/test">5</node1>
+
+ <node2>
+ <child>1<grandchild>1</grandchild></child>
+ <child>2<grandchild>2</grandchild></child>
+ <child>3<grandchild>3</grandchild></child>
+ <child>4<grandchild>4</grandchild></child>
+ <child>5<grandchild>5</grandchild></child>
+ <child>6<grandchild>6</grandchild></child>
+ <child>7<grandchild>7</grandchild></child>
+ <child>8<grandchild>8</grandchild></child>
+ <child>9<grandchild>9</grandchild></child>
+ <child>10<grandchild>10</grandchild></child>
+ <child>11<grandchild>11</grandchild></child>
+ <child>12<grandchild>12</grandchild></child>
+ <child>13<grandchild>13</grandchild></child>
+ <child>14<grandchild>14</grandchild></child>
+ <child>15<grandchild>15</grandchild></child>
+ <child>16<grandchild>16</grandchild></child>
+ <child>17<grandchild>17</grandchild></child>
+ <child>18<grandchild>18</grandchild></child>
+ <child>19<grandchild>19</grandchild></child>
+ <child>20<grandchild>20</grandchild></child>
+ </node2>
+
+</test>"
+#
+"<test xmlns:ns1="http://xpath/test">
+
+ <ns1:node1 attr1="attribute_value_1" xmlns:nsx="http://xpath/test">10</ns1:node1>
+
+ <ns1:node2>
+ <child>1<grandchild>1</grandchild></child>
+ <child>2<grandchild>2</grandchild></child>
+ <child xmlns:ns44="http://xpath/testsasd">3<grandchild>3</grandchild></child>
+ <child>4<grandchild>4</grandchild></child>
+ <child>5<grandchild>5</grandchild></child>
+ <child>6<grandchild>6</grandchild></child>
+ <child>7<grandchild>7</grandchild></child>
+ <child>8<grandchild>8</grandchild></child>
+ <child>9<grandchild>9</grandchild></child>
+ <child>10<grandchild>10</grandchild></child>
+ <child>11<grandchild>11</grandchild></child>
+ <child>12<grandchild>12</grandchild></child>
+ <child>13<grandchild>13</grandchild></child>
+ <child>14<grandchild>14</grandchild></child>
+ <child>15<grandchild>15</grandchild></child>
+ <child>16<grandchild>16</grandchild></child>
+ <child>17<grandchild>17</grandchild></child>
+ <child>18<grandchild>18</grandchild></child>
+ <child>19<grandchild>19</grandchild></child>
+ <child>20<grandchild>20</grandchild></child>
+ </ns1:node2>
+
+ <node1 attr1="attribute_value_2" xmlns:nsp="http://xpath/test">5</node1>
+
+ <node2>
+ <child>1<grandchild>1</grandchild></child>
+ <child>2<grandchild>2</grandchild></child>
+ <child>3<grandchild>3</grandchild></child>
+ <child>4<grandchild>4</grandchild></child>
+ <child>5<grandchild>5</grandchild></child>
+ <child>6<grandchild>6</grandchild></child>
+ <child>7<grandchild>7</grandchild></child>
+ <child>8<grandchild>8</grandchild></child>
+ <child>9<grandchild>9</grandchild></child>
+ <child>10<grandchild>10</grandchild></child>
+ <child>11<grandchild>11</grandchild></child>
+ <child>12<grandchild>12</grandchild></child>
+ <child>13<grandchild>13</grandchild></child>
+ <child>14<grandchild>14</grandchild></child>
+ <child>15<grandchild>15</grandchild></child>
+ <child>16<grandchild>16</grandchild></child>
+ <child>17<grandchild>17</grandchild></child>
+ <child>18<grandchild>18</grandchild></child>
+ <child>19<grandchild>19</grandchild></child>
+ <child>20<grandchild>20</grandchild></child>
+ </node2>
+
+</test>"
+"<node2>
+ <child>1<grandchild>1</grandchild></child>
+ <child>2<grandchild>2</grandchild></child>
+ <child>3<grandchild>3</grandchild></child>
+ <child>4<grandchild>4</grandchild></child>
+ <child>5<grandchild>5</grandchild></child>
+ <child>6<grandchild>6</grandchild></child>
+ <child>7<grandchild>7</grandchild></child>
+ <child>8<grandchild>8</grandchild></child>
+ <child>9<grandchild>9</grandchild></child>
+ <child>10<grandchild>10</grandchild></child>
+ <child>11<grandchild>11</grandchild></child>
+ <child>12<grandchild>12</grandchild></child>
+ <child>13<grandchild>13</grandchild></child>
+ <child>14<grandchild>14</grandchild></child>
+ <child>15<grandchild>15</grandchild></child>
+ <child>16<grandchild>16</grandchild></child>
+ <child>17<grandchild>17</grandchild></child>
+ <child>18<grandchild>18</grandchild></child>
+ <child>19<grandchild>19</grandchild></child>
+ <child>20<grandchild>20</grandchild></child>
+ </node2>"
+"<child>3<grandchild>3</grandchild></child>"
+#
+"<child>20<grandchild>20</grandchild></child>"
+"<child>19<grandchild>19</grandchild></child>"
+"<child>18<grandchild>18</grandchild></child>"
+"<child>17<grandchild>17</grandchild></child>"
+"<child>16<grandchild>16</grandchild></child>"
+"<child>15<grandchild>15</grandchild></child>"
+"<child>14<grandchild>14</grandchild></child>"
+"<child>13<grandchild>13</grandchild></child>"
+"<child>12<grandchild>12</grandchild></child>"
+"<child>11<grandchild>11</grandchild></child>"
+"<child>10<grandchild>10</grandchild></child>"
+"<child>9<grandchild>9</grandchild></child>"
+"<child>8<grandchild>8</grandchild></child>"
+"<child>7<grandchild>7</grandchild></child>"
+"<child>6<grandchild>6</grandchild></child>"
+"<child>5<grandchild>5</grandchild></child>"
+"<child>4<grandchild>4</grandchild></child>"
+#
+"<child>1<grandchild>1</grandchild></child>"
+"<child>2<grandchild>2</grandchild></child>"
+#
+"<grandchild>20</grandchild>"
+"<child>20<grandchild>20</grandchild></child>"
+"<grandchild>19</grandchild>"
+"<child>19<grandchild>19</grandchild></child>"
+"<grandchild>18</grandchild>"
+"<child>18<grandchild>18</grandchild></child>"
+"<grandchild>17</grandchild>"
+"<child>17<grandchild>17</grandchild></child>"
+"<grandchild>16</grandchild>"
+"<child>16<grandchild>16</grandchild></child>"
+"<grandchild>15</grandchild>"
+"<child>15<grandchild>15</grandchild></child>"
+"<grandchild>14</grandchild>"
+"<child>14<grandchild>14</grandchild></child>"
+"<grandchild>13</grandchild>"
+"<child>13<grandchild>13</grandchild></child>"
+"<grandchild>12</grandchild>"
+"<child>12<grandchild>12</grandchild></child>"
+"<grandchild>11</grandchild>"
+"<child>11<grandchild>11</grandchild></child>"
+"<grandchild>10</grandchild>"
+"<child>10<grandchild>10</grandchild></child>"
+"<grandchild>9</grandchild>"
+"<child>9<grandchild>9</grandchild></child>"
+"<grandchild>8</grandchild>"
+"<child>8<grandchild>8</grandchild></child>"
+"<grandchild>7</grandchild>"
+"<child>7<grandchild>7</grandchild></child>"
+"<grandchild>6</grandchild>"
+"<child>6<grandchild>6</grandchild></child>"
+"<grandchild>5</grandchild>"
+"<child>5<grandchild>5</grandchild></child>"
+"<grandchild>4</grandchild>"
+"<child>4<grandchild>4</grandchild></child>"
+"<grandchild>20</grandchild>"
+"<child>20<grandchild>20</grandchild></child>"
+"<grandchild>19</grandchild>"
+"<child>19<grandchild>19</grandchild></child>"
+"<grandchild>18</grandchild>"
+"<child>18<grandchild>18</grandchild></child>"
+"<grandchild>17</grandchild>"
+"<child>17<grandchild>17</grandchild></child>"
+"<grandchild>16</grandchild>"
+"<child>16<grandchild>16</grandchild></child>"
+"<grandchild>15</grandchild>"
+"<child>15<grandchild>15</grandchild></child>"
+"<grandchild>14</grandchild>"
+"<child>14<grandchild>14</grandchild></child>"
+"<grandchild>13</grandchild>"
+"<child>13<grandchild>13</grandchild></child>"
+"<grandchild>12</grandchild>"
+"<child>12<grandchild>12</grandchild></child>"
+"<grandchild>11</grandchild>"
+"<child>11<grandchild>11</grandchild></child>"
+"<grandchild>10</grandchild>"
+"<child>10<grandchild>10</grandchild></child>"
+"<grandchild>9</grandchild>"
+"<child>9<grandchild>9</grandchild></child>"
+"<grandchild>8</grandchild>"
+"<child>8<grandchild>8</grandchild></child>"
+"<grandchild>7</grandchild>"
+"<child>7<grandchild>7</grandchild></child>"
+"<grandchild>6</grandchild>"
+"<child>6<grandchild>6</grandchild></child>"
+"<grandchild>5</grandchild>"
+"<child>5<grandchild>5</grandchild></child>"
+"<grandchild>4</grandchild>"
+"<child>4<grandchild>4</grandchild></child>"
+#
+"<ns1:node1 xmlns:ns1="http://xpath/test" attr1="attribute_value_1" xmlns:nsx="http://xpath/test">10</ns1:node1>"
+"<grandchild>1</grandchild>"
+"<child>1<grandchild>1</grandchild></child>"
+"<grandchild>2</grandchild>"
+"<child>2<grandchild>2</grandchild></child>"
+"<grandchild>3</grandchild>"
+"<child xmlns:ns44="http://xpath/testsasd">3<grandchild>3</grandchild></child>"
+"<grandchild>4</grandchild>"
+"<child>4<grandchild>4</grandchild></child>"
+"<grandchild>5</grandchild>"
+"<child>5<grandchild>5</grandchild></child>"
+"<grandchild>6</grandchild>"
+"<child>6<grandchild>6</grandchild></child>"
+"<grandchild>7</grandchild>"
+"<child>7<grandchild>7</grandchild></child>"
+"<grandchild>8</grandchild>"
+"<child>8<grandchild>8</grandchild></child>"
+"<grandchild>9</grandchild>"
+"<child>9<grandchild>9</grandchild></child>"
+"<grandchild>10</grandchild>"
+"<child>10<grandchild>10</grandchild></child>"
+"<grandchild>11</grandchild>"
+"<child>11<grandchild>11</grandchild></child>"
+"<grandchild>12</grandchild>"
+"<child>12<grandchild>12</grandchild></child>"
+"<grandchild>13</grandchild>"
+"<child>13<grandchild>13</grandchild></child>"
+"<grandchild>14</grandchild>"
+"<child>14<grandchild>14</grandchild></child>"
+"<grandchild>15</grandchild>"
+"<child>15<grandchild>15</grandchild></child>"
+"<grandchild>16</grandchild>"
+"<child>16<grandchild>16</grandchild></child>"
+"<grandchild>17</grandchild>"
+"<child>17<grandchild>17</grandchild></child>"
+"<grandchild>18</grandchild>"
+"<child>18<grandchild>18</grandchild></child>"
+"<grandchild>19</grandchild>"
+"<child>19<grandchild>19</grandchild></child>"
+"<grandchild>20</grandchild>"
+"<child>20<grandchild>20</grandchild></child>"
+"<ns1:node2 xmlns:ns1="http://xpath/test">
+ <child>1<grandchild>1</grandchild></child>
+ <child>2<grandchild>2</grandchild></child>
+ <child xmlns:ns44="http://xpath/testsasd">3<grandchild>3</grandchild></child>
+ <child>4<grandchild>4</grandchild></child>
+ <child>5<grandchild>5</grandchild></child>
+ <child>6<grandchild>6</grandchild></child>
+ <child>7<grandchild>7</grandchild></child>
+ <child>8<grandchild>8</grandchild></child>
+ <child>9<grandchild>9</grandchild></child>
+ <child>10<grandchild>10</grandchild></child>
+ <child>11<grandchild>11</grandchild></child>
+ <child>12<grandchild>12</grandchild></child>
+ <child>13<grandchild>13</grandchild></child>
+ <child>14<grandchild>14</grandchild></child>
+ <child>15<grandchild>15</grandchild></child>
+ <child>16<grandchild>16</grandchild></child>
+ <child>17<grandchild>17</grandchild></child>
+ <child>18<grandchild>18</grandchild></child>
+ <child>19<grandchild>19</grandchild></child>
+ <child>20<grandchild>20</grandchild></child>
+ </ns1:node2>"
+"<node1 attr1="attribute_value_2" xmlns:nsp="http://xpath/test">5</node1>"
+"<grandchild>1</grandchild>"
+"<child>1<grandchild>1</grandchild></child>"
+"<grandchild>2</grandchild>"
+"<child>2<grandchild>2</grandchild></child>"
+#
+attr1 = "attribute_value_2"
+attr1 = "attribute_value_1"
+#
+nsp = "http://xpath/test"
+nsx = "http://xpath/test"
+#
+"<node1 attr1="attribute_value_2" xmlns:nsp="http://xpath/test">5</node1>"
+#
+"<child>20<grandchild>20</grandchild></child>"
+"<child>19<grandchild>19</grandchild></child>"
+"<child>18<grandchild>18</grandchild></child>"
+"<child>17<grandchild>17</grandchild></child>"
+"<child>16<grandchild>16</grandchild></child>"
+"<child>15<grandchild>15</grandchild></child>"
+"<child>14<grandchild>14</grandchild></child>"
+"<child>13<grandchild>13</grandchild></child>"
+"<child>12<grandchild>12</grandchild></child>"
+"<child>11<grandchild>11</grandchild></child>"
+"<child>10<grandchild>10</grandchild></child>"
+"<child>9<grandchild>9</grandchild></child>"
+"<child>8<grandchild>8</grandchild></child>"
+"<child>7<grandchild>7</grandchild></child>"
+"<child>6<grandchild>6</grandchild></child>"
+"<child>5<grandchild>5</grandchild></child>"
+"<child>4<grandchild>4</grandchild></child>"
+"<child>3<grandchild>3</grandchild></child>"
+"<child>2<grandchild>2</grandchild></child>"
+"<child>1<grandchild>1</grandchild></child>"
+"<child>20<grandchild>20</grandchild></child>"
+"<child>19<grandchild>19</grandchild></child>"
+"<child>18<grandchild>18</grandchild></child>"
+"<child>17<grandchild>17</grandchild></child>"
+"<child>16<grandchild>16</grandchild></child>"
+"<child>15<grandchild>15</grandchild></child>"
+"<child>14<grandchild>14</grandchild></child>"
+"<child>13<grandchild>13</grandchild></child>"
+"<child>12<grandchild>12</grandchild></child>"
+"<child>11<grandchild>11</grandchild></child>"
+"<child>10<grandchild>10</grandchild></child>"
+"<child>9<grandchild>9</grandchild></child>"
+"<child>8<grandchild>8</grandchild></child>"
+"<child>7<grandchild>7</grandchild></child>"
+"<child>6<grandchild>6</grandchild></child>"
+"<child>5<grandchild>5</grandchild></child>"
+"<child>4<grandchild>4</grandchild></child>"
+"<child xmlns:ns44="http://xpath/testsasd">3<grandchild>3</grandchild></child>"
+"<child>2<grandchild>2</grandchild></child>"
+"<child>1<grandchild>1</grandchild></child>"
+#
+"<child>4<grandchild>4</grandchild></child>"
+#
+"<grandchild>20</grandchild>"
+"<grandchild>19</grandchild>"
+"<grandchild>18</grandchild>"
+"<grandchild>17</grandchild>"
+"<grandchild>16</grandchild>"
+"<grandchild>15</grandchild>"
+"<grandchild>14</grandchild>"
+"<grandchild>13</grandchild>"
+"<grandchild>12</grandchild>"
+"<grandchild>11</grandchild>"
+"<grandchild>10</grandchild>"
+"<grandchild>9</grandchild>"
+"<grandchild>8</grandchild>"
+"<grandchild>7</grandchild>"
+"<grandchild>6</grandchild>"
+"<grandchild>5</grandchild>"
+"<grandchild>4</grandchild>"
+"<grandchild>3</grandchild>"
+"<grandchild>2</grandchild>"
+"<grandchild>1</grandchild>"
+#
+"<child>20<grandchild>20</grandchild></child>"
+"<child>19<grandchild>19</grandchild></child>"
+"<child>18<grandchild>18</grandchild></child>"
+"<child>17<grandchild>17</grandchild></child>"
+"<child>16<grandchild>16</grandchild></child>"
+"<child>15<grandchild>15</grandchild></child>"
+"<child>14<grandchild>14</grandchild></child>"
+"<child>13<grandchild>13</grandchild></child>"
+"<child>12<grandchild>12</grandchild></child>"
+"<child>11<grandchild>11</grandchild></child>"
+"<child>10<grandchild>10</grandchild></child>"
+"<child>9<grandchild>9</grandchild></child>"
+"<child>8<grandchild>8</grandchild></child>"
+"<child>7<grandchild>7</grandchild></child>"
+"<child>6<grandchild>6</grandchild></child>"
+"<child>5<grandchild>5</grandchild></child>"
+"<child>4<grandchild>4</grandchild></child>"
+"<child xmlns:ns44="http://xpath/testsasd">3<grandchild>3</grandchild></child>"
+"<child>2<grandchild>2</grandchild></child>"
+"<child>1<grandchild>1</grandchild></child>"
+#
+"<child>20<grandchild>20</grandchild></child>"
+"<child>19<grandchild>19</grandchild></child>"
+"<child>18<grandchild>18</grandchild></child>"
+"<child>17<grandchild>17</grandchild></child>"
+"<child>16<grandchild>16</grandchild></child>"
+"<child>15<grandchild>15</grandchild></child>"
+"<child>14<grandchild>14</grandchild></child>"
+"<child>13<grandchild>13</grandchild></child>"
+"<child>12<grandchild>12</grandchild></child>"
+"<child>11<grandchild>11</grandchild></child>"
+"<child>10<grandchild>10</grandchild></child>"
+"<child>9<grandchild>9</grandchild></child>"
+"<child>8<grandchild>8</grandchild></child>"
+"<child>7<grandchild>7</grandchild></child>"
+"<child>6<grandchild>6</grandchild></child>"
+"<child>5<grandchild>5</grandchild></child>"
+"<child>4<grandchild>4</grandchild></child>"
+"<child xmlns:ns44="http://xpath/testsasd">3<grandchild>3</grandchild></child>"
+"<child>2<grandchild>2</grandchild></child>"
+"<child>1<grandchild>1</grandchild></child>"
+#
+attr1 = "attribute_value_2"
+#
+"<node1 attr1="attribute_value_2" xmlns:nsp="http://xpath/test">5</node1>"
+"<ns1:node1 xmlns:ns1="http://xpath/test" attr1="attribute_value_1" xmlns:nsx="http://xpath/test">10</ns1:node1>"
+#
+"<ns1:node1 xmlns:ns1="http://xpath/test" attr1="attribute_value_1" xmlns:nsx="http://xpath/test">10</ns1:node1>"
+#
+"<child>5<grandchild>5</grandchild></child>"
+#
+"true"
+#
+"<grandchild>20</grandchild>"
+"<grandchild>19</grandchild>"
+"<grandchild>18</grandchild>"
+"<grandchild>17</grandchild>"
+"<grandchild>16</grandchild>"
+"<grandchild>15</grandchild>"
+"<grandchild>14</grandchild>"
+"<grandchild>13</grandchild>"
+"<grandchild>12</grandchild>"
+"<grandchild>11</grandchild>"
+"<grandchild>10</grandchild>"
+"<grandchild>9</grandchild>"
+"<grandchild>8</grandchild>"
+"<grandchild>7</grandchild>"
+"<grandchild>6</grandchild>"
+"<grandchild>5</grandchild>"
+"<grandchild>4</grandchild>"
+"<grandchild>3</grandchild>"
+"<grandchild>2</grandchild>"
+"<grandchild>1</grandchild>"
+#
+"<child>20<grandchild>20</grandchild></child>"
+"<child>19<grandchild>19</grandchild></child>"
+"<child>18<grandchild>18</grandchild></child>"
+"<child>17<grandchild>17</grandchild></child>"
+"<child>16<grandchild>16</grandchild></child>"
+"<child>15<grandchild>15</grandchild></child>"
+"<child>14<grandchild>14</grandchild></child>"
+"<child>13<grandchild>13</grandchild></child>"
+"<child>12<grandchild>12</grandchild></child>"
+"<child>11<grandchild>11</grandchild></child>"
+"<child>10<grandchild>10</grandchild></child>"
+"<child>9<grandchild>9</grandchild></child>"
+"<child>8<grandchild>8</grandchild></child>"
+"<child>7<grandchild>7</grandchild></child>"
+"<child>6<grandchild>6</grandchild></child>"
+"<child>5<grandchild>5</grandchild></child>"
+"<child>4<grandchild>4</grandchild></child>"
+"<child>3<grandchild>3</grandchild></child>"
+"<child>2<grandchild>2</grandchild></child>"
+"<child>1<grandchild>1</grandchild></child>"
+#
+"<child>20<grandchild>20</grandchild></child>"
+"<child>19<grandchild>19</grandchild></child>"
+"<child>18<grandchild>18</grandchild></child>"
+"<child>17<grandchild>17</grandchild></child>"
+"<child>16<grandchild>16</grandchild></child>"
+"<child>15<grandchild>15</grandchild></child>"
+"<child>14<grandchild>14</grandchild></child>"
+"<child>13<grandchild>13</grandchild></child>"
+"<child>12<grandchild>12</grandchild></child>"
+"<child>11<grandchild>11</grandchild></child>"
+"<child>10<grandchild>10</grandchild></child>"
+"<child>9<grandchild>9</grandchild></child>"
+"<child>8<grandchild>8</grandchild></child>"
+"<child>7<grandchild>7</grandchild></child>"
+"<child>6<grandchild>6</grandchild></child>"
+"<child>5<grandchild>5</grandchild></child>"
+"<child>4<grandchild>4</grandchild></child>"
+"<child>3<grandchild>3</grandchild></child>"
+"<child>2<grandchild>2</grandchild></child>"
+"<child>1<grandchild>1</grandchild></child>"
+#
+"<node1 attr1="attribute_value_2" xmlns:nsp="http://xpath/test">5</node1>"
+"<ns1:node1 xmlns:ns1="http://xpath/test" attr1="attribute_value_1" xmlns:nsx="http://xpath/test">10</ns1:node1>"
+#
+"<node2>
+ <child>1<grandchild>1</grandchild></child>
+ <child>2<grandchild>2</grandchild></child>
+ <child>3<grandchild>3</grandchild></child>
+ <child>4<grandchild>4</grandchild></child>
+ <child>5<grandchild>5</grandchild></child>
+ <child>6<grandchild>6</grandchild></child>
+ <child>7<grandchild>7</grandchild></child>
+ <child>8<grandchild>8</grandchild></child>
+ <child>9<grandchild>9</grandchild></child>
+ <child>10<grandchild>10</grandchild></child>
+ <child>11<grandchild>11</grandchild></child>
+ <child>12<grandchild>12</grandchild></child>
+ <child>13<grandchild>13</grandchild></child>
+ <child>14<grandchild>14</grandchild></child>
+ <child>15<grandchild>15</grandchild></child>
+ <child>16<grandchild>16</grandchild></child>
+ <child>17<grandchild>17</grandchild></child>
+ <child>18<grandchild>18</grandchild></child>
+ <child>19<grandchild>19</grandchild></child>
+ <child>20<grandchild>20</grandchild></child>
+ </node2>"
+#
+"<ns1:node2 xmlns:ns1="http://xpath/test">
+ <child>1<grandchild>1</grandchild></child>
+ <child>2<grandchild>2</grandchild></child>
+ <child xmlns:ns44="http://xpath/testsasd">3<grandchild>3</grandchild></child>
+ <child>4<grandchild>4</grandchild></child>
+ <child>5<grandchild>5</grandchild></child>
+ <child>6<grandchild>6</grandchild></child>
+ <child>7<grandchild>7</grandchild></child>
+ <child>8<grandchild>8</grandchild></child>
+ <child>9<grandchild>9</grandchild></child>
+ <child>10<grandchild>10</grandchild></child>
+ <child>11<grandchild>11</grandchild></child>
+ <child>12<grandchild>12</grandchild></child>
+ <child>13<grandchild>13</grandchild></child>
+ <child>14<grandchild>14</grandchild></child>
+ <child>15<grandchild>15</grandchild></child>
+ <child>16<grandchild>16</grandchild></child>
+ <child>17<grandchild>17</grandchild></child>
+ <child>18<grandchild>18</grandchild></child>
+ <child>19<grandchild>19</grandchild></child>
+ <child>20<grandchild>20</grandchild></child>
+ </ns1:node2>"
+#
+attr1 = "attribute_value_1"
+# \ No newline at end of file
diff --git a/axiom/test/xpath/test.ns b/axiom/test/xpath/test.ns
new file mode 100644
index 0000000..45508e2
--- /dev/null
+++ b/axiom/test/xpath/test.ns
@@ -0,0 +1,2 @@
+test
+http://xpath/test
diff --git a/axiom/test/xpath/test.xml b/axiom/test/xpath/test.xml
new file mode 100644
index 0000000..fa0adb6
--- /dev/null
+++ b/axiom/test/xpath/test.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<test xmlns:ns1="http://xpath/test">
+
+ <ns1:node1 xmlns:nsx="http://xpath/test" attr1="attribute_value_1">10</ns1:node1>
+
+ <ns1:node2>
+ <child>1<grandchild>1</grandchild></child>
+ <child>2<grandchild>2</grandchild></child>
+ <child xmlns:ns44="http://xpath/testsasd">3<grandchild>3</grandchild></child>
+ <child>4<grandchild>4</grandchild></child>
+ <child>5<grandchild>5</grandchild></child>
+ <child>6<grandchild>6</grandchild></child>
+ <child>7<grandchild>7</grandchild></child>
+ <child>8<grandchild>8</grandchild></child>
+ <child>9<grandchild>9</grandchild></child>
+ <child>10<grandchild>10</grandchild></child>
+ <child>11<grandchild>11</grandchild></child>
+ <child>12<grandchild>12</grandchild></child>
+ <child>13<grandchild>13</grandchild></child>
+ <child>14<grandchild>14</grandchild></child>
+ <child>15<grandchild>15</grandchild></child>
+ <child>16<grandchild>16</grandchild></child>
+ <child>17<grandchild>17</grandchild></child>
+ <child>18<grandchild>18</grandchild></child>
+ <child>19<grandchild>19</grandchild></child>
+ <child>20<grandchild>20</grandchild></child>
+ </ns1:node2>
+
+ <node1 xmlns:nsp="http://xpath/test" attr1="attribute_value_2">5</node1>
+
+ <node2>
+ <child>1<grandchild>1</grandchild></child>
+ <child>2<grandchild>2</grandchild></child>
+ <child>3<grandchild>3</grandchild></child>
+ <child>4<grandchild>4</grandchild></child>
+ <child>5<grandchild>5</grandchild></child>
+ <child>6<grandchild>6</grandchild></child>
+ <child>7<grandchild>7</grandchild></child>
+ <child>8<grandchild>8</grandchild></child>
+ <child>9<grandchild>9</grandchild></child>
+ <child>10<grandchild>10</grandchild></child>
+ <child>11<grandchild>11</grandchild></child>
+ <child>12<grandchild>12</grandchild></child>
+ <child>13<grandchild>13</grandchild></child>
+ <child>14<grandchild>14</grandchild></child>
+ <child>15<grandchild>15</grandchild></child>
+ <child>16<grandchild>16</grandchild></child>
+ <child>17<grandchild>17</grandchild></child>
+ <child>18<grandchild>18</grandchild></child>
+ <child>19<grandchild>19</grandchild></child>
+ <child>20<grandchild>20</grandchild></child>
+ </node2>
+
+</test>
diff --git a/axiom/test/xpath/test.xpath b/axiom/test/xpath/test.xpath
new file mode 100644
index 0000000..1ebe4a8
--- /dev/null
+++ b/axiom/test/xpath/test.xpath
@@ -0,0 +1,37 @@
+#Test: Functions
+test/descendant::child
+count(test/descendant::child)
+#Test: Axes
+test/node2/child::child[5]
+test/descendant::child
+test/node2/parent::*
+test/node2/child[3]/grandchild/ancestor::*
+test/node2/child[3]/following-sibling::*
+test/node2/child[3]/preceding-sibling::*
+test/node2/child[3]/following::*
+test/node2/child[3]/preceding::*
+test/*/attribute::*
+test/*/namespace::*
+test/node1/self::*
+test/descendant-or-self::child
+test/node2/child[4]/grandchild/ancestor-or-self::child
+#Test: Namespaces
+test/test:node2//grandchild
+test/test:node2/child
+test/test:node2/*
+#Test: Attributes and Predicates
+test/node1/@*
+//*[@*]
+//*[@attr1 = 'attribute_value_1']
+test/node2/child[grandchild = /test/node1]
+#Test: Equality Expressions
+test/node1 = test/node2/child
+#Test: Abbreviated Axes
+test/node2//grandchild
+test/node2/child
+test/node2/*
+#Test: Random
+test/*[@*]
+test/node2
+test/test:node2
+test/test:node1/@*
diff --git a/axiom/test/xpath/test_xpath.c b/axiom/test/xpath/test_xpath.c
new file mode 100644
index 0000000..95e0d94
--- /dev/null
+++ b/axiom/test/xpath/test_xpath.c
@@ -0,0 +1,513 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+Compiling For Windows:
+cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" /I %AXIS2C_HOME%\include /c *.c
+link.exe /LIBPATH:%AXIS2C_HOME%\lib axutil.lib axiom.lib axis2_parser.lib axis2_engine.lib /OUT:test.exe *.obj
+*/
+#include <stdio.h>
+#include <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axiom_xpath.h>
+
+/* Function headers */
+axiom_node_t *build_test_xml(const axutil_env_t *env);
+
+void output_results(const axutil_env_t *env, axiom_xpath_result_t *xpath_result);
+
+axiom_node_t *read_test_xml(const axutil_env_t *env, char *file_name);
+
+void output_results(const axutil_env_t *env,
+ axiom_xpath_result_t *xpath_result);
+
+void evaluate(const axutil_env_t *env,
+ axiom_xpath_context_t *context,
+ axis2_char_t *expr_str);
+
+void evaluate_expressions(const axutil_env_t *env,
+ axiom_xpath_context_t *context,
+ char *file_name);
+
+void add_namespaces(const axutil_env_t *env,
+ axiom_xpath_context_t *context,
+ char *file_name);
+
+int readline(FILE *fin, char *str);
+
+FILE *fcor;
+/*FILE *ftemp;*/
+
+int main(int argc, char *argv[])
+{
+ axiom_node_t *test_tree = NULL;
+ axis2_char_t *test_tree_str;
+ char *xml_file = "test.xml";
+ char *xpath_file = "test.xpath";
+ char *ns_file = "test.ns";
+ char *cor_file = "results.txt";
+ axiom_xpath_context_t *context = NULL;
+
+ /* Create environment */
+ axutil_env_t *env =
+ axutil_env_create_all("xpath_test.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set input file */
+ if (argc > 1)
+ {
+ printf("Usage: test [xml_file xpath_file namespaces_file results_file]\n\n");
+ printf("\tLook at the example test case:");
+ printf(" test.xml, test.xpath test.ns\n\n");
+
+ if(argc > 4)
+ {
+ xml_file = argv[1];
+ xpath_file = argv[2];
+ ns_file = argv[3];
+ cor_file = argv[4];
+ }
+ }
+
+ /*Create the request */
+ /* test_tree = build_test_xml(env); */
+ test_tree = read_test_xml(env, (axis2_char_t *)xml_file);
+
+ fcor = fopen(cor_file, "r");
+ /*ftemp = fopen("temp.txt", "w");*/
+
+ if (!fcor)
+ {
+ printf("Error opening file: %s\n", cor_file);
+ }
+
+ if (test_tree)
+ {
+ test_tree_str = axiom_node_to_string(test_tree, env);
+ printf("\nTesting XML\n-----------\n\"%s\"\n\n\n", test_tree_str);
+
+ /* Create XPath Context */
+ context = axiom_xpath_context_create(env, test_tree);
+
+ /* Namespaces */
+ add_namespaces(env, context, ns_file);
+
+ evaluate_expressions(env, context, xpath_file);
+
+ test_tree_str = axiom_node_to_string(test_tree, env);
+ printf("\n\nFinal XML\n-----------\n\"%s\"\n\n\n", test_tree_str);
+ }
+
+ /* Freeing memory */
+ if (context)
+ {
+ axiom_xpath_free_context(env, context);
+ }
+
+ if (test_tree)
+ {
+ axiom_node_free_tree(test_tree, env);
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ }
+
+ if(fcor)
+ {
+ fclose(fcor);
+ }
+
+ return 0;
+}
+
+int readline(FILE *fin, char *str)
+{
+ int i;
+
+ for (i = 0; 1; i++)
+ {
+ str[i] = (char)getc(fin);
+
+ if (str[i] == '\n' || str[i] == '\r' || str[i] == EOF)
+ {
+ break;
+ }
+ }
+
+ str[i] = '\0';
+
+ return i;
+}
+
+void add_namespaces(const axutil_env_t *env,
+ axiom_xpath_context_t *context,
+ char *file_name)
+{
+ FILE *fin = NULL;
+ char prefix[1024];
+ char uri[1024];
+ axiom_namespace_t *ns;
+
+ fin = fopen(file_name, "r");
+
+ if (!fin)
+ {
+ printf("Error opening file: %s\n", file_name);
+ return;
+ }
+
+ /* Compiling XPath expression */
+ while (1)
+ {
+ if (readline(fin, prefix) == 0)
+ {
+ break;
+ }
+
+ if (readline(fin, uri) == 0)
+ {
+ break;
+ }
+
+ ns = axiom_namespace_create(
+ env, (axis2_char_t *)uri, (axis2_char_t *)prefix);
+
+ if (ns)
+ {
+ axiom_xpath_register_namespace(context, ns);
+ }
+ }
+
+ fclose(fin);
+}
+
+void evaluate_expressions(
+ const axutil_env_t *env,
+ axiom_xpath_context_t *context,
+ char *file_name)
+{
+ FILE *fin = NULL;
+ char str[1024];
+
+ fin = fopen(file_name, "r");
+
+ if (!fin)
+ {
+ printf("Error opening file: %s\n", file_name);
+ return;
+ }
+
+ /* Compiling XPath expression */
+ while (1)
+ {
+ if (readline(fin, str) == 0)
+ {
+ break;
+ }
+
+ if (str[0] == '#')
+ {
+ printf("\n\n%s", str + 1);
+ continue;
+ }
+
+ evaluate(env, context, (axis2_char_t *)str);
+ }
+
+ fclose(fin);
+}
+
+void evaluate(
+ const axutil_env_t *env,
+ axiom_xpath_context_t *context,
+ axis2_char_t *expr_str)
+{
+ axiom_xpath_expression_t *expr = NULL;
+ axiom_xpath_result_t *result = NULL;
+
+ printf("\nCompiling XPath expression: \"%s\" ...\n", expr_str);
+ expr = axiom_xpath_compile_expression(env, expr_str);
+
+ if (!expr)
+ {
+ printf("Compilation error.");
+ printf("Please check the systax of the XPath query.\n");
+
+ return;
+ }
+
+ /* Evaluating XPath expression */
+ printf("Evaluating...\n");
+ result = axiom_xpath_evaluate(context, expr);
+
+ if (!result)
+ {
+ printf("An error occured while evaluating the expression.\n");
+
+ axiom_xpath_free_expression(env, expr);
+
+ return;
+ }
+
+ if (result->flag == AXIOM_XPATH_ERROR_STREAMING_NOT_SUPPORTED)
+ {
+ printf("Streaming not supported.\n");
+
+ axiom_xpath_free_expression(env, expr);
+
+ return;
+ }
+
+ output_results(env, result);
+
+ if (result)
+ {
+ axiom_xpath_free_result(env, result);
+ }
+
+ if (expr)
+ {
+ axiom_xpath_free_expression(env, expr);
+ }
+}
+
+int compare_result(axis2_char_t *rs)
+{
+ int i;
+ char c;
+
+ /*fprintf(ftemp, "%s#", rs);*/
+
+ if(!fcor)
+ {
+ return 0;
+ }
+
+ for(i = 0; 1; i++)
+ {
+ while(rs[i] == ' ' || rs[i] == '\n' || rs[i] == '\r' || rs[i] == '\t')
+ {
+ i++;
+ }
+
+ do
+ {
+ c = (char)getc(fcor);
+ }
+ while(c == ' ' || c == '\n' || c == '\r' || c == '\t');
+
+ if(c == '#' || c == EOF)
+ {
+ break;
+ }
+
+ if(c != rs[i])
+ {
+ while(c != '#' && c != EOF)
+ {
+ c = getc(fcor);
+ }
+
+ return 0;
+ }
+ }
+
+ return rs[i] == '\0';
+}
+
+void output_results(const axutil_env_t *env,
+ axiom_xpath_result_t *xpath_result)
+{
+ axiom_xpath_result_node_t *xpath_result_node;
+ axiom_node_t *result_node;
+ axis2_char_t *result_str;
+ axis2_char_t result_set[100000];
+ axis2_char_t temp_res[100000];
+
+ axiom_element_t *ele;
+ int i;
+
+ result_set[0] = '\n';
+ result_set[1] = '\0';
+
+ for (i = 0; i < axutil_array_list_size(xpath_result->nodes, env); i++)
+ {
+ xpath_result_node = axutil_array_list_get(xpath_result->nodes, env, i);
+
+ if (xpath_result_node->type == AXIOM_XPATH_TYPE_NODE)
+ {
+ result_node = xpath_result_node->value;
+ ele = (axiom_element_t *)axiom_node_get_data_element(
+ result_node, env);
+
+ if (ele)
+ {
+ /*result_str = axiom_element_get_text(ele, env, result_node);*/
+ result_str = axiom_node_to_string(result_node, env);
+
+ sprintf(temp_res, "\"%s\"\n", result_str);
+ strcat(result_set, temp_res);
+ }
+ }
+ else if (xpath_result_node->type == AXIOM_XPATH_TYPE_ATTRIBUTE)
+ {
+ result_str =
+ axiom_attribute_get_localname(xpath_result_node->value, env);
+ sprintf(temp_res, "%s = ", result_str);
+ strcat(result_set, temp_res);
+ result_str =
+ axiom_attribute_get_value(xpath_result_node->value, env);
+ sprintf(temp_res, "\"%s\"\n", result_str);
+ strcat(result_set, temp_res);
+ }
+ else if (xpath_result_node->type == AXIOM_XPATH_TYPE_NAMESPACE)
+ {
+ result_str =
+ axiom_namespace_get_prefix(xpath_result_node->value, env);
+ sprintf(temp_res, "%s = ", result_str);
+ strcat(result_set, temp_res);
+ result_str =
+ axiom_namespace_get_uri(xpath_result_node->value, env);
+ sprintf(temp_res, "\"%s\"\n", result_str);
+ strcat(result_set, temp_res);
+ }
+ else if (xpath_result_node->type == AXIOM_XPATH_TYPE_BOOLEAN)
+ {
+ sprintf(temp_res, "\"%s\"\n",
+ (*(axis2_bool_t *)xpath_result_node->value) ? "true" : "false");
+ strcat(result_set, temp_res);
+ }
+ else if (xpath_result_node->type == AXIOM_XPATH_TYPE_TEXT)
+ {
+ sprintf(temp_res, "\"%s\"\n",
+ (axis2_char_t *)xpath_result_node->value);
+ strcat(result_set, temp_res);
+ }
+ else if (xpath_result_node->type == AXIOM_XPATH_TYPE_NUMBER)
+ {
+ sprintf(temp_res, "\"%lf\"\n",
+ *(double *)xpath_result_node->value);
+ strcat(result_set, temp_res);
+ }
+ }
+
+ if(compare_result(result_set))
+ {
+ printf("Test case passed\n");
+ }
+ else
+ {
+ printf("Failed test case!\nOutput\n%s\n", result_set);
+ }
+}
+
+axiom_node_t *read_test_xml(const axutil_env_t *env, axis2_char_t *file_name)
+{
+ axiom_xml_reader_t *reader = NULL;
+ axiom_stax_builder_t *builder = NULL;
+ axiom_document_t *document = NULL;
+ axiom_node_t *root = NULL;
+
+ /* Create parser */
+ reader = axiom_xml_reader_create_for_file(env, file_name, NULL);
+
+ if (!reader)
+ {
+ printf("Error creating pullparser");
+ return NULL;
+ }
+
+ /* Create axiom_stax_builder */
+ builder = axiom_stax_builder_create(env, reader);
+
+ if (!builder)
+ {
+ printf("Error creating pull parser");
+ return NULL;
+ }
+
+ /* Create an om document */
+ document = axiom_stax_builder_get_document(builder, env);
+
+ if (!document)
+ {
+ printf("Error creating document");
+ return NULL;
+ }
+
+ /* Get root element */
+ root = axiom_document_get_root_element(document, env);
+ if (!root)
+ {
+ printf("Root element null ");
+ axiom_stax_builder_free(builder, env);
+ return NULL;
+ }
+
+ while (axiom_document_build_next(document, env));
+
+ return root;
+}
+
+axiom_node_t * build_test_xml(const axutil_env_t *env)
+{
+ axiom_node_t *main_node;
+ axiom_node_t *order_node;
+ axiom_node_t *values_node;
+ axiom_node_t *value_node;
+ axiom_node_t *grandchild;
+ axis2_char_t value_str[255];
+ axiom_element_t *order_ele;
+ axiom_element_t *values_ele;
+ axiom_element_t *value_ele;
+ axiom_element_t *grandchild_ele;
+ axiom_attribute_t *attribute;
+ int i, N = 20;
+
+ axiom_namespace_t *ns1 =
+ axiom_namespace_create(env, "http://xpath/test", "ns1");
+
+ axiom_element_create(env, NULL, "test", ns1, &main_node);
+
+ order_ele =
+ axiom_element_create(env, main_node, "node1", NULL, &order_node);
+ axiom_element_set_text(order_ele, env, "10", order_node);
+ attribute =
+ axiom_attribute_create(env, "attr1", "attribute_value_1", NULL);
+ axiom_element_add_attribute(order_ele, env, attribute, order_node);
+
+ values_ele =
+ axiom_element_create(env, main_node, "node2", NULL, &values_node);
+
+ for (i = 0 ; i < N; i++)
+ {
+ sprintf(value_str, "%d", i + 1);
+
+ value_ele =
+ axiom_element_create(env, values_node, "child", NULL, &value_node);
+ axiom_element_set_text(value_ele, env, value_str, value_node);
+
+ grandchild_ele =
+ axiom_element_create(env, value_node, "grandchild", NULL, &grandchild);
+ axiom_element_set_text(grandchild_ele, env, value_str /*"3 rd level"*/, grandchild);
+ }
+
+ return main_node;
+}
diff --git a/axiom/test/xpath/test_xpath_streaming.c b/axiom/test/xpath/test_xpath_streaming.c
new file mode 100644
index 0000000..6b64262
--- /dev/null
+++ b/axiom/test/xpath/test_xpath_streaming.c
@@ -0,0 +1,468 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+Compiling For Windows:
+cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" /I %AXIS2C_HOME%\include /c *.c
+link.exe /LIBPATH:%AXIS2C_HOME%\lib axutil.lib axiom.lib axis2_parser.lib axis2_engine.lib /OUT:test.exe *.obj
+*/
+#include <stdio.h>
+#include <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axiom_xpath.h>
+
+/* Function headers */
+void output_results(const axutil_env_t *env, axiom_xpath_result_t *xpath_result);
+
+axiom_node_t *read_test_xml(const axutil_env_t *env, char *file_name);
+
+void output_results(const axutil_env_t *env,
+ axiom_xpath_result_t *xpath_result);
+
+void evaluate(const axutil_env_t *env,
+ axis2_char_t *expr_str);
+
+void evaluate_expressions(const axutil_env_t *env,
+ char *file_name);
+
+void add_namespaces(const axutil_env_t *env,
+ axiom_xpath_context_t *context,
+ char *file_name);
+
+int readline(FILE *fin, char *str);
+
+FILE *fcor;
+char *xml_file = "test.xml";
+char *xpath_file = "test.xpath";
+char *cor_file = "results.txt";
+char *ns_file = "test.ns";
+
+/*FILE *ftemp;*/
+
+int main(int argc, char *argv[])
+{
+ axiom_node_t *test_tree = NULL;
+ axis2_char_t *test_tree_str;
+
+ /* Create environment */
+ axutil_env_t *env =
+ axutil_env_create_all("xpath_test.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set input file */
+ if (argc > 1)
+ {
+ printf("Usage: test [xml_file xpath_file namespaces_file results_file]\n\n");
+ printf("\tLook at the example test case:");
+ printf(" test.xml, test.xpath test.ns\n\n");
+
+ if(argc > 4)
+ {
+ xml_file = argv[1];
+ xpath_file = argv[2];
+ ns_file = argv[3];
+ cor_file = argv[4];
+ }
+ }
+
+ /*Create the request */
+ test_tree = read_test_xml(env, (axis2_char_t *)xml_file);
+
+ fcor = fopen(cor_file, "r");
+ /*ftemp = fopen("temp.txt", "w");*/
+
+ if (!fcor)
+ {
+ printf("Error opening file: %s\n", cor_file);
+ }
+
+ if (test_tree)
+ {
+ test_tree_str = axiom_node_to_string(test_tree, env);
+ printf("\nTesting XML\n-----------\n\"%s\"\n\n\n", test_tree_str);
+
+ axiom_node_free_tree(test_tree, env);
+
+ evaluate_expressions(env, xpath_file);
+ }
+
+ /* Freeing memory */
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ }
+
+ if(fcor)
+ {
+ fclose(fcor);
+ }
+
+ return 0;
+}
+
+int readline(FILE *fin, char *str)
+{
+ int i;
+
+ for (i = 0; 1; i++)
+ {
+ str[i] = (char)getc(fin);
+
+ if (str[i] == '\n' || str[i] == '\r' || str[i] == EOF)
+ {
+ break;
+ }
+ }
+
+ str[i] = '\0';
+
+ return i;
+}
+
+void add_namespaces(const axutil_env_t *env,
+ axiom_xpath_context_t *context,
+ char *file_name)
+{
+ FILE *fin = NULL;
+ char prefix[1024];
+ char uri[1024];
+ axiom_namespace_t *ns;
+
+ fin = fopen(file_name, "r");
+
+ if (!fin)
+ {
+ printf("Error opening file: %s\n", file_name);
+ return;
+ }
+
+ /* Compiling XPath expression */
+ while (1)
+ {
+ if (readline(fin, prefix) == 0)
+ {
+ break;
+ }
+
+ if (readline(fin, uri) == 0)
+ {
+ break;
+ }
+
+ ns = axiom_namespace_create(
+ env, (axis2_char_t *)uri, (axis2_char_t *)prefix);
+
+ if (ns)
+ {
+ axiom_xpath_register_namespace(context, ns);
+ }
+ }
+
+ fclose(fin);
+}
+
+void evaluate_expressions(
+ const axutil_env_t *env,
+ char *file_name)
+{
+ FILE *fin = NULL;
+ char str[1024];
+
+ fin = fopen(file_name, "r");
+
+ if (!fin)
+ {
+ printf("Error opening file: %s\n", file_name);
+ return;
+ }
+
+ /* Compiling XPath expression */
+ while (1)
+ {
+ if (readline(fin, str) == 0)
+ {
+ break;
+ }
+
+ if (str[0] == '#')
+ {
+ printf("\n\n%s", str + 1);
+ continue;
+ }
+
+ evaluate(env, (axis2_char_t *)str);
+ }
+
+ fclose(fin);
+}
+
+void evaluate(
+ const axutil_env_t *env,
+ axis2_char_t *expr_str)
+{
+ axiom_xpath_expression_t *expr = NULL;
+ axiom_xpath_result_t *result = NULL;
+ axiom_node_t *test_tree = NULL;
+ axiom_xpath_context_t *context = NULL;
+
+ test_tree = read_test_xml(env, (axis2_char_t *)xml_file);
+
+ if(!test_tree)
+ {
+ printf("Error reading file: %s\n", xml_file);
+ return;
+ }
+
+ /* Create XPath Context */
+ context = axiom_xpath_context_create(env, test_tree);
+
+ if(!context)
+ {
+ printf("Could not initialise XPath context\n");
+ return;
+ }
+
+ /* Namespaces */
+ add_namespaces(env, context, ns_file);
+
+
+ printf("\nCompiling XPath expression: \"%s\" ...\n", expr_str);
+ expr = axiom_xpath_compile_expression(env, expr_str);
+
+ if (!expr)
+ {
+ printf("Compilation error.");
+ printf("Please check the systax of the XPath query.\n");
+
+ return;
+ }
+
+ /* Evaluating XPath expression */
+ printf("Evaluating...\n");
+ result = axiom_xpath_evaluate_streaming(context, expr);
+
+ if (!result)
+ {
+ compare_result("");
+ printf("An error occured while evaluating the expression.\n");
+
+ axiom_xpath_free_expression(env, expr);
+
+ return;
+ }
+
+ if (result->flag == AXIOM_XPATH_ERROR_STREAMING_NOT_SUPPORTED)
+ {
+ compare_result("");
+ printf("Streaming not supported.\n");
+
+ axiom_xpath_free_expression(env, expr);
+
+ return;
+ }
+
+ output_results(env, result);
+
+ if (result)
+ {
+ axiom_xpath_free_result(env, result);
+ }
+
+ if (expr)
+ {
+ axiom_xpath_free_expression(env, expr);
+ }
+}
+
+int compare_result(axis2_char_t *rs)
+{
+ int i;
+ char c;
+
+ /*fprintf(ftemp, "%s#", rs);*/
+
+ if(!fcor)
+ {
+ return 0;
+ }
+
+ for(i = 0; 1; i++)
+ {
+ while(rs[i] == ' ' || rs[i] == '\n' || rs[i] == '\r' || rs[i] == '\t')
+ {
+ i++;
+ }
+
+ do
+ {
+ c = (char)getc(fcor);
+ }
+ while(c == ' ' || c == '\n' || c == '\r' || c == '\t');
+
+ if(c == '#' || c == EOF)
+ {
+ break;
+ }
+
+ if(c != rs[i])
+ {
+ while(c != '#' && c != EOF)
+ {
+ c = getc(fcor);
+ }
+
+ return 0;
+ }
+ }
+
+ return rs[i] == '\0';
+}
+
+void output_results(const axutil_env_t *env,
+ axiom_xpath_result_t *xpath_result)
+{
+ axiom_xpath_result_node_t *xpath_result_node;
+ axiom_node_t *result_node;
+ axis2_char_t *result_str;
+ axis2_char_t result_set[100000];
+ axis2_char_t temp_res[100000];
+
+ axiom_element_t *ele;
+ int i;
+
+ result_set[0] = '\n';
+ result_set[1] = '\0';
+
+ for (i = 0; i < axutil_array_list_size(xpath_result->nodes, env); i++)
+ {
+ xpath_result_node = axutil_array_list_get(xpath_result->nodes, env, i);
+
+ if (xpath_result_node->type == AXIOM_XPATH_TYPE_NODE)
+ {
+ result_node = xpath_result_node->value;
+ ele = (axiom_element_t *)axiom_node_get_data_element(
+ result_node, env);
+
+ if (ele)
+ {
+ /*result_str = axiom_element_get_text(ele, env, result_node);*/
+ result_str = axiom_node_to_string(result_node, env);
+
+ sprintf(temp_res, "\"%s\"\n", result_str);
+ strcat(result_set, temp_res);
+ }
+ }
+ else if (xpath_result_node->type == AXIOM_XPATH_TYPE_ATTRIBUTE)
+ {
+ result_str =
+ axiom_attribute_get_localname(xpath_result_node->value, env);
+ sprintf(temp_res, "%s = ", result_str);
+ strcat(result_set, temp_res);
+ result_str =
+ axiom_attribute_get_value(xpath_result_node->value, env);
+ sprintf(temp_res, "\"%s\"\n", result_str);
+ strcat(result_set, temp_res);
+ }
+ else if (xpath_result_node->type == AXIOM_XPATH_TYPE_NAMESPACE)
+ {
+ result_str =
+ axiom_namespace_get_prefix(xpath_result_node->value, env);
+ sprintf(temp_res, "%s = ", result_str);
+ strcat(result_set, temp_res);
+ result_str =
+ axiom_namespace_get_uri(xpath_result_node->value, env);
+ sprintf(temp_res, "\"%s\"\n", result_str);
+ strcat(result_set, temp_res);
+ }
+ else if (xpath_result_node->type == AXIOM_XPATH_TYPE_BOOLEAN)
+ {
+ sprintf(temp_res, "\"%s\"\n",
+ (*(axis2_bool_t *)xpath_result_node->value) ? "true" : "false");
+ strcat(result_set, temp_res);
+ }
+ else if (xpath_result_node->type == AXIOM_XPATH_TYPE_TEXT)
+ {
+ sprintf(temp_res, "\"%s\"\n",
+ (axis2_char_t *)xpath_result_node->value);
+ strcat(result_set, temp_res);
+ }
+ else if (xpath_result_node->type == AXIOM_XPATH_TYPE_NUMBER)
+ {
+ sprintf(temp_res, "\"%lf\"\n",
+ *(double *)xpath_result_node->value);
+ strcat(result_set, temp_res);
+ }
+ }
+
+ if(compare_result(result_set))
+ {
+ printf("Test case passed\n");
+ }
+ else
+ {
+ printf("Failed test case!\nOutput\n%s\n", result_set);
+ }
+}
+
+axiom_node_t *read_test_xml(const axutil_env_t *env, axis2_char_t *file_name)
+{
+ axiom_xml_reader_t *reader = NULL;
+ axiom_stax_builder_t *builder = NULL;
+ axiom_document_t *document = NULL;
+ axiom_node_t *root = NULL;
+
+ /* Create parser */
+ reader = axiom_xml_reader_create_for_file(env, file_name, NULL);
+
+ if (!reader)
+ {
+ printf("Error creating pullparser");
+ return NULL;
+ }
+
+ /* Create axiom_stax_builder */
+ builder = axiom_stax_builder_create(env, reader);
+
+ if (!builder)
+ {
+ printf("Error creating pull parser");
+ return NULL;
+ }
+
+ /* Create an om document */
+ document = axiom_stax_builder_get_document(builder, env);
+
+ if (!document)
+ {
+ printf("Error creating document");
+ return NULL;
+ }
+
+ /* Get root element */
+ root = axiom_document_get_root_element(document, env);
+ if (!root)
+ {
+ printf("Root element null ");
+ axiom_stax_builder_free(builder, env);
+ return NULL;
+ }
+
+ while (axiom_document_build_next(document, env));
+
+ return root;
+}