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