1<?xml version="1.0" encoding="UTF-8"?> 2<tests xmlns:var="http://jaxen.org/test-harness/var"> 3 <!-- test for jaxen-24 --> 4 <document url="xml/jaxen24.xml"> 5 <context select="/body/div"> 6 <test select="preceding::*[1]" count="1"/> 7 <valueOf select="local-name(preceding::*[1])">span</valueOf> 8 </context> 9 <!-- jaxen-58 --> 10 <context select="/"> 11 <test select="//preceding::x" count="0"/> 12 <test select="//following::x" count="0"/> 13 <test select="/descendant::*/preceding::x" count="0"/> 14 <test select="/descendant::node()/preceding::x" count="0"/> 15 </context> 16 </document> 17 18 <!-- test for jaxen-3 --> 19 <document url="xml/simple.xml"> 20 <context select="/"> 21 <valueOf select="string()">abd</valueOf> 22 </context> 23 <context select="/root"> 24 <valueOf select="string()">abd</valueOf> 25 </context> 26 <context select="/root/a"> 27 <valueOf select="string()">a</valueOf> 28 </context> 29 <context select="/root/c"> 30 <valueOf select="string()">d</valueOf> 31 </context> 32 </document> 33 34 35 <!-- test for jaxen-3 --> 36 <document url="xml/jaxen3.xml"> 37 <context select="/"> 38 <test select="/Configuration/hostname/attrlist/hostname[. = 'CE-A'] " count="1"/> 39 </context> 40 </document> 41 42 <!-- parser test cases all of which should fail--> 43 <document url="xml/numbers.xml"> 44 <context select="/"> 45 <!-- repeated xpaths, jaxen-35 --> 46 <test exception="true" select="/numbers numbers" count="0"/> 47 <!-- invalid xpath, jaxen-34 --> 48 <test exception="true" select="/a/b[c > d]efg" count="0"/> 49 <!-- invalid xpath, jaxen-27 --> 50 <test exception="true" select="/inv/child::" count="0"/> 51 <!-- invalid xpath, jaxen-26 --> 52 <!-- 53 54 <test exception="true" select="/invoice/@test[abcd" count="0"/> 55 <test exception="true" select="/invoice/@test[abcd > x" count="0"/> 56 57 <test exception="true" select="string-length('a" count="0"/> 58 <test exception="true" select="/descendant::()" count="0"/> 59 <test exception="true" select="(1 + 1" count="0"/> 60 61 --> 62 </context> 63 </document> 64 65 66 <!-- test cases for the use of underscores in names --> 67 <document url="xml/underscore.xml"> 68 <context select="/"> 69 <test select="/root/@a" count="1"/> 70 <test select="/root/@_a" count="1"/> 71 <test select="/root/b" count="1"/> 72 <test select="/root/_b" count="1"/> 73 <valueOf select="/root/@a">1</valueOf> 74 <valueOf select="/root/@_a">2</valueOf> 75 <valueOf select="/root/b">1</valueOf> 76 <valueOf select="/root/_b">2</valueOf> 77 </context> 78 </document> 79 80 <!-- test cases for the use of = with nodesets --> 81 <document url="xml/web.xml"> 82 <context select="/"> 83 <valueOf select="/web-app/servlet/servlet-name = 'file'">true</valueOf> 84 <valueOf select="/web-app/servlet/servlet-name = 'snoop'">true</valueOf> 85 </context> 86 </document> 87 88 <document url="xml/numbers.xml"> 89 <context select="/"> 90 <valueOf select="/numbers/set/nr = '-3'">true</valueOf> 91 <valueOf select="/numbers/set/nr = -3">true</valueOf> 92 <valueOf select="/numbers/set/nr = 24">true</valueOf> 93 <valueOf select="/numbers/set/nr/@value = '9999'">true</valueOf> 94 <valueOf select="/numbers/set/nr/@value = 9999.0">true</valueOf> 95 <valueOf select="/numbers/set/nr/@value = 66">true</valueOf> 96 </context> 97 </document> 98 99 <!-- test basic math... --> 100 <document url="xml/numbers.xml"> 101 <context select="/"> 102 <valueOf select="(8 * 2 + 1) = 17">true</valueOf> 103 <valueOf select="(1 + 8 * 2) = 17">true</valueOf> 104 <valueOf select="(7 - 3 + 1) = 5">true</valueOf> 105 <valueOf select="(8 - 4 + 5 - 6) = 3">true</valueOf> 106 <!-- left-assoc tests, comments show WRONG evaluation --> 107 <!-- 3 - 2 - 1 != 2 --> 108 <valueOf select="3 - 2 - 1">0</valueOf> 109 <!-- 8 div 4 div 2 != 4 --> 110 <valueOf select="8 div 4 div 2">1</valueOf> 111 <!-- 3 mod 5 mod 7 != 1 --> 112 <valueOf select="3 mod 7 mod 5">3</valueOf> 113 <!-- 1=(2=2) is true--> 114 <valueOf select="1 = 2 = 2">false</valueOf> 115 <!-- 2!=(3!=1) => 2!=1 => true, (2!=3)!=1 => 1!=1 => false --> 116 <valueOf select="2 != 3 != 1">false</valueOf> 117 <!-- 3 > (2 > 1) is true --> 118 <valueOf select="3 > 2 > 1">false</valueOf> 119 <!-- 3 >= (2 >= 2) is true --> 120 <valueOf select="3 >= 2 >= 2">false</valueOf> 121 <!-- 1 < (2 < 3) is false --> 122 <valueOf select="1 < 2 < 3">true</valueOf> 123 <!-- 0 <= (2 <= 3) is true --> 124 <valueOf select="2 <= 2 <= 3">true</valueOf> 125 </context> 126 </document> 127 128 <!-- test cases for preceding axis with different node types --> 129 <document url="xml/pi2.xml"> 130 <context select="/a/c"> 131 <test select="//processing-instruction()" count="1"/> 132 <test select="preceding-sibling::*" count="1"/> 133 <test select="preceding-sibling::node()" count="5"/> 134 <test select="preceding-sibling::*[1]" count="1"/> 135 <test select="preceding-sibling::processing-instruction()" count="1"/> 136 <valueOf select="preceding-sibling::processing-instruction()">order-by="x"</valueOf> 137 <valueOf select="preceding-sibling::*[1]">foo</valueOf> 138 <valueOf select="preceding-sibling::node()[2]">order-by="x"</valueOf> 139 </context> 140 </document> 141 142 <document url="xml/id.xml"> 143 <context select="/" 144 var:foobar="foobar" 145 var:foo="foo"> 146 <valueOf select="$foobar">foobar</valueOf> 147 <test select="/foo[@id=$foobar]" count="1"/> 148 <test select="/foo[@id='$foobar']" count="0"/> 149 <test select="/foo[concat($foo, 'bar')=@id]" count="1"/> 150 <test select="CD_Library/artist[@name=$artist]" count="0"/> 151 </context> 152 </document> 153 154 <document url="xml/id.xml"> 155 <context select="/"> 156 <!-- attributes have a parent: their element --> 157 <test select="/foo/@id/parent::foo" count="1"/> 158 </context> 159 <!-- attributes can also be used as context nodes --> 160 <context select="/foo/@id"> 161 <test select="parent::foo" count="1"/> 162 </context> 163 </document> 164 165 <document url="xml/pi.xml"> 166 <context select="/"> 167 <test select="//processing-instruction()" count="3"/> 168 <test select="//processing-instruction('cheese')" count="2"/> 169 <test select="//processing-instruction('toast')" count="1"> 170 <valueOf select="string()">is tasty</valueOf> 171 </test> 172 </context> 173 174 </document> 175 176 <!-- test evaluate() extension function --> 177 <document url="xml/evaluate.xml"> 178 <context select="/"> 179 <test select="evaluate('//jumps/*')" count="3"/> 180 <test select="evaluate('//jumps/object/dog')" count="1"/> 181 <test select="evaluate('//jumps/object')/evaluate" count="0"/> 182 <test select="evaluate('//jumps/object')/dog" count="1"/> 183 <test select="evaluate('//jumps/*')/dog" count="1"/> 184 <test select="//metatest[ evaluate(@select) = . ]" count="1"/> 185 </context> 186 </document> 187 188 <document url="xml/numbers.xml"> 189 <context select="/numbers/set[1]"> 190 <test select="*[-3 = .]" count="1"/> 191 <valueOf select="54 < *">true</valueOf> 192 <valueOf select="55 <= *">true</valueOf> 193 <valueOf select="69 < *">false</valueOf> 194 <valueOf select="-2 > *">true</valueOf> 195 <valueOf select="-3 >= *">true</valueOf> 196 <valueOf select="-4 >= *">false</valueOf> 197 </context> 198 <!-- TODO 199 This context should work, but needs a fixed version of saxpath to parse the right-hand side 200 of the greater-than expression. 201 <context select="/numbers/set[2]"> 202 <valueOf select="1 > nr/@value">false</valueOf> 203 <valueOf select="55 > nr/@value">false</valueOf> 204 <valueOf select="55 >= nr/@value">true</valueOf> 205 <valueOf select="1000000 > nr/@value">true</valueOf> 206 </context> 207 --> 208 </document> 209 210 211 <!-- test sibling axes --> 212 <document url="xml/axis.xml"> 213 214 <context select="/root"> 215 <test select="preceding-sibling::*" count="0"/> 216 </context> 217 218 <context select="/root/a/a.3"> 219 <test select="preceding::*" count="2"/> 220 </context> 221 222 <context select="/root/a/a.3"> 223 <test select="preceding-sibling::*" count="2"/> 224 </context> 225 226 <context select="/"> 227 <valueOf select="name(/root/a/a.3/preceding-sibling::*[1])">a.2</valueOf> 228 <valueOf select="name(/root/a/a.3/preceding-sibling::*[2])">a.1</valueOf> 229 </context> 230 231 <context select="/"> 232 <valueOf select="name(/root/a/a.3/following-sibling::*[1])">a.4</valueOf> 233 <valueOf select="name(/root/a/a.3/following-sibling::*[2])">a.5</valueOf> 234 </context> 235 236 </document> 237 238 239 <document url="xml/web.xml"> 240 241 <context select="/"> 242 <valueOf select="/web-app/servlet[1]/servlet-name">snoop</valueOf> 243 <valueOf select="/web-app/servlet[1]/servlet-name/text()">snoop</valueOf> 244 <valueOf select="/web-app/servlet[2]/servlet-name">file</valueOf> 245 <valueOf select="/web-app/servlet[2]/servlet-name/text()">file</valueOf> 246 </context> 247 248 <context select="/web-app/servlet[1]"> 249 <valueOf select="servlet-name">snoop</valueOf> 250 <valueOf select="servlet-name/text()">snoop</valueOf> 251 </context> 252 253 <context select="/web-app/servlet[2]/servlet-name"> 254 <test select="preceding::*" count="3"/> 255 </context> 256 257 <context select="/web-app/servlet[2]/servlet-name"> 258 <test select="following::*" count="13"/> 259 </context> 260 261 </document> 262 263 264 <!-- test name --> 265 266 <document url="xml/web.xml"> 267 <context select="/"> 268 269 <test select="*" count="1"> 270 <valueOf select="name()">web-app</valueOf> 271 </test> 272 273 <!-- NOTE that the child::node() tests only work if the 274 XML document does not comments or PIs 275 --> 276 277 <test select="./*" count="1"> 278 <valueOf select="name()">web-app</valueOf> 279 </test> 280 <test select="child::*" count="1"> 281 <valueOf select="name()">web-app</valueOf> 282 </test> 283 <test select="/*" count="1"> 284 <valueOf select="name()">web-app</valueOf> 285 </test> 286 <test select="/child::node()" count="1"> 287 <valueOf select="name(.)">web-app</valueOf> 288 </test> 289 <test select="child::node()" count="1"> 290 <valueOf select="name(.)">web-app</valueOf> 291 </test> 292 293 <!-- empty names --> 294 295 <valueOf select="name()"></valueOf> 296 <valueOf select="name(.)"></valueOf> 297 <valueOf select="name(parent::*)"></valueOf> 298 <valueOf select="name(/)"></valueOf> 299 <valueOf select="name(/.)"></valueOf> 300 <valueOf select="name(/self::node())"></valueOf> 301 302 <!-- name of root elemet --> 303 <valueOf select="name(node())">web-app</valueOf> 304 <valueOf select="name(/node())">web-app</valueOf> 305 <valueOf select="name(/*)">web-app</valueOf> 306 <valueOf select="name(/child::*)">web-app</valueOf> 307 <valueOf select="name(/child::node())">web-app</valueOf> 308 <valueOf select="name(/child::node())">web-app</valueOf> 309 <valueOf select="name(child::node())">web-app</valueOf> 310 <valueOf select="name(./*)">web-app</valueOf> 311 <valueOf select="name(*)">web-app</valueOf> 312 313 </context> 314 315 <context select="/*"> 316 <!-- empty names --> 317 <valueOf select="name(..)"></valueOf> 318 <valueOf select="name(parent::node())"></valueOf> 319 <valueOf select="name(parent::*)"></valueOf> 320 321 <!-- name of root elemet --> 322 <valueOf select="name()">web-app</valueOf> 323 <valueOf select="name(.)">web-app</valueOf> 324 <valueOf select="name(../*)">web-app</valueOf> 325 <valueOf select="name(/child::node())">web-app</valueOf> 326 </context> 327 </document> 328 329 330 331 <!-- test predicates --> 332 333 <document url="xml/nitf.xml"> 334 <context select="/nitf/head/docdata"> 335 <test select="doc-id[@regsrc='AP' and @id-string='D76UIMO80']" count="1"/> 336 </context> 337 <context select="/nitf/head"> 338 <test select="meta[@name='ap-cycle']" count="1"/> 339 <test select="meta[@content='AP']" count="1"/> 340 <test select="meta[@name and @content]" count="8"/> 341 <test select="meta[@name='ap-cycle' and @content='AP']" count="1"/> 342 <test select="meta[@name != 'ap-cycle']" count="7"/> 343 </context> 344 <context select="/"> 345 <test select="/nitf/head/meta[@name='ap-cycle']" count="1"/> 346 <test select="/nitf/head/meta[@content='AP']" count="1"/> 347 <test select="/nitf/head/meta[@name and @content]" count="8"/> 348 <test select="/nitf/head/meta[@name='ap-cycle' and @content='AP']" count="1"/> 349 <test select="/nitf/head/meta[@name != 'ap-cycle']" count="7"/> 350 </context> 351 </document> 352 353 354 <document url="xml/moreover.xml"> 355 <context select="/"> 356 <test select="/child::node()" count="1"/> 357 <test select="/*" count="1"/> 358 359 <test select="/*/article" count="20"/> 360 <test select="//*" count="221"/> 361 <test select="//*[local-name()='article']" count="20"/> 362 <test select="//article" count="20"/> 363 <test select="/*/*[@code]" count="20"/> 364 365 <test select="/moreovernews/article[@code='13563275']" count="1"/> 366 367 <test select="/moreovernews/article[@code='13563275']"> 368 <valueOf select="url">http://c.moreover.com/click/here.pl?x13563273</valueOf> 369 </test> 370 <test select="/*/article[@code='13563275']"> 371 <valueOf select="url">http://c.moreover.com/click/here.pl?x13563273</valueOf> 372 </test> 373 <test select="//article[@code='13563275']"> 374 <valueOf select="url">http://c.moreover.com/click/here.pl?x13563273</valueOf> 375 </test> 376 <test select="//*[@code='13563275']"> 377 <valueOf select="url">http://c.moreover.com/click/here.pl?x13563273</valueOf> 378 </test> 379 <test select="/child::node()/child::node()[@code='13563275']"> 380 <valueOf select="url">http://c.moreover.com/click/here.pl?x13563273</valueOf> 381 </test> 382 <test select="/*/*[@code='13563275']"> 383 <valueOf select="url">http://c.moreover.com/click/here.pl?x13563273</valueOf> 384 </test> 385 </context> 386 </document> 387 388 389 390 <!-- test other node types--> 391 392 <document url="xml/contents.xml"> 393 <context select="/"> 394 <test select="processing-instruction()" count="3"/> 395 <test select="/processing-instruction()" count="3"/> 396 <test select="/comment()" count="1"/> 397 <test select="comment()" count="1"/> 398 <test select="/child::node()/comment()" count="2"/> 399 <test select="/*/comment()" count="2"/> 400 <test select="//comment()" count="3"/> 401 </context> 402 </document> 403 404 405 406 <!-- test positioning --> 407 408 <document url="xml/fibo.xml"> 409 <context select="/"> 410 <test select="/*/fibonacci[position() < 10]" count="9"/> 411 <valueOf select="sum(//fibonacci)">196417</valueOf> 412 <valueOf select="sum(//fibonacci/@index)">325</valueOf> 413 <valueOf select="/*/fibonacci[2]">1</valueOf> 414 <valueOf select="/*/fibonacci[ count(/*/fibonacci) ]">75025</valueOf> 415 <valueOf select="/*/fibonacci[ count(/*/fibonacci) - 1 ]">46368</valueOf> 416 </context> 417 </document> 418 419 420 <!-- test number functions --> 421 422 <!-- test Axes --> 423 424 <document url="xml/web.xml"> 425 <context select="/"> 426 <test select="descendant-or-self::*" count="19"/> 427 <test select="descendant::*" count="19"/> 428 <test select="/descendant::*" count="19"/> 429 <test select="/descendant-or-self::*" count="19"/> 430 <test select="/descendant::servlet" count="2"/> 431 <test select="/descendant-or-self::servlet" count="2"/> 432 <test select="descendant-or-self::servlet" count="2"/> 433 <test select="descendant::servlet" count="2"/> 434 <test select="/*/servlet" count="2"/> 435 <valueOf select="count(/*/servlet)">2</valueOf> 436 <test select="//servlet" count="2"/> 437 <valueOf select="count(//servlet)">2</valueOf> 438 </context> 439 <context select="/web-app"> 440 <test select="/descendant::servlet" count="2"/> 441 <test select="/descendant-or-self::servlet" count="2"/> 442 <test select="descendant-or-self::servlet" count="2"/> 443 <test select="descendant::servlet" count="2"/> 444 </context> 445 </document> 446 447 <document url="xml/much_ado.xml"> 448 <context select="/"> 449 <test select="/descendant::ACT" count="5"/> 450 <test select="descendant::ACT" count="5"/> 451 <valueOf select="/PLAY/TITLE">Much Ado about Nothing</valueOf> 452 <valueOf select="2+2">4</valueOf> 453 <valueOf select="5 * 4 + 1">21</valueOf> 454 <valueOf select="count(descendant::ACT)">5</valueOf> 455 <valueOf select="10 + count(descendant::ACT) * 5">35</valueOf> 456 <valueOf select="(10 + count(descendant::ACT)) * 5">75</valueOf> 457 </context> 458 <context select="/PLAY/ACT[2]/SCENE[1]"> 459 <test select="/descendant::ACT" count="5"/> 460 <test select="/descendant::ACT" count="5"/> 461 <test select="/PLAY/ACT[2]/SCENE[1]/descendant::SPEAKER" count="141"/> 462 <test select="descendant::SPEAKER" count="141"/> 463 <valueOf select="count(descendant::*)+1">646</valueOf> 464 <valueOf select="count(descendant::SPEAKER)+1">142</valueOf> 465 <valueOf select="count(ancestor::*)">2</valueOf> 466 <valueOf select="count(ancestor::PLAY)">1</valueOf> 467 <valueOf select="count(ancestor-or-self::*)">3</valueOf> 468 <valueOf select="count(ancestor-or-self::PLAY)">1</valueOf> 469 <valueOf select="5+count(ancestor::*)-1">6</valueOf> 470 </context> 471 <context select="/"> 472 <!-- Test correct predicate application --> 473 <valueOf select="count(/PLAY/ACT/SCENE[1])">5</valueOf> 474 </context> 475 </document> 476 477 <!-- test axis node ordering --> 478 <document url="xml/web.xml"> 479 <context select="/"> 480 <!-- Reported as Jira issue JAXEN-24 --> 481 <test select="//servlet-mapping/preceding::*[1][name()='description']" count="1"/> 482 <test select="/web-app/servlet//description/following::*[1][name()='servlet-mapping']" count="1"/> 483 <test select="/web-app/servlet//description/following::*[2][name()='servlet-name']" count="1"/> 484 </context> 485 </document> 486 487 <!-- test document function --> 488 <document url="xml/text.xml"> 489 <context select="/"> 490 <test select="document('xml/web.xml')" count="1"> 491 <valueOf select="/web-app/servlet[1]/servlet-name">snoop</valueOf> 492 <valueOf select="/web-app/servlet[1]/servlet-name/text()">snoop</valueOf> 493 </test> 494 <valueOf select="document('xml/web.xml')/web-app/servlet[1]/servlet-name">snoop</valueOf> 495 </context> 496 <!-- Test to check if the context changes when an extension function is used. 497 First test is an example, second is the actual test. 498 --> 499 <context select="/foo/bar/cheese[1]"> 500 <valueOf select="concat(./@id,'foo',@id)">3foo3</valueOf> 501 <valueOf select="concat(./@id,document('xml/web.xml')/web-app/servlet[1]/servlet-name,./@id)">3snoop3</valueOf> 502 </context> 503 </document> 504 505 <document url="xml/message.xml"> 506 <context select="/"> 507 <valueOf select="/message/body/data/items/item[name/text()='parentinfo']/value">Pruefgebiete</valueOf> 508 <valueOf select="document('xml/message.xml')/message/body/data/items/item[name/text()='parentinfo']/value">Pruefgebiete</valueOf> 509 </context> 510 </document> 511 512 <document url="xml/simple.xml"> 513 514 <!-- test behaviour of AbsoluteLocationPath --> 515 <context select="/root/a"> 516 <valueOf select="concat( ., /root/b )">ab</valueOf> 517 <valueOf select="concat( ../b, . )">ba</valueOf> 518 <valueOf select="concat( /root/b, . )">ba</valueOf> 519 <valueOf select="concat( /root/c/d, ../b )">db</valueOf> 520 </context> 521 522 <!-- test the translate() function --> 523 <context select="/"> 524 <valueOf select="translate( '', '', '' )"></valueOf> 525 <valueOf select="translate( 'abcd', '', '' )">abcd</valueOf> 526 <valueOf select="translate( 'abcd', 'abcd', 'abcd' )">abcd</valueOf> 527 <valueOf select="translate( 'abcd', 'dcba', 'dcba' )">abcd</valueOf> 528 <valueOf select="translate( 'abcd', 'abcd', 'dcba' )">dcba</valueOf> 529 <valueOf select="translate( 'abcd', 'abcd', 'ab' )">ab</valueOf> 530 <valueOf select="translate( 'abcd', 'cdab', 'cd' )">cd</valueOf> 531 <valueOf select="translate( 'abcd', 'acbd', 'xy' )">xy</valueOf> 532 <valueOf select="translate( 'abcd', 'abcdb', 'abcdb' )">abcd</valueOf> 533 <valueOf select="translate( 'abcd', 'abcd', 'abcdb' )">abcd</valueOf> 534 </context> 535 536 <context select="/"> 537 <valueOf select="substring('12345', 1.5, 2.6)">234</valueOf> 538 <valueOf select="substring('12345', 0, 3)">12</valueOf> 539 <valueOf select="substring('12345', 0 div 0, 3)"></valueOf> 540 <valueOf select="substring('12345', 1, 0 div 0)"></valueOf> 541 <valueOf select="substring('12345', -42, 1 div 0)">12345</valueOf> 542 <valueOf select="substring('12345', -1 div 0, 1 div 0)"></valueOf> 543 <valueOf select="substring('12345', 3)">345</valueOf> 544 <valueOf select="substring('12345',1,15)">12345</valueOf> 545 </context> 546 547 <!-- Some tests for the normalize-space() function --> 548 549 <context select="/"> 550 <valueOf select="normalize-space(' abc ')">abc</valueOf> 551 <valueOf select="normalize-space(' a b c ')">a b c</valueOf> 552 <valueOf select="normalize-space(' a 
 b 
 c ')">a b c</valueOf> 553 <!-- Next test case addresses issue JAXEN-22 --> 554 <valueOf select="normalize-space(' ')"></valueOf> 555 <!-- Next test case addresses issue JAXEN-29 --> 556 <valueOf select="normalize-space('')"></valueOf> 557 </context> 558 </document> 559 560 561 562 <!-- test cases for String extension functions --> 563 <document url="xml/web.xml"> 564 <context select="/web-app/servlet[1]"> 565 <valueOf select="upper-case( servlet-class )">SNOOPSERVLET</valueOf> 566 <valueOf select="lower-case( servlet-class )">snoopservlet</valueOf> 567 <valueOf select="upper-case( servlet-class, 'fr' )">SNOOPSERVLET</valueOf> 568 <valueOf select="upper-case( servlet-class, 'fr-CA' )">SNOOPSERVLET</valueOf> 569 <valueOf select="upper-case( servlet-class, 'es-ES-Traditional_WIN' )">SNOOPSERVLET</valueOf> 570 <valueOf select="ends-with( servlet-class, 'Servlet' )">true</valueOf> 571 <valueOf select="ends-with( servlet-class, 'S' )">false</valueOf> 572 </context> 573 </document> 574 575 <!-- test cases for the lang() function --> 576 <document url="xml/lang.xml"> 577 <context select="/"> 578 <test select="/e1/e2[lang('hr')]" count="0"/> 579 <test select="/e1/e2/e3[lang('en')]" count="1"/> 580 <test select="/e1/e2/e3[lang('en-US')]" count="1"/> 581 <test select="/e1/e2/e3[lang('en-GB')]" count="0"/> 582 <test select="/e1/e2/e3[lang('hu')]" count="2"/> 583 <test select="/e1/e2/e3[lang('hu-HU')]" count="0"/> 584 <test select="/e1/e2/e3[lang('es')]" count="1"/> 585 <test select="/e1/e2/e3[lang('es-BR')]" count="0"/> 586 </context> 587 </document> 588 589 <!-- test namespace --> 590 <document url="xml/namespaces.xml"> 591 <context select="/" 592 xmlns:foo="http://fooNamespace/" 593 xmlns:voo="http://fooNamespace/" 594 xmlns:bar="http://barNamespace/" 595 xmlns:alias="http://fooNamespace/"> 596 <test select="/*" count="1"/> 597 <test select="/foo:a" count="1"/> 598 <test select="/foo:a/b" count="1"/> 599 <test select="/voo:a/b/c" count="1"/> 600 <test select="/voo:a/bar:f" count="1"/> 601 <test select="/*[namespace-uri()='http://fooNamespace/' and local-name()='a']" count="1"/> 602 <test select="/*[local-name()='a' and namespace-uri()='http://fooNamespace/']/*[local-name()='x' and namespace-uri()='http://fooNamespace/']" count="1"/> 603 <test select="/*[local-name()='a' and namespace-uri()='http://fooNamespace/']/*[local-name()='x' and namespace-uri()='http://fooNamespace/']/*[local-name()='y' and namespace-uri()='http://fooNamespace/']" count="1"/> 604 </context> 605 <!-- the prefix here and in the document have no relation; it's their 606 namespace-uri binding that counts --> 607 <context select="/" xmlns:foo="http://somethingElse/"> 608 <test select="/foo:a/b/c" count="0"/> 609 </context> 610 611 <context select="/" 612 xmlns:foo="http://fooNamespace/" 613 xmlns:bar="http://barNamespace/" 614 xmlns:alias="http://fooNamespace/"> 615 <valueOf select="/foo:a/b/c">Hello</valueOf> 616 <valueOf select="/foo:a/foo:d/foo:e">Hey</valueOf> 617 <valueOf select="/foo:a/alias:x/alias:y">Hey3</valueOf> 618 <valueOf select="/foo:a/foo:x/foo:y">Hey3</valueOf> 619 <valueOf select="/*[local-name()='a' and namespace-uri()='http://fooNamespace/']/*[local-name()='x' and namespace-uri()='http://fooNamespace/']/*[local-name()='y' and namespace-uri()='http://fooNamespace/']">Hey3</valueOf> 620 </context> 621 622 </document> 623 624 <document url="xml/defaultNamespace.xml"> 625 <context select="/"> 626 <!-- NOTE: /a/b/c selects elements in no namespace only! --> 627 <test select="/a/b/c" count="0"/> 628 <!-- 629 The following test uses an unbound prefix 'x' and should throw an exception. 630 Addresses issue JAXEN-18. 631 Turns out this isn't really tested as the test didn't fail when the exception wasn't thrown. 632 <test select="/x:a/x:b/x:c" count="0" exception="true"/> 633 --> 634 </context> 635 <context select="/" 636 xmlns:dummy="http://dummyNamespace/"> 637 <test select="/dummy:a/dummy:b/dummy:c" count="1"/> 638 </context> 639 </document> 640 <document url="xml/text.xml"> 641 <context select="/"> 642 <test select="/foo/bar/text()" count="3"/> 643 <valueOf select="normalize-space(/foo/bar/text())">baz</valueOf> 644 </context> 645 </document> 646 647 <document url="xml/testNamespaces.xml"> 648 <context select="/"> 649 <!-- the root is not an element, so no namespaces --> 650 <test select="namespace::*" count="0" debug="off"/> 651 <test select="/namespace::*" count="0" debug="off"/> 652 <test select="/Template/Application1/namespace::*" count="3" debug="off"/> 653 <test select="/Template/Application2/namespace::*" count="3" debug="off"/> 654 655 <test select="//namespace::*" count="25" debug="off"/> 656 </context> 657 658 <!-- 659 <context select="/Template/Application1"> 660 <test select="namespace::*" count="3" debug="off"/> 661 <test select="/namespace::*" count="0" debug="off"/> 662 <test select="/Template/Application1/namespace::*" count="3" debug="off"/> 663 <test select="/Template/Application2/namespace::*" count="3" debug="off"/> 664 <test select="//namespace::*" count="25" debug="off"/> 665 <test select="//namespace::xplt" count="8" debug="off"/> 666 <test xmlns:somethingelse="http://www.xxxx.com/" 667 select="//namespace::somethingelse" count="0" debug="off"/> 668 </context> 669 --> 670 </document> 671 672 <document url="xml/testNamespaces.xml"> 673 <context select="/"> 674 <!-- namespace nodes have their element as their parent --> 675 <test select="/Template/namespace::xml/parent::Template" count="1"/> 676 </context> 677 <!-- namespace nodes can also be used as context nodes --> 678 <context select="/Template/namespace::xml"> 679 <test select="parent::Template" count="1"/> 680 </context> 681 </document> 682 683</tests> 684