|
138 | 138 | """) |
139 | 139 | @test isa(doc, Document) |
140 | 140 | @test nodetype(doc.node) === EzXML.HTML_DOCUMENT_NODE |
| 141 | + @test hasdtd(doc) |
| 142 | + @test name(dtd(doc)) == "html" |
141 | 143 |
|
142 | 144 | doc = parse(Document, """ |
143 | 145 | <html> |
|
151 | 153 | """) |
152 | 154 | @test isa(doc, Document) |
153 | 155 | @test nodetype(doc.node) === EzXML.HTML_DOCUMENT_NODE |
| 156 | + @test hasdtd(doc) |
154 | 157 |
|
155 | 158 | doc = parse(Document, """ |
156 | 159 | <!DOCTYPE html> |
|
319 | 322 | @test isattribute(n) |
320 | 323 | @test_throws ArgumentError document(n) |
321 | 324 |
|
| 325 | + n = DTDNode("open-hatch") |
| 326 | + @test isa(n, Node) |
| 327 | + @test isdtd(n) |
| 328 | + @test n.owner === n |
| 329 | + @test nodetype(n) === EzXML.DTD_NODE |
| 330 | + @test name(n) == "open-hatch" |
| 331 | + @test_throws ArgumentError systemID(n) |
| 332 | + @test_throws ArgumentError externalID(n) |
| 333 | + |
| 334 | + n = DTDNode("open-hatch", |
| 335 | + "http://www.textuality.com/boilerplate/OpenHatch.xml") |
| 336 | + @test isa(n, Node) |
| 337 | + @test isdtd(n) |
| 338 | + @test n.owner === n |
| 339 | + @test nodetype(n) === EzXML.DTD_NODE |
| 340 | + @test systemID(n) == "http://www.textuality.com/boilerplate/OpenHatch.xml" |
| 341 | + @test_throws ArgumentError externalID(n) |
| 342 | + |
| 343 | + n = DTDNode("open-hatch", |
| 344 | + "http://www.textuality.com/boilerplate/OpenHatch.xml", |
| 345 | + "-//Textuality//TEXT Standard open-hatch boilerplate//EN") |
| 346 | + @test isa(n, Node) |
| 347 | + @test isdtd(n) |
| 348 | + @test n.owner === n |
| 349 | + @test nodetype(n) === EzXML.DTD_NODE |
| 350 | + @test systemID(n) == "http://www.textuality.com/boilerplate/OpenHatch.xml" |
| 351 | + @test externalID(n) == "-//Textuality//TEXT Standard open-hatch boilerplate//EN" |
| 352 | + |
322 | 353 | doc = XMLDocument() |
323 | 354 | @test isa(doc, Document) |
324 | 355 | @test doc.node.owner === doc.node |
|
345 | 376 | @testset "Traversal" begin |
346 | 377 | doc = parsexml("<root/>") |
347 | 378 | @test hasroot(doc) |
| 379 | + @test !hasdtd(doc) |
348 | 380 | @test isa(root(doc), Node) |
349 | 381 | @test root(doc) == root(doc) |
350 | 382 | @test root(doc) === root(doc) |
|
358 | 390 | @test_throws ArgumentError parentnode(doc.node) |
359 | 391 | @test hasparentnode(root(doc)) |
360 | 392 | @test parentnode(root(doc)) === doc.node |
| 393 | + @test_throws ArgumentError dtd(doc) |
| 394 | + |
| 395 | + doc = parsexml(""" |
| 396 | + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| 397 | + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 398 | +
|
| 399 | + <html xmlns="http://www.w3.org/1999/xhtml"> |
| 400 | + <head><title>hello</title></head> |
| 401 | + <body>Content</body> |
| 402 | + </html> |
| 403 | + """) |
| 404 | + @test hasroot(doc) |
| 405 | + @test hasdtd(doc) |
| 406 | + @test isa(dtd(doc), Node) |
| 407 | + @test isdtd(dtd(doc)) |
| 408 | + @test dtd(doc) === dtd(doc) |
| 409 | + @test name(dtd(doc)) == "html" |
| 410 | + @test systemID(dtd(doc)) == "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" |
| 411 | + @test externalID(dtd(doc)) == "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| 412 | + @test parentnode(dtd(doc)) === doc.node |
361 | 413 |
|
362 | 414 | doc = parse(Document, """ |
363 | 415 | <?xml version="1.0"?> |
|
602 | 654 | setcontent!(el, "some content") |
603 | 655 | @test content(el) == "some content" |
604 | 656 |
|
| 657 | + doc = XMLDocument() |
| 658 | + @test countnodes(doc.node) === 0 |
| 659 | + d1 = DTDNode("hello", "hello.dtd") |
| 660 | + @test setdtd!(doc, d1) === d1 |
| 661 | + @test countnodes(doc.node) === 1 |
| 662 | + @test dtd(doc) === d1 |
| 663 | + setroot!(doc, ElementNode("root")) |
| 664 | + @test countnodes(doc.node) === 2 |
| 665 | + @test nextnode(d1) === root(doc) |
| 666 | + d2 = DTDNode("hello", "hello2.dtd") |
| 667 | + @test setdtd!(doc, d2) === d2 |
| 668 | + @test countnodes(doc.node) === 2 |
| 669 | + @test dtd(doc) === d2 |
| 670 | + @test_throws ArgumentError setdtd!(doc, ElementNode("foo")) |
| 671 | + |
605 | 672 | # <e1>t1<e2>t2<e3 a1="val"/></e2></e1> |
606 | 673 | doc = XMLDocument() |
607 | 674 | e1 = ElementNode("e1") |
|
0 commit comments