tests.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <?xml version="1.0"?>
  2. <tests>
  3. <test name="adopt_recon_default">
  4. <doc name="doc1"><![CDATA[<p1 xmlns="urn:test:AAA"><a/></p1>]]></doc>
  5. <doc name="doc2"><![CDATA[<p1 xmlns="urn:test:BBB"><b/></p1>]]></doc>
  6. <doc name="doc3"><![CDATA[<p2 xmlns="urn:test:ZZZ"/>]]></doc>
  7. <var name="a">
  8. <xpath doc="doc1" select-node="/a:p1/a:a">
  9. <reg-ns prefix="a" ns="urn:test:AAA"/>
  10. </xpath>
  11. </var>
  12. <var name="b" >
  13. <xpath doc="doc2" select-node="/b:p1/b:b">
  14. <reg-ns prefix="b" ns="urn:test:BBB"/>
  15. </xpath>
  16. </var>
  17. <var name="p2">
  18. <xpath doc="doc3" select-node="/z:p2">
  19. <reg-ns prefix="z" ns="urn:test:ZZZ"/>
  20. </xpath>
  21. </var>
  22. <remove node="a"/>
  23. <adopt dest-doc="doc3" node="a"/>
  24. <append-child parent="p2" child="a"/>
  25. <!-- This time without a previous removing. -->
  26. <adopt dest-doc="doc3" node="b"/>
  27. <append-child parent="p2" child="b"/>
  28. <reconcile-ns node="p2"/>
  29. <expected doc="doc3"><![CDATA[<p2 xmlns="urn:test:ZZZ"><a xmlns="urn:test:AAA"/><b xmlns="urn:test:BBB"/></p2>]]></expected>
  30. </test>
  31. <test name="adopt_recon">
  32. <doc name="doc1"><![CDATA[<a:p1 xmlns:a="urn:test:AAA"><a:a/></a:p1>]]></doc>
  33. <doc name="doc2"><![CDATA[<a:p2 xmlns:a="urn:test:AAA"/>]]></doc>
  34. <var name="a">
  35. <xpath doc="doc1" select-node="/a:p1/a:a">
  36. <reg-ns prefix="a" ns="urn:test:AAA"/>
  37. </xpath>
  38. </var>
  39. <var name="p2">
  40. <xpath doc="doc2" select-node="/a:p2">
  41. <reg-ns prefix="a" ns="urn:test:AAA"/>
  42. </xpath>
  43. </var>
  44. <adopt dest-doc="doc2" node="a"/>
  45. <append-child parent="p2" child="a"/>
  46. <reconcile-ns node="a"/>
  47. <expected doc="doc2"><![CDATA[<a:p2 xmlns:a="urn:test:AAA"><a:a/></a:p2>]]></expected>
  48. </test>
  49. <test name="adopt_recon_attr">
  50. <doc name="doc1"><![CDATA[<p1 xmlns:b="urn:test:BBB" b:attr="marvin"/>]]></doc>
  51. <doc name="doc2"><![CDATA[<a:p2 xmlns:a="urn:test:AAA"/>]]></doc>
  52. <var name="attr">
  53. <xpath doc="doc1" select-node="/p1/@b:attr">
  54. <reg-ns prefix="b" ns="urn:test:BBB"/>
  55. </xpath>
  56. </var>
  57. <var name="p2">
  58. <xpath doc="doc2" select-node="/a:p2">
  59. <reg-ns prefix="a" ns="urn:test:AAA"/>
  60. </xpath>
  61. </var>
  62. <adopt dest-doc="doc2" node="attr" />
  63. <append-child parent="p2" child="attr"/>
  64. <reconcile-ns node="p2"/>
  65. <expected doc="doc2"><![CDATA[<a:p2 xmlns:a="urn:test:AAA" xmlns:b="urn:test:BBB" b:attr="marvin"/>]]></expected>
  66. </test>
  67. <test name="adopt_recon_attr_2">
  68. <!-- Here we will specify a destination-parent for adoption. -->
  69. <doc name="doc1"><![CDATA[<p1 xmlns:b="urn:test:BBB" b:attr="marvin"/>]]></doc>
  70. <doc name="doc2"><![CDATA[<a:p2 xmlns:a="urn:test:AAA"/>]]></doc>
  71. <var name="attr">
  72. <xpath doc="doc1" select-node="/p1/@b:attr">
  73. <reg-ns prefix="b" ns="urn:test:BBB"/>
  74. </xpath>
  75. </var>
  76. <var name="p2">
  77. <xpath doc="doc2" select-node="/a:p2">
  78. <reg-ns prefix="a" ns="urn:test:AAA"/>
  79. </xpath>
  80. </var>
  81. <adopt dest-doc="doc2" dest-parent="p2" node="attr" />
  82. <append-child parent="p2" child="attr"/>
  83. <reconcile-ns node="p2"/>
  84. <expected doc="doc2"><![CDATA[<a:p2 xmlns:a="urn:test:AAA" xmlns:b="urn:test:BBB" b:attr="marvin"/>]]></expected>
  85. </test>
  86. <test name="adopt_recon_attr_3">
  87. <!-- Conflicting ns-prefixes for the added attribute. -->
  88. <doc name="doc1"><![CDATA[<p1 xmlns:a="urn:test:AAA" a:attr="marvin"/>]]></doc>
  89. <doc name="doc2"><![CDATA[<a:p2 xmlns:a="urn:test:aaa"/>]]></doc>
  90. <var name="attr">
  91. <xpath doc="doc1" select-node="/p1/@a:attr">
  92. <reg-ns prefix="a" ns="urn:test:AAA"/>
  93. </xpath>
  94. </var>
  95. <var name="p2">
  96. <xpath doc="doc2" select-node="/a:p2">
  97. <reg-ns prefix="a" ns="urn:test:aaa"/>
  98. </xpath>
  99. </var>
  100. <adopt dest-doc="doc2" node="attr" />
  101. <append-child parent="p2" child="attr"/>
  102. <reconcile-ns node="p2"/>
  103. <expected doc="doc2"><![CDATA[<a:p2 xmlns:a="urn:test:aaa" xmlns:a1="urn:test:AAA" a1:attr="marvin"/>]]></expected>
  104. </test>
  105. <test name="adopt_recon_attr_4">
  106. <!-- Qualified attribute added to default namespaced elem. -->
  107. <doc name="doc1"><![CDATA[<p1 xmlns:a="urn:test:AAA" a:attr="marvin"/>]]></doc>
  108. <doc name="doc2"><![CDATA[<p2 xmlns="urn:test:AAA"/>]]></doc>
  109. <var name="attr">
  110. <xpath doc="doc1" select-node="/p1/@a:attr">
  111. <reg-ns prefix="a" ns="urn:test:AAA"/>
  112. </xpath>
  113. </var>
  114. <var name="p2">
  115. <xpath doc="doc2" select-node="/a:p2">
  116. <reg-ns prefix="a" ns="urn:test:AAA"/>
  117. </xpath>
  118. </var>
  119. <adopt dest-doc="doc2" node="attr" />
  120. <append-child parent="p2" child="attr"/>
  121. <reconcile-ns node="p2"/>
  122. <expected doc="doc2"><![CDATA[<p2 xmlns="urn:test:AAA" xmlns:a="urn:test:AAA" a:attr="marvin"/>]]></expected>
  123. </test>
  124. <test name="adopt_recon_attr_5">
  125. <!-- Shadowed and conflicting prefix. dest-parent IS given. -->
  126. <doc name="doc1"><![CDATA[<p1 xmlns:a="urn:test:AAA" a:attr="marvin"/>]]></doc>
  127. <doc name="doc2"><![CDATA[<p2 xmlns:a="urn:test:AAA"><a:p3 xmlns:a="urn:test:ZZZ"/></p2>]]></doc>
  128. <var name="attr">
  129. <xpath doc="doc1" select-node="/p1/@a:attr">
  130. <reg-ns prefix="a" ns="urn:test:AAA"/>
  131. </xpath>
  132. </var>
  133. <var name="p3">
  134. <xpath doc="doc2" select-node="/p2/a:p3">
  135. <reg-ns prefix="a" ns="urn:test:ZZZ"/>
  136. </xpath>
  137. </var>
  138. <adopt dest-doc="doc2" node="attr" dest-parent="p3"/>
  139. <append-child parent="p3" child="attr"/>
  140. <!-- Note that we don't need to reconcile here, since done during
  141. adoption. -->
  142. <expected doc="doc2"><![CDATA[
  143. <p2 xmlns:a="urn:test:AAA">
  144. <a:p3 xmlns:a="urn:test:ZZZ" xmlns:a1="urn:test:AAA" a1:attr="marvin"/>
  145. </p2>]]></expected>
  146. </test>
  147. <test name="adopt_recon_attr_6">
  148. <!-- Shadowed and conflicting prefix. dest-parent NOT given. -->
  149. <doc name="doc1"><![CDATA[<p1 xmlns:a="urn:test:AAA" a:attr="marvin"/>]]></doc>
  150. <doc name="doc2"><![CDATA[<p2 xmlns:a="urn:test:AAA"><a:p3 xmlns:a="urn:test:ZZZ"/></p2>]]></doc>
  151. <var name="attr">
  152. <xpath doc="doc1" select-node="/p1/@a:attr">
  153. <reg-ns prefix="a" ns="urn:test:AAA"/>
  154. </xpath>
  155. </var>
  156. <var name="p3">
  157. <xpath doc="doc2" select-node="/p2/a:p3">
  158. <reg-ns prefix="a" ns="urn:test:ZZZ"/>
  159. </xpath>
  160. </var>
  161. <adopt dest-doc="doc2" node="attr"/>
  162. <append-child parent="p3" child="attr"/>
  163. <reconcile-ns node="p3"/>
  164. <expected doc="doc2"><![CDATA[
  165. <p2 xmlns:a="urn:test:AAA">
  166. <a:p3 xmlns:a="urn:test:ZZZ" xmlns:a1="urn:test:AAA" a1:attr="marvin"/>
  167. </p2>]]></expected>
  168. </test>
  169. <test name="shadow_1">
  170. <doc name="doc"><![CDATA[
  171. <foo xmlns:foo="urn:test:mine">
  172. <p xmlns:bar="urn:test:mine"/>
  173. <a1>
  174. <a2 xmlns:bar="urn:test:OTHER">
  175. <foo:a3/>
  176. </a2>
  177. </a1>
  178. </foo>
  179. ]]></doc>
  180. <var name="a1">
  181. <xpath doc="doc" select-node="/foo/a1"/>
  182. </var>
  183. <var name="p" >
  184. <xpath doc="doc" select-node="/foo/p"/>
  185. </var>
  186. <remove node="a1"/>
  187. <append-child parent="p" child="a1"/>
  188. <reconcile-ns node="a1"/>
  189. <expected doc="doc"><![CDATA[
  190. <foo xmlns:foo="urn:test:mine">
  191. <p xmlns:bar="urn:test:mine">
  192. <a1>
  193. <a2 xmlns:bar="urn:test:OTHER">
  194. <foo:a3/>
  195. </a2>
  196. </a1>
  197. </p>
  198. </foo>
  199. ]]></expected>
  200. </test>
  201. <test name="norm_1">
  202. <doc name="doc"><![CDATA[
  203. <foo>
  204. <p1 xmlns:a="urn:test:A" xmlns:b="urn:test:B" xmlns:c="urn:test:C">
  205. <a:a>
  206. <b:b a:attr="dont" c:attr="panic"/>
  207. </a:a>
  208. </p1>
  209. <p2/>
  210. </foo>
  211. ]]></doc>
  212. <var name="a">
  213. <xpath doc="doc" select-node="/foo/p1/a:a">
  214. <reg-ns prefix="a" ns="urn:test:A"/>
  215. </xpath>
  216. </var>
  217. <var name="p2" >
  218. <xpath doc="doc" select-node="/foo/p2"/>
  219. </var>
  220. <remove node="a"/>
  221. <append-child parent="p2" child="a"/>
  222. <reconcile-ns node="a"/>
  223. <expected doc="doc"><![CDATA[
  224. <foo>
  225. <p1 xmlns:a="urn:test:A" xmlns:b="urn:test:B" xmlns:c="urn:test:C"/>
  226. <p2>
  227. <a:a xmlns:a="urn:test:A">
  228. <b:b xmlns:b="urn:test:B" xmlns:c="urn:test:C" a:attr="dont" c:attr="panic"/>
  229. </a:a>
  230. </p2>
  231. </foo>
  232. ]]></expected>
  233. </test>
  234. </tests>