/usr/share/doc/libghc-hxt-doc/html/src/Text-XML-HXT-DTDValidation-DTDValidation.html is in libghc-hxt-doc 9.3.1.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
<title>src/Text/XML/HXT/DTDValidation/DTDValidation.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>-- ------------------------------------------------------------</span>
<a name="line-2"></a>
<a name="line-3"></a><span class='hs-comment'>{- |
<a name="line-4"></a> Module : Text.XML.HXT.DTDValidation.TypeDefs
<a name="line-5"></a> Copyright : Copyright (C) 2008 Uwe Schmidt
<a name="line-6"></a> License : MIT
<a name="line-7"></a>
<a name="line-8"></a> Maintainer : Uwe Schmidt (uwe@fh-wedel.de)
<a name="line-9"></a> Stability : experimental
<a name="line-10"></a> Portability: portable
<a name="line-11"></a>
<a name="line-12"></a> This module provides functions for validating the DTD of XML documents
<a name="line-13"></a> represented as XmlTree.
<a name="line-14"></a>
<a name="line-15"></a> Unlike other popular XML validation tools the validation process returns
<a name="line-16"></a> a list of errors instead of aborting after the first error was found.
<a name="line-17"></a>
<a name="line-18"></a>
<a name="line-19"></a> Unlike validation of the document, the DTD branch is traversed four times:
<a name="line-20"></a>
<a name="line-21"></a> - Validation of Notations
<a name="line-22"></a>
<a name="line-23"></a> - Validation of Unparsed Entities
<a name="line-24"></a>
<a name="line-25"></a> - Validation of Element declarations
<a name="line-26"></a>
<a name="line-27"></a> - Validation of Attribute declarations
<a name="line-28"></a>
<a name="line-29"></a>-}</span>
<a name="line-30"></a>
<a name="line-31"></a><span class='hs-comment'>-- ------------------------------------------------------------</span>
<a name="line-32"></a>
<a name="line-33"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Text</span><span class='hs-varop'>.</span><span class='hs-conid'>XML</span><span class='hs-varop'>.</span><span class='hs-conid'>HXT</span><span class='hs-varop'>.</span><span class='hs-conid'>DTDValidation</span><span class='hs-varop'>.</span><span class='hs-conid'>DTDValidation</span>
<a name="line-34"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>removeDoublicateDefs</span>
<a name="line-35"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>validateDTD</span>
<a name="line-36"></a> <span class='hs-layout'>)</span>
<a name="line-37"></a><span class='hs-keyword'>where</span>
<a name="line-38"></a>
<a name="line-39"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Text</span><span class='hs-varop'>.</span><span class='hs-conid'>XML</span><span class='hs-varop'>.</span><span class='hs-conid'>HXT</span><span class='hs-varop'>.</span><span class='hs-conid'>DTDValidation</span><span class='hs-varop'>.</span><span class='hs-conid'>TypeDefs</span>
<a name="line-40"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Text</span><span class='hs-varop'>.</span><span class='hs-conid'>XML</span><span class='hs-varop'>.</span><span class='hs-conid'>HXT</span><span class='hs-varop'>.</span><span class='hs-conid'>DTDValidation</span><span class='hs-varop'>.</span><span class='hs-conid'>AttributeValueValidation</span>
<a name="line-41"></a>
<a name="line-42"></a><span class='hs-comment'>-- |</span>
<a name="line-43"></a><span class='hs-comment'>-- Validate a DTD.</span>
<a name="line-44"></a><span class='hs-comment'>--</span>
<a name="line-45"></a><span class='hs-comment'>-- - returns : a functions which takes the DTD subset of the XmlTree, checks</span>
<a name="line-46"></a><span class='hs-comment'>-- if the DTD is valid and returns a list of errors</span>
<a name="line-47"></a>
<a name="line-48"></a><a name="validateDTD"></a><span class='hs-definition'>validateDTD</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>XmlArrow</span>
<a name="line-49"></a><span class='hs-definition'>validateDTD</span> <span class='hs-comment'>-- dtdPart</span>
<a name="line-50"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>isDTDDoctype</span>
<a name="line-51"></a> <span class='hs-varop'>`guards`</span>
<a name="line-52"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>listA</span> <span class='hs-varid'>getChildren</span>
<a name="line-53"></a> <span class='hs-varop'>>>></span>
<a name="line-54"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>validateParts</span> <span class='hs-varop'>$<<</span> <span class='hs-layout'>(</span><span class='hs-varid'>getNotationNames</span> <span class='hs-varop'>&&&</span> <span class='hs-varid'>getElemNames</span><span class='hs-layout'>)</span> <span class='hs-layout'>)</span>
<a name="line-55"></a> <span class='hs-layout'>)</span>
<a name="line-56"></a> <span class='hs-keyword'>where</span>
<a name="line-57"></a> <span class='hs-varid'>validateParts</span> <span class='hs-varid'>notationNames</span> <span class='hs-varid'>elemNames</span>
<a name="line-58"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>validateNotations</span>
<a name="line-59"></a> <span class='hs-varop'><+></span>
<a name="line-60"></a> <span class='hs-varid'>validateEntities</span> <span class='hs-varid'>notationNames</span>
<a name="line-61"></a> <span class='hs-varop'><+></span>
<a name="line-62"></a> <span class='hs-varid'>validateElements</span> <span class='hs-varid'>elemNames</span>
<a name="line-63"></a> <span class='hs-varop'><+></span>
<a name="line-64"></a> <span class='hs-varid'>validateAttributes</span> <span class='hs-varid'>elemNames</span> <span class='hs-varid'>notationNames</span>
<a name="line-65"></a>
<a name="line-66"></a> <span class='hs-varid'>getNotationNames</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>LA</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>XmlTree</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span>
<a name="line-67"></a> <span class='hs-varid'>getNotationNames</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>listA</span> <span class='hs-varop'>$</span> <span class='hs-varid'>unlistA</span> <span class='hs-varop'>>>></span> <span class='hs-varid'>isDTDNotation</span> <span class='hs-varop'>>>></span> <span class='hs-varid'>getDTDAttrValue</span> <span class='hs-varid'>a_name</span>
<a name="line-68"></a>
<a name="line-69"></a> <span class='hs-varid'>getElemNames</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>LA</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>XmlTree</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span>
<a name="line-70"></a> <span class='hs-varid'>getElemNames</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>listA</span> <span class='hs-varop'>$</span> <span class='hs-varid'>unlistA</span> <span class='hs-varop'>>>></span> <span class='hs-varid'>isDTDElement</span> <span class='hs-varop'>>>></span> <span class='hs-varid'>getDTDAttrValue</span> <span class='hs-varid'>a_name</span>
<a name="line-71"></a>
<a name="line-72"></a><span class='hs-comment'>-- ------------------------------------------------------------</span>
<a name="line-73"></a>
<a name="line-74"></a><a name="checkName"></a><span class='hs-definition'>checkName</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>String</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SLA</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-conid'>XmlTree</span> <span class='hs-conid'>XmlTree</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SLA</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-conid'>XmlTree</span> <span class='hs-conid'>XmlTree</span>
<a name="line-75"></a><span class='hs-definition'>checkName</span> <span class='hs-varid'>name</span> <span class='hs-varid'>msg</span>
<a name="line-76"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>ifA</span> <span class='hs-layout'>(</span> <span class='hs-varid'>getState</span>
<a name="line-77"></a> <span class='hs-varop'>>>></span>
<a name="line-78"></a> <span class='hs-varid'>isA</span> <span class='hs-layout'>(</span><span class='hs-varid'>name</span> <span class='hs-varop'>`elem`</span><span class='hs-layout'>)</span>
<a name="line-79"></a> <span class='hs-layout'>)</span>
<a name="line-80"></a> <span class='hs-varid'>msg</span>
<a name="line-81"></a> <span class='hs-layout'>(</span><span class='hs-varid'>nextState</span> <span class='hs-layout'>(</span><span class='hs-varid'>name</span><span class='hs-conop'>:</span><span class='hs-layout'>)</span> <span class='hs-varop'>>>></span> <span class='hs-varid'>none</span><span class='hs-layout'>)</span>
<a name="line-82"></a>
<a name="line-83"></a><span class='hs-comment'>-- ------------------------------------------------------------</span>
<a name="line-84"></a>
<a name="line-85"></a><span class='hs-comment'>-- |</span>
<a name="line-86"></a><span class='hs-comment'>-- Validation of Notations, checks if all notation names are unique.</span>
<a name="line-87"></a><span class='hs-comment'>-- Validity constraint: Unique Notation Name (4.7 \/ p.44 in Spec)</span>
<a name="line-88"></a><span class='hs-comment'>--</span>
<a name="line-89"></a><span class='hs-comment'>-- * 1.parameter dtdPart : the children of the @DOCTYPE@ node</span>
<a name="line-90"></a><span class='hs-comment'>--</span>
<a name="line-91"></a><span class='hs-comment'>-- - returns : a list of errors</span>
<a name="line-92"></a>
<a name="line-93"></a><a name="validateNotations"></a><span class='hs-definition'>validateNotations</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>LA</span> <span class='hs-conid'>XmlTrees</span> <span class='hs-conid'>XmlTree</span>
<a name="line-94"></a><span class='hs-definition'>validateNotations</span>
<a name="line-95"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fromSLA</span> <span class='hs-conid'>[]</span> <span class='hs-layout'>(</span> <span class='hs-varid'>unlistA</span>
<a name="line-96"></a> <span class='hs-varop'>>>></span>
<a name="line-97"></a> <span class='hs-varid'>isDTDNotation</span>
<a name="line-98"></a> <span class='hs-varop'>>>></span>
<a name="line-99"></a> <span class='hs-layout'>(</span><span class='hs-varid'>checkForUniqueNotation</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>getDTDAttrl</span><span class='hs-layout'>)</span>
<a name="line-100"></a> <span class='hs-layout'>)</span>
<a name="line-101"></a> <span class='hs-keyword'>where</span>
<a name="line-102"></a> <span class='hs-varid'>checkForUniqueNotation</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SLA</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-conid'>XmlTree</span> <span class='hs-conid'>XmlTree</span>
<a name="line-103"></a> <span class='hs-varid'>checkForUniqueNotation</span> <span class='hs-varid'>al</span>
<a name="line-104"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>checkName</span> <span class='hs-varid'>name</span> <span class='hs-varop'>$</span>
<a name="line-105"></a> <span class='hs-varid'>err</span> <span class='hs-layout'>(</span> <span class='hs-str'>"Notation "</span><span class='hs-varop'>++</span> <span class='hs-varid'>show</span> <span class='hs-varid'>name</span> <span class='hs-varop'>++</span> <span class='hs-str'>" was already specified."</span> <span class='hs-layout'>)</span>
<a name="line-106"></a> <span class='hs-keyword'>where</span>
<a name="line-107"></a> <span class='hs-varid'>name</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al</span>
<a name="line-108"></a>
<a name="line-109"></a><span class='hs-comment'>-- |</span>
<a name="line-110"></a><span class='hs-comment'>-- Validation of Entities.</span>
<a name="line-111"></a><span class='hs-comment'>--</span>
<a name="line-112"></a><span class='hs-comment'>-- 1. Issues a warning if entities are declared multiple times.</span>
<a name="line-113"></a><span class='hs-comment'>--</span>
<a name="line-114"></a><span class='hs-comment'>-- Optional warning: (4.2 \/ p.35 in Spec)</span>
<a name="line-115"></a><span class='hs-comment'>--</span>
<a name="line-116"></a><span class='hs-comment'>--</span>
<a name="line-117"></a><span class='hs-comment'>-- 2. Validates that a notation is declared for an unparsed entity.</span>
<a name="line-118"></a><span class='hs-comment'>--</span>
<a name="line-119"></a><span class='hs-comment'>-- Validity constraint: Notation Declared (4.2.2 \/ p.36 in Spec)</span>
<a name="line-120"></a><span class='hs-comment'>--</span>
<a name="line-121"></a><span class='hs-comment'>-- * 1.parameter dtdPart : the children of the @DOCTYPE@ node</span>
<a name="line-122"></a><span class='hs-comment'>--</span>
<a name="line-123"></a><span class='hs-comment'>-- - 2.parameter notationNames : list of all notation names declared in the DTD</span>
<a name="line-124"></a><span class='hs-comment'>--</span>
<a name="line-125"></a><span class='hs-comment'>-- - returns : a list of errors</span>
<a name="line-126"></a>
<a name="line-127"></a><a name="validateEntities"></a><span class='hs-definition'>validateEntities</span> <span class='hs-keyglyph'>::</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>LA</span> <span class='hs-conid'>XmlTrees</span> <span class='hs-conid'>XmlTree</span>
<a name="line-128"></a><span class='hs-definition'>validateEntities</span> <span class='hs-varid'>notationNames</span>
<a name="line-129"></a> <span class='hs-keyglyph'>=</span> <span class='hs-layout'>(</span> <span class='hs-varid'>fromSLA</span> <span class='hs-conid'>[]</span> <span class='hs-layout'>(</span> <span class='hs-varid'>unlistA</span>
<a name="line-130"></a> <span class='hs-varop'>>>></span>
<a name="line-131"></a> <span class='hs-varid'>isDTDEntity</span>
<a name="line-132"></a> <span class='hs-varop'>>>></span>
<a name="line-133"></a> <span class='hs-layout'>(</span><span class='hs-varid'>checkForUniqueEntity</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>getDTDAttrl</span><span class='hs-layout'>)</span>
<a name="line-134"></a> <span class='hs-layout'>)</span>
<a name="line-135"></a> <span class='hs-layout'>)</span>
<a name="line-136"></a> <span class='hs-varop'><+></span>
<a name="line-137"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>unlistA</span>
<a name="line-138"></a> <span class='hs-varop'>>>></span>
<a name="line-139"></a> <span class='hs-varid'>isUnparsedEntity</span>
<a name="line-140"></a> <span class='hs-varop'>>>></span>
<a name="line-141"></a> <span class='hs-layout'>(</span><span class='hs-varid'>checkNotationDecl</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>getDTDAttrl</span><span class='hs-layout'>)</span>
<a name="line-142"></a> <span class='hs-layout'>)</span>
<a name="line-143"></a> <span class='hs-keyword'>where</span>
<a name="line-144"></a>
<a name="line-145"></a> <span class='hs-comment'>-- Check if entities are declared multiple times</span>
<a name="line-146"></a>
<a name="line-147"></a> <span class='hs-varid'>checkForUniqueEntity</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SLA</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-conid'>XmlTree</span> <span class='hs-conid'>XmlTree</span>
<a name="line-148"></a> <span class='hs-varid'>checkForUniqueEntity</span> <span class='hs-varid'>al</span>
<a name="line-149"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>checkName</span> <span class='hs-varid'>name</span> <span class='hs-varop'>$</span>
<a name="line-150"></a> <span class='hs-varid'>warn</span> <span class='hs-layout'>(</span> <span class='hs-str'>"Entity "</span><span class='hs-varop'>++</span> <span class='hs-varid'>show</span> <span class='hs-varid'>name</span> <span class='hs-varop'>++</span> <span class='hs-str'>" was already specified. "</span> <span class='hs-varop'>++</span>
<a name="line-151"></a> <span class='hs-str'>"First declaration will be used."</span> <span class='hs-layout'>)</span>
<a name="line-152"></a> <span class='hs-keyword'>where</span>
<a name="line-153"></a> <span class='hs-varid'>name</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al</span>
<a name="line-154"></a>
<a name="line-155"></a> <span class='hs-comment'>-- Find unparsed entities for which no notation is specified</span>
<a name="line-156"></a>
<a name="line-157"></a> <span class='hs-varid'>checkNotationDecl</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>XmlArrow</span>
<a name="line-158"></a> <span class='hs-varid'>checkNotationDecl</span> <span class='hs-varid'>al</span>
<a name="line-159"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>notationName</span> <span class='hs-varop'>`elem`</span> <span class='hs-varid'>notationNames</span>
<a name="line-160"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>none</span>
<a name="line-161"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span>
<a name="line-162"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>err</span> <span class='hs-layout'>(</span> <span class='hs-str'>"The notation "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>show</span> <span class='hs-varid'>notationName</span> <span class='hs-varop'>++</span> <span class='hs-str'>" must be declared "</span> <span class='hs-varop'>++</span>
<a name="line-163"></a> <span class='hs-str'>"when referenced in the unparsed entity declaration for "</span> <span class='hs-varop'>++</span>
<a name="line-164"></a> <span class='hs-varid'>show</span> <span class='hs-varid'>upEntityName</span> <span class='hs-varop'>++</span> <span class='hs-str'>"."</span>
<a name="line-165"></a> <span class='hs-layout'>)</span>
<a name="line-166"></a> <span class='hs-keyword'>where</span>
<a name="line-167"></a> <span class='hs-varid'>notationName</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>lookup1</span> <span class='hs-varid'>k_ndata</span> <span class='hs-varid'>al</span>
<a name="line-168"></a> <span class='hs-varid'>upEntityName</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al</span>
<a name="line-169"></a>
<a name="line-170"></a><span class='hs-comment'>-- |</span>
<a name="line-171"></a><span class='hs-comment'>-- Validation of Element declarations.</span>
<a name="line-172"></a><span class='hs-comment'>--</span>
<a name="line-173"></a><span class='hs-comment'>-- 1. Validates that an element is not declared multiple times.</span>
<a name="line-174"></a><span class='hs-comment'>--</span>
<a name="line-175"></a><span class='hs-comment'>-- Validity constraint: Unique Element Type Declaration (3.2 \/ p.21 in Spec)</span>
<a name="line-176"></a><span class='hs-comment'>--</span>
<a name="line-177"></a><span class='hs-comment'>--</span>
<a name="line-178"></a><span class='hs-comment'>-- 2. Validates that an element name only appears once in a mixed-content declaration.</span>
<a name="line-179"></a><span class='hs-comment'>--</span>
<a name="line-180"></a><span class='hs-comment'>-- Validity constraint: No Duplicate Types (3.2 \/ p.21 in Spec)</span>
<a name="line-181"></a><span class='hs-comment'>--</span>
<a name="line-182"></a><span class='hs-comment'>--</span>
<a name="line-183"></a><span class='hs-comment'>-- 3. Issues a warning if an element mentioned in a content model is not declared in the</span>
<a name="line-184"></a><span class='hs-comment'>-- DTD.</span>
<a name="line-185"></a><span class='hs-comment'>--</span>
<a name="line-186"></a><span class='hs-comment'>-- Optional warning: (3.2 \/ p.21 in Spec)</span>
<a name="line-187"></a><span class='hs-comment'>--</span>
<a name="line-188"></a><span class='hs-comment'>-- * 1.parameter dtdPart : the children of the @DOCTYPE@ node</span>
<a name="line-189"></a><span class='hs-comment'>--</span>
<a name="line-190"></a><span class='hs-comment'>-- - 2.parameter elemNames : list of all element names declared in the DTD</span>
<a name="line-191"></a><span class='hs-comment'>--</span>
<a name="line-192"></a><span class='hs-comment'>-- - returns : a list of errors</span>
<a name="line-193"></a>
<a name="line-194"></a>
<a name="line-195"></a><a name="validateElements"></a><span class='hs-definition'>validateElements</span> <span class='hs-keyglyph'>::</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>LA</span> <span class='hs-conid'>XmlTrees</span> <span class='hs-conid'>XmlTree</span>
<a name="line-196"></a><span class='hs-definition'>validateElements</span> <span class='hs-varid'>elemNames</span> <span class='hs-comment'>-- dtdPart</span>
<a name="line-197"></a> <span class='hs-keyglyph'>=</span> <span class='hs-layout'>(</span> <span class='hs-varid'>fromSLA</span> <span class='hs-conid'>[]</span> <span class='hs-layout'>(</span> <span class='hs-varid'>unlistA</span>
<a name="line-198"></a> <span class='hs-varop'>>>></span>
<a name="line-199"></a> <span class='hs-varid'>isDTDElement</span>
<a name="line-200"></a> <span class='hs-varop'>>>></span>
<a name="line-201"></a> <span class='hs-layout'>(</span><span class='hs-varid'>checkForUniqueElement</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>getDTDAttrl</span><span class='hs-layout'>)</span>
<a name="line-202"></a> <span class='hs-layout'>)</span>
<a name="line-203"></a> <span class='hs-layout'>)</span>
<a name="line-204"></a> <span class='hs-varop'><+></span>
<a name="line-205"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>unlistA</span>
<a name="line-206"></a> <span class='hs-varop'>>>></span>
<a name="line-207"></a> <span class='hs-varid'>isMixedContentElement</span>
<a name="line-208"></a> <span class='hs-varop'>>>></span>
<a name="line-209"></a> <span class='hs-layout'>(</span><span class='hs-varid'>checkMixedContent</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>getDTDAttrl</span><span class='hs-layout'>)</span>
<a name="line-210"></a> <span class='hs-layout'>)</span>
<a name="line-211"></a> <span class='hs-varop'><+></span>
<a name="line-212"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>unlistA</span>
<a name="line-213"></a> <span class='hs-varop'>>>></span>
<a name="line-214"></a> <span class='hs-varid'>isDTDElement</span>
<a name="line-215"></a> <span class='hs-varop'>>>></span>
<a name="line-216"></a> <span class='hs-layout'>(</span><span class='hs-varid'>checkContentModel</span> <span class='hs-varid'>elemNames</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>getDTDAttrl</span><span class='hs-layout'>)</span>
<a name="line-217"></a> <span class='hs-layout'>)</span>
<a name="line-218"></a> <span class='hs-keyword'>where</span>
<a name="line-219"></a>
<a name="line-220"></a> <span class='hs-comment'>-- Validates that an element is not declared multiple times</span>
<a name="line-221"></a>
<a name="line-222"></a> <span class='hs-varid'>checkForUniqueElement</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SLA</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-conid'>XmlTree</span> <span class='hs-conid'>XmlTree</span>
<a name="line-223"></a> <span class='hs-varid'>checkForUniqueElement</span> <span class='hs-varid'>al</span>
<a name="line-224"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>checkName</span> <span class='hs-varid'>name</span> <span class='hs-varop'>$</span>
<a name="line-225"></a> <span class='hs-varid'>err</span> <span class='hs-layout'>(</span> <span class='hs-str'>"Element type "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>show</span> <span class='hs-varid'>name</span> <span class='hs-varop'>++</span>
<a name="line-226"></a> <span class='hs-str'>" must not be declared more than once."</span> <span class='hs-layout'>)</span>
<a name="line-227"></a> <span class='hs-keyword'>where</span>
<a name="line-228"></a> <span class='hs-varid'>name</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al</span>
<a name="line-229"></a>
<a name="line-230"></a> <span class='hs-comment'>-- Validates that an element name only appears once in a mixed-content declaration</span>
<a name="line-231"></a>
<a name="line-232"></a> <span class='hs-varid'>checkMixedContent</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>XmlArrow</span>
<a name="line-233"></a> <span class='hs-varid'>checkMixedContent</span> <span class='hs-varid'>al</span>
<a name="line-234"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fromSLA</span> <span class='hs-conid'>[]</span> <span class='hs-layout'>(</span> <span class='hs-varid'>getChildren</span>
<a name="line-235"></a> <span class='hs-varop'>>>></span>
<a name="line-236"></a> <span class='hs-varid'>getChildren</span>
<a name="line-237"></a> <span class='hs-varop'>>>></span>
<a name="line-238"></a> <span class='hs-varid'>isDTDName</span>
<a name="line-239"></a> <span class='hs-varop'>>>></span>
<a name="line-240"></a> <span class='hs-layout'>(</span><span class='hs-varid'>check</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>getDTDAttrl</span><span class='hs-layout'>)</span>
<a name="line-241"></a> <span class='hs-layout'>)</span>
<a name="line-242"></a> <span class='hs-keyword'>where</span>
<a name="line-243"></a> <span class='hs-varid'>elemName</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al</span>
<a name="line-244"></a> <span class='hs-varid'>check</span> <span class='hs-varid'>al'</span>
<a name="line-245"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>checkName</span> <span class='hs-varid'>name</span> <span class='hs-varop'>$</span>
<a name="line-246"></a> <span class='hs-varid'>err</span> <span class='hs-layout'>(</span> <span class='hs-str'>"The element type "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>show</span> <span class='hs-varid'>name</span> <span class='hs-varop'>++</span>
<a name="line-247"></a> <span class='hs-str'>" was already specified in the mixed-content model of the element declaration "</span> <span class='hs-varop'>++</span>
<a name="line-248"></a> <span class='hs-varid'>show</span> <span class='hs-varid'>elemName</span> <span class='hs-varop'>++</span> <span class='hs-str'>"."</span> <span class='hs-layout'>)</span>
<a name="line-249"></a> <span class='hs-keyword'>where</span>
<a name="line-250"></a> <span class='hs-varid'>name</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al'</span>
<a name="line-251"></a>
<a name="line-252"></a> <span class='hs-comment'>-- Issues a warning if an element mentioned in a content model is not</span>
<a name="line-253"></a> <span class='hs-comment'>-- declared in the DTD.</span>
<a name="line-254"></a> <span class='hs-varid'>checkContentModel</span> <span class='hs-keyglyph'>::</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>XmlArrow</span>
<a name="line-255"></a> <span class='hs-varid'>checkContentModel</span> <span class='hs-varid'>names</span> <span class='hs-varid'>al</span>
<a name="line-256"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>cm</span> <span class='hs-varop'>`elem`</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>v_children</span><span class='hs-layout'>,</span> <span class='hs-varid'>v_mixed</span><span class='hs-keyglyph'>]</span>
<a name="line-257"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>getChildren</span> <span class='hs-varop'>>>></span> <span class='hs-varid'>checkContent</span>
<a name="line-258"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span>
<a name="line-259"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>none</span>
<a name="line-260"></a> <span class='hs-keyword'>where</span>
<a name="line-261"></a> <span class='hs-varid'>elemName</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al</span>
<a name="line-262"></a> <span class='hs-varid'>cm</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_type</span> <span class='hs-varid'>al</span>
<a name="line-263"></a>
<a name="line-264"></a> <span class='hs-varid'>checkContent</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>XmlArrow</span>
<a name="line-265"></a> <span class='hs-varid'>checkContent</span>
<a name="line-266"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>choiceA</span>
<a name="line-267"></a> <span class='hs-keyglyph'>[</span> <span class='hs-varid'>isDTDName</span> <span class='hs-conop'>:-></span> <span class='hs-layout'>(</span> <span class='hs-varid'>checkName'</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>getDTDAttrl</span> <span class='hs-layout'>)</span>
<a name="line-268"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>isDTDContent</span> <span class='hs-conop'>:-></span> <span class='hs-layout'>(</span> <span class='hs-varid'>getChildren</span> <span class='hs-varop'>>>></span> <span class='hs-varid'>checkContent</span> <span class='hs-layout'>)</span>
<a name="line-269"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>this</span> <span class='hs-conop'>:-></span> <span class='hs-varid'>none</span>
<a name="line-270"></a> <span class='hs-keyglyph'>]</span>
<a name="line-271"></a> <span class='hs-keyword'>where</span>
<a name="line-272"></a> <span class='hs-varid'>checkName'</span> <span class='hs-varid'>al'</span>
<a name="line-273"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>childElemName</span> <span class='hs-varop'>`elem`</span> <span class='hs-varid'>names</span>
<a name="line-274"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>none</span>
<a name="line-275"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span>
<a name="line-276"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>warn</span> <span class='hs-layout'>(</span> <span class='hs-str'>"The element type "</span><span class='hs-varop'>++</span> <span class='hs-varid'>show</span> <span class='hs-varid'>childElemName</span> <span class='hs-varop'>++</span>
<a name="line-277"></a> <span class='hs-str'>", used in content model of element "</span><span class='hs-varop'>++</span> <span class='hs-varid'>show</span> <span class='hs-varid'>elemName</span> <span class='hs-varop'>++</span>
<a name="line-278"></a> <span class='hs-str'>", is not declared."</span>
<a name="line-279"></a> <span class='hs-layout'>)</span>
<a name="line-280"></a> <span class='hs-keyword'>where</span>
<a name="line-281"></a> <span class='hs-varid'>childElemName</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al'</span>
<a name="line-282"></a>
<a name="line-283"></a><span class='hs-comment'>-- |</span>
<a name="line-284"></a><span class='hs-comment'>-- Validation of Attribute declarations.</span>
<a name="line-285"></a><span class='hs-comment'>--</span>
<a name="line-286"></a><span class='hs-comment'>-- (1) Issues a warning if an attribute is declared for an element type not itself</span>
<a name="line-287"></a><span class='hs-comment'>-- decared.</span>
<a name="line-288"></a><span class='hs-comment'>--</span>
<a name="line-289"></a><span class='hs-comment'>-- Optinal warning: (3.3 \/ p. 24 in Spec)</span>
<a name="line-290"></a><span class='hs-comment'>--</span>
<a name="line-291"></a><span class='hs-comment'>--</span>
<a name="line-292"></a><span class='hs-comment'>-- 2. Issues a warning if more than one definition is provided for the same</span>
<a name="line-293"></a><span class='hs-comment'>-- attribute of a given element type. Fist declaration is binding, later</span>
<a name="line-294"></a><span class='hs-comment'>-- definitions are ignored.</span>
<a name="line-295"></a><span class='hs-comment'>--</span>
<a name="line-296"></a><span class='hs-comment'>-- Optional warning: (3.3 \/ p.24 in Spec)</span>
<a name="line-297"></a><span class='hs-comment'>--</span>
<a name="line-298"></a><span class='hs-comment'>--</span>
<a name="line-299"></a><span class='hs-comment'>-- 3. Issues a warning if the same Nmtoken occures more than once in enumerated</span>
<a name="line-300"></a><span class='hs-comment'>-- attribute types of a single element type.</span>
<a name="line-301"></a><span class='hs-comment'>--</span>
<a name="line-302"></a><span class='hs-comment'>-- Optional warning: (3.3.1 \/ p.27 in Spec)</span>
<a name="line-303"></a><span class='hs-comment'>--</span>
<a name="line-304"></a><span class='hs-comment'>--</span>
<a name="line-305"></a><span class='hs-comment'>-- 4. Validates that an element type has not more than one ID attribute defined.</span>
<a name="line-306"></a><span class='hs-comment'>--</span>
<a name="line-307"></a><span class='hs-comment'>-- Validity constraint: One ID per Element Type (3.3.1 \/ p.26 in Spec)</span>
<a name="line-308"></a><span class='hs-comment'>--</span>
<a name="line-309"></a><span class='hs-comment'>--</span>
<a name="line-310"></a><span class='hs-comment'>-- 5. Validates that an element type has not more than one NOTATION attribute defined.</span>
<a name="line-311"></a><span class='hs-comment'>--</span>
<a name="line-312"></a><span class='hs-comment'>-- Validity constraint: One Notation per Element Type (3.3.1 \/ p.27 in Spec)</span>
<a name="line-313"></a><span class='hs-comment'>--</span>
<a name="line-314"></a><span class='hs-comment'>--</span>
<a name="line-315"></a><span class='hs-comment'>-- 6. Validates that an ID attributes has the type #IMPLIED or #REQUIRED.</span>
<a name="line-316"></a><span class='hs-comment'>--</span>
<a name="line-317"></a><span class='hs-comment'>-- Validity constraint: ID Attribute Default (3.3.1 \/ p.26 in Spec)</span>
<a name="line-318"></a><span class='hs-comment'>--</span>
<a name="line-319"></a><span class='hs-comment'>--</span>
<a name="line-320"></a><span class='hs-comment'>-- 7. Validates that all referenced notations are declared.</span>
<a name="line-321"></a><span class='hs-comment'>--</span>
<a name="line-322"></a><span class='hs-comment'>-- Validity constraint: Notation Attributes (3.3.1 \/ p.27 in Spec)</span>
<a name="line-323"></a><span class='hs-comment'>--</span>
<a name="line-324"></a><span class='hs-comment'>--</span>
<a name="line-325"></a><span class='hs-comment'>-- 8. Validates that notations are not declared for EMPTY elements.</span>
<a name="line-326"></a><span class='hs-comment'>--</span>
<a name="line-327"></a><span class='hs-comment'>-- Validity constraint: No Notation on Empty Element (3.3.1 \/p.27 in Spec)</span>
<a name="line-328"></a><span class='hs-comment'>--</span>
<a name="line-329"></a><span class='hs-comment'>--</span>
<a name="line-330"></a><span class='hs-comment'>-- 9. Validates that the default value matches the lexical constraints of it's type.</span>
<a name="line-331"></a><span class='hs-comment'>--</span>
<a name="line-332"></a><span class='hs-comment'>-- Validity constraint: Attribute default legal (3.3.2 \/ p.28 in Spec)</span>
<a name="line-333"></a><span class='hs-comment'>--</span>
<a name="line-334"></a><span class='hs-comment'>--</span>
<a name="line-335"></a><span class='hs-comment'>-- * 1.parameter dtdPart : the children of the @DOCTYPE@ node</span>
<a name="line-336"></a><span class='hs-comment'>--</span>
<a name="line-337"></a><span class='hs-comment'>-- - 2.parameter elemNames : list of all element names declared in the DTD</span>
<a name="line-338"></a><span class='hs-comment'>--</span>
<a name="line-339"></a><span class='hs-comment'>-- - 3.parameter notationNames : list of all notation names declared in the DTD</span>
<a name="line-340"></a><span class='hs-comment'>--</span>
<a name="line-341"></a><span class='hs-comment'>-- - returns : a list of errors</span>
<a name="line-342"></a>
<a name="line-343"></a><a name="validateAttributes"></a><span class='hs-definition'>validateAttributes</span> <span class='hs-keyglyph'>::</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>LA</span> <span class='hs-conid'>XmlTrees</span> <span class='hs-conid'>XmlTree</span>
<a name="line-344"></a><span class='hs-definition'>validateAttributes</span> <span class='hs-varid'>elemNames</span> <span class='hs-varid'>notationNames</span>
<a name="line-345"></a> <span class='hs-keyglyph'>=</span> <span class='hs-comment'>-- 1. Find attributes for which no elements are declared</span>
<a name="line-346"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>runCheck</span> <span class='hs-varid'>this</span> <span class='hs-layout'>(</span><span class='hs-varid'>checkDeclaredElements</span> <span class='hs-varid'>elemNames</span><span class='hs-layout'>)</span> <span class='hs-layout'>)</span>
<a name="line-347"></a> <span class='hs-varop'><+></span>
<a name="line-348"></a> <span class='hs-comment'>-- 2. Find attributes which are declared more than once</span>
<a name="line-349"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>runNameCheck</span> <span class='hs-varid'>this</span> <span class='hs-varid'>checkForUniqueAttributeDeclaration</span> <span class='hs-layout'>)</span>
<a name="line-350"></a> <span class='hs-varop'><+></span>
<a name="line-351"></a> <span class='hs-comment'>-- 3. Find enumerated attribute types which nmtokens are declared more than once</span>
<a name="line-352"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>runCheck</span> <span class='hs-layout'>(</span><span class='hs-varid'>isEnumAttrType</span> <span class='hs-varop'>`orElse`</span> <span class='hs-varid'>isNotationAttrType</span><span class='hs-layout'>)</span> <span class='hs-varid'>checkEnumeratedTypes</span> <span class='hs-layout'>)</span>
<a name="line-353"></a> <span class='hs-varop'><+></span>
<a name="line-354"></a> <span class='hs-comment'>-- 4. Validate that there exists only one ID attribute for an element</span>
<a name="line-355"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>runNameCheck</span> <span class='hs-varid'>isIdAttrType</span> <span class='hs-varid'>checkForUniqueId</span> <span class='hs-layout'>)</span>
<a name="line-356"></a> <span class='hs-varop'><+></span>
<a name="line-357"></a> <span class='hs-comment'>-- 5. Validate that there exists only one NOTATION attribute for an element</span>
<a name="line-358"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>runNameCheck</span> <span class='hs-varid'>isNotationAttrType</span> <span class='hs-varid'>checkForUniqueNotation</span> <span class='hs-layout'>)</span>
<a name="line-359"></a> <span class='hs-varop'><+></span>
<a name="line-360"></a> <span class='hs-comment'>-- 6. Validate that ID attributes have the type #IMPLIED or #REQUIRED</span>
<a name="line-361"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>runCheck</span> <span class='hs-varid'>isIdAttrType</span> <span class='hs-varid'>checkIdKindConstraint</span> <span class='hs-layout'>)</span>
<a name="line-362"></a> <span class='hs-varop'><+></span>
<a name="line-363"></a> <span class='hs-comment'>-- 7. Validate that all referenced notations are declared</span>
<a name="line-364"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>runCheck</span> <span class='hs-varid'>isNotationAttrType</span> <span class='hs-layout'>(</span><span class='hs-varid'>checkNotationDeclaration</span> <span class='hs-varid'>notationNames</span><span class='hs-layout'>)</span> <span class='hs-layout'>)</span>
<a name="line-365"></a> <span class='hs-varop'><+></span>
<a name="line-366"></a> <span class='hs-comment'>-- 8. Validate that notations are not declared for EMPTY elements</span>
<a name="line-367"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>checkNoNotationForEmptyElements</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>listA</span> <span class='hs-layout'>(</span> <span class='hs-varid'>unlistA</span>
<a name="line-368"></a> <span class='hs-varop'>>>></span>
<a name="line-369"></a> <span class='hs-varid'>isEmptyElement</span>
<a name="line-370"></a> <span class='hs-varop'>>>></span>
<a name="line-371"></a> <span class='hs-varid'>getDTDAttrValue</span> <span class='hs-varid'>a_name</span>
<a name="line-372"></a> <span class='hs-layout'>)</span>
<a name="line-373"></a> <span class='hs-layout'>)</span>
<a name="line-374"></a> <span class='hs-varop'><+></span>
<a name="line-375"></a> <span class='hs-comment'>-- 9. Validate that the default value matches the lexical constraints of it's type</span>
<a name="line-376"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>checkDefaultValueTypes</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>this</span> <span class='hs-layout'>)</span>
<a name="line-377"></a>
<a name="line-378"></a> <span class='hs-keyword'>where</span>
<a name="line-379"></a> <span class='hs-comment'>-- ------------------------------------------------------------</span>
<a name="line-380"></a> <span class='hs-comment'>-- control structures</span>
<a name="line-381"></a>
<a name="line-382"></a> <span class='hs-varid'>runCheck</span> <span class='hs-varid'>select</span> <span class='hs-varid'>check</span>
<a name="line-383"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unlistA</span> <span class='hs-varop'>>>></span> <span class='hs-varid'>isDTDAttlist</span>
<a name="line-384"></a> <span class='hs-varop'>>>></span>
<a name="line-385"></a> <span class='hs-varid'>select</span>
<a name="line-386"></a> <span class='hs-varop'>>>></span>
<a name="line-387"></a> <span class='hs-layout'>(</span><span class='hs-varid'>check</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>getDTDAttrl</span><span class='hs-layout'>)</span>
<a name="line-388"></a>
<a name="line-389"></a> <span class='hs-varid'>runNameCheck</span> <span class='hs-varid'>select</span> <span class='hs-varid'>check</span>
<a name="line-390"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fromSLA</span> <span class='hs-conid'>[]</span> <span class='hs-varop'>$</span> <span class='hs-varid'>runCheck</span> <span class='hs-varid'>select</span> <span class='hs-varid'>check</span>
<a name="line-391"></a>
<a name="line-392"></a> <span class='hs-comment'>--------------------------------------------------------------------------</span>
<a name="line-393"></a>
<a name="line-394"></a> <span class='hs-comment'>-- 1. Find attributes for which no elements are declared</span>
<a name="line-395"></a>
<a name="line-396"></a> <span class='hs-varid'>checkDeclaredElements</span> <span class='hs-keyglyph'>::</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>XmlArrow</span>
<a name="line-397"></a> <span class='hs-varid'>checkDeclaredElements</span> <span class='hs-varid'>elemNames'</span> <span class='hs-varid'>al</span>
<a name="line-398"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>en</span> <span class='hs-varop'>`elem`</span> <span class='hs-varid'>elemNames'</span>
<a name="line-399"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>none</span>
<a name="line-400"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span>
<a name="line-401"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>warn</span> <span class='hs-layout'>(</span> <span class='hs-str'>"The element type \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>en</span> <span class='hs-varop'>++</span> <span class='hs-str'>"\" used in dclaration "</span><span class='hs-varop'>++</span>
<a name="line-402"></a> <span class='hs-str'>"of attribute \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>an</span> <span class='hs-varop'>++</span><span class='hs-str'>"\" is not declared."</span>
<a name="line-403"></a> <span class='hs-layout'>)</span>
<a name="line-404"></a> <span class='hs-keyword'>where</span>
<a name="line-405"></a> <span class='hs-varid'>en</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al</span>
<a name="line-406"></a> <span class='hs-varid'>an</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_value</span> <span class='hs-varid'>al</span>
<a name="line-407"></a>
<a name="line-408"></a> <span class='hs-comment'>--------------------------------------------------------------------------</span>
<a name="line-409"></a>
<a name="line-410"></a> <span class='hs-comment'>-- 2. Find attributes which are declared more than once</span>
<a name="line-411"></a>
<a name="line-412"></a> <span class='hs-varid'>checkForUniqueAttributeDeclaration</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SLA</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-conid'>XmlTree</span> <span class='hs-conid'>XmlTree</span>
<a name="line-413"></a> <span class='hs-varid'>checkForUniqueAttributeDeclaration</span> <span class='hs-varid'>al</span>
<a name="line-414"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>checkName</span> <span class='hs-varid'>name</span> <span class='hs-varop'>$</span>
<a name="line-415"></a> <span class='hs-varid'>warn</span> <span class='hs-layout'>(</span> <span class='hs-str'>"Attribute \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>aname</span> <span class='hs-varop'>++</span><span class='hs-str'>"\" for element type \""</span><span class='hs-varop'>++</span>
<a name="line-416"></a> <span class='hs-varid'>ename</span> <span class='hs-varop'>++</span><span class='hs-str'>"\" is already declared. First "</span><span class='hs-varop'>++</span>
<a name="line-417"></a> <span class='hs-str'>"declaration will be used."</span> <span class='hs-layout'>)</span>
<a name="line-418"></a> <span class='hs-keyword'>where</span>
<a name="line-419"></a> <span class='hs-varid'>ename</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al</span>
<a name="line-420"></a> <span class='hs-varid'>aname</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_value</span> <span class='hs-varid'>al</span>
<a name="line-421"></a> <span class='hs-varid'>name</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>ename</span> <span class='hs-varop'>++</span> <span class='hs-str'>"|"</span> <span class='hs-varop'>++</span> <span class='hs-varid'>aname</span>
<a name="line-422"></a>
<a name="line-423"></a> <span class='hs-comment'>--------------------------------------------------------------------------</span>
<a name="line-424"></a>
<a name="line-425"></a> <span class='hs-comment'>-- 3. Find enumerated attribute types which nmtokens are declared more than once</span>
<a name="line-426"></a>
<a name="line-427"></a> <span class='hs-varid'>checkEnumeratedTypes</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>XmlArrow</span>
<a name="line-428"></a> <span class='hs-varid'>checkEnumeratedTypes</span> <span class='hs-varid'>al</span>
<a name="line-429"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fromSLA</span> <span class='hs-conid'>[]</span> <span class='hs-layout'>(</span> <span class='hs-varid'>getChildren</span>
<a name="line-430"></a> <span class='hs-varop'>>>></span>
<a name="line-431"></a> <span class='hs-varid'>isDTDName</span>
<a name="line-432"></a> <span class='hs-varop'>>>></span>
<a name="line-433"></a> <span class='hs-layout'>(</span><span class='hs-varid'>checkForUniqueType</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>getDTDAttrl</span><span class='hs-layout'>)</span>
<a name="line-434"></a> <span class='hs-layout'>)</span>
<a name="line-435"></a> <span class='hs-keyword'>where</span>
<a name="line-436"></a> <span class='hs-varid'>checkForUniqueType</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SLA</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-conid'>XmlTree</span> <span class='hs-conid'>XmlTree</span>
<a name="line-437"></a> <span class='hs-varid'>checkForUniqueType</span> <span class='hs-varid'>al'</span>
<a name="line-438"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>checkName</span> <span class='hs-varid'>nmtoken</span> <span class='hs-varop'>$</span>
<a name="line-439"></a> <span class='hs-varid'>warn</span> <span class='hs-layout'>(</span> <span class='hs-str'>"Nmtoken \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>nmtoken</span> <span class='hs-varop'>++</span><span class='hs-str'>"\" should not "</span><span class='hs-varop'>++</span>
<a name="line-440"></a> <span class='hs-str'>"occur more than once in attribute \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>dtd_value</span> <span class='hs-varid'>al</span> <span class='hs-varop'>++</span>
<a name="line-441"></a> <span class='hs-str'>"\" for element \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al</span> <span class='hs-varop'>++</span> <span class='hs-str'>"\"."</span> <span class='hs-layout'>)</span>
<a name="line-442"></a> <span class='hs-keyword'>where</span>
<a name="line-443"></a> <span class='hs-varid'>nmtoken</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al'</span>
<a name="line-444"></a>
<a name="line-445"></a> <span class='hs-comment'>--------------------------------------------------------------------------</span>
<a name="line-446"></a>
<a name="line-447"></a> <span class='hs-comment'>-- 4. Validate that there exists only one ID attribute for an element</span>
<a name="line-448"></a>
<a name="line-449"></a> <span class='hs-varid'>checkForUniqueId</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SLA</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-conid'>XmlTree</span> <span class='hs-conid'>XmlTree</span>
<a name="line-450"></a> <span class='hs-varid'>checkForUniqueId</span> <span class='hs-varid'>al</span>
<a name="line-451"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>checkName</span> <span class='hs-varid'>ename</span> <span class='hs-varop'>$</span>
<a name="line-452"></a> <span class='hs-varid'>err</span> <span class='hs-layout'>(</span> <span class='hs-str'>"Element \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>ename</span> <span class='hs-varop'>++</span> <span class='hs-str'>"\" already has attribute of type "</span><span class='hs-varop'>++</span>
<a name="line-453"></a> <span class='hs-str'>"ID, another attribute \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>dtd_value</span> <span class='hs-varid'>al</span> <span class='hs-varop'>++</span> <span class='hs-str'>"\" of type ID is "</span><span class='hs-varop'>++</span>
<a name="line-454"></a> <span class='hs-str'>"not permitted."</span> <span class='hs-layout'>)</span>
<a name="line-455"></a> <span class='hs-keyword'>where</span>
<a name="line-456"></a> <span class='hs-varid'>ename</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al</span>
<a name="line-457"></a>
<a name="line-458"></a> <span class='hs-comment'>--------------------------------------------------------------------------</span>
<a name="line-459"></a>
<a name="line-460"></a> <span class='hs-comment'>-- 5. Validate that there exists only one NOTATION attribute for an element</span>
<a name="line-461"></a>
<a name="line-462"></a> <span class='hs-varid'>checkForUniqueNotation</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SLA</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-conid'>XmlTree</span> <span class='hs-conid'>XmlTree</span>
<a name="line-463"></a> <span class='hs-varid'>checkForUniqueNotation</span> <span class='hs-varid'>al</span>
<a name="line-464"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>checkName</span> <span class='hs-varid'>ename</span> <span class='hs-varop'>$</span>
<a name="line-465"></a> <span class='hs-varid'>err</span> <span class='hs-layout'>(</span> <span class='hs-str'>"Element \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>ename</span> <span class='hs-varop'>++</span> <span class='hs-str'>"\" already has attribute of type "</span><span class='hs-varop'>++</span>
<a name="line-466"></a> <span class='hs-str'>"NOTATION, another attribute \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>dtd_value</span> <span class='hs-varid'>al</span> <span class='hs-varop'>++</span> <span class='hs-str'>"\" of type NOTATION "</span><span class='hs-varop'>++</span>
<a name="line-467"></a> <span class='hs-str'>"is not permitted."</span> <span class='hs-layout'>)</span>
<a name="line-468"></a> <span class='hs-keyword'>where</span>
<a name="line-469"></a> <span class='hs-varid'>ename</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al</span>
<a name="line-470"></a>
<a name="line-471"></a> <span class='hs-comment'>--------------------------------------------------------------------------</span>
<a name="line-472"></a>
<a name="line-473"></a> <span class='hs-comment'>-- 6. Validate that ID attributes have the type #IMPLIED or #REQUIRED</span>
<a name="line-474"></a>
<a name="line-475"></a> <span class='hs-varid'>checkIdKindConstraint</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>XmlArrow</span>
<a name="line-476"></a> <span class='hs-varid'>checkIdKindConstraint</span> <span class='hs-varid'>al</span>
<a name="line-477"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>attKind</span> <span class='hs-varop'>`elem`</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>k_implied</span><span class='hs-layout'>,</span> <span class='hs-varid'>k_required</span><span class='hs-keyglyph'>]</span>
<a name="line-478"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>none</span>
<a name="line-479"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span>
<a name="line-480"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>err</span> <span class='hs-layout'>(</span> <span class='hs-str'>"ID attribute \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>dtd_value</span> <span class='hs-varid'>al</span> <span class='hs-varop'>++</span><span class='hs-str'>"\" must have a declared default "</span><span class='hs-varop'>++</span>
<a name="line-481"></a> <span class='hs-str'>"of \"#IMPLIED\" or \"REQUIRED\""</span><span class='hs-layout'>)</span>
<a name="line-482"></a> <span class='hs-keyword'>where</span>
<a name="line-483"></a> <span class='hs-varid'>attKind</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_kind</span> <span class='hs-varid'>al</span>
<a name="line-484"></a>
<a name="line-485"></a>
<a name="line-486"></a> <span class='hs-comment'>--------------------------------------------------------------------------</span>
<a name="line-487"></a>
<a name="line-488"></a> <span class='hs-comment'>-- 7. Validate that all referenced notations are declared</span>
<a name="line-489"></a>
<a name="line-490"></a> <span class='hs-varid'>checkNotationDeclaration</span> <span class='hs-keyglyph'>::</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>XmlArrow</span>
<a name="line-491"></a> <span class='hs-varid'>checkNotationDeclaration</span> <span class='hs-varid'>notations</span> <span class='hs-varid'>al</span>
<a name="line-492"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>getChildren</span>
<a name="line-493"></a> <span class='hs-varop'>>>></span>
<a name="line-494"></a> <span class='hs-varid'>isDTDName</span>
<a name="line-495"></a> <span class='hs-varop'>>>></span>
<a name="line-496"></a> <span class='hs-layout'>(</span><span class='hs-varid'>checkNotations</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>getDTDAttrl</span><span class='hs-layout'>)</span>
<a name="line-497"></a> <span class='hs-keyword'>where</span>
<a name="line-498"></a> <span class='hs-varid'>checkNotations</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>XmlArrow</span>
<a name="line-499"></a> <span class='hs-varid'>checkNotations</span> <span class='hs-varid'>al'</span>
<a name="line-500"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>notation</span> <span class='hs-varop'>`elem`</span> <span class='hs-varid'>notations</span>
<a name="line-501"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>none</span>
<a name="line-502"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span>
<a name="line-503"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>err</span> <span class='hs-layout'>(</span> <span class='hs-str'>"The notation \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>notation</span> <span class='hs-varop'>++</span><span class='hs-str'>"\" must be declared when "</span><span class='hs-varop'>++</span>
<a name="line-504"></a> <span class='hs-str'>"referenced in the notation type list for attribute \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>dtd_value</span> <span class='hs-varid'>al</span> <span class='hs-varop'>++</span>
<a name="line-505"></a> <span class='hs-str'>"\" of element \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al</span> <span class='hs-varop'>++</span><span class='hs-str'>"\"."</span>
<a name="line-506"></a> <span class='hs-layout'>)</span>
<a name="line-507"></a> <span class='hs-keyword'>where</span>
<a name="line-508"></a> <span class='hs-varid'>notation</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al'</span>
<a name="line-509"></a>
<a name="line-510"></a> <span class='hs-comment'>--------------------------------------------------------------------------</span>
<a name="line-511"></a>
<a name="line-512"></a> <span class='hs-comment'>-- 8. Validate that notations are not declared for EMPTY elements</span>
<a name="line-513"></a>
<a name="line-514"></a> <span class='hs-varid'>checkNoNotationForEmptyElements</span> <span class='hs-keyglyph'>::</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>LA</span> <span class='hs-conid'>XmlTrees</span> <span class='hs-conid'>XmlTree</span>
<a name="line-515"></a> <span class='hs-varid'>checkNoNotationForEmptyElements</span> <span class='hs-varid'>emptyElems</span>
<a name="line-516"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unlistA</span>
<a name="line-517"></a> <span class='hs-varop'>>>></span>
<a name="line-518"></a> <span class='hs-varid'>isDTDAttlist</span>
<a name="line-519"></a> <span class='hs-varop'>>>></span>
<a name="line-520"></a> <span class='hs-varid'>isNotationAttrType</span>
<a name="line-521"></a> <span class='hs-varop'>>>></span>
<a name="line-522"></a> <span class='hs-layout'>(</span><span class='hs-varid'>checkNoNotationForEmptyElement</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>getDTDAttrl</span><span class='hs-layout'>)</span>
<a name="line-523"></a> <span class='hs-keyword'>where</span>
<a name="line-524"></a> <span class='hs-varid'>checkNoNotationForEmptyElement</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>XmlArrow</span>
<a name="line-525"></a> <span class='hs-varid'>checkNoNotationForEmptyElement</span> <span class='hs-varid'>al</span>
<a name="line-526"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>ename</span> <span class='hs-varop'>`elem`</span> <span class='hs-varid'>emptyElems</span>
<a name="line-527"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>err</span> <span class='hs-layout'>(</span> <span class='hs-str'>"Attribute \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>dtd_value</span> <span class='hs-varid'>al</span> <span class='hs-varop'>++</span><span class='hs-str'>"\" of type NOTATION must not be "</span><span class='hs-varop'>++</span>
<a name="line-528"></a> <span class='hs-str'>"declared on the element \""</span><span class='hs-varop'>++</span> <span class='hs-varid'>ename</span> <span class='hs-varop'>++</span><span class='hs-str'>"\" declared EMPTY."</span>
<a name="line-529"></a> <span class='hs-layout'>)</span>
<a name="line-530"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span>
<a name="line-531"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>none</span>
<a name="line-532"></a> <span class='hs-keyword'>where</span>
<a name="line-533"></a> <span class='hs-varid'>ename</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al</span>
<a name="line-534"></a>
<a name="line-535"></a> <span class='hs-comment'>--------------------------------------------------------------------------</span>
<a name="line-536"></a>
<a name="line-537"></a> <span class='hs-comment'>-- 9. Validate that default values meet the lexical constraints of the attribute types</span>
<a name="line-538"></a>
<a name="line-539"></a> <span class='hs-varid'>checkDefaultValueTypes</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>XmlTrees</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>LA</span> <span class='hs-conid'>XmlTrees</span> <span class='hs-conid'>XmlTree</span>
<a name="line-540"></a> <span class='hs-varid'>checkDefaultValueTypes</span> <span class='hs-varid'>dtdPart'</span>
<a name="line-541"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unlistA</span> <span class='hs-varop'>>>></span> <span class='hs-varid'>isDTDAttlist</span>
<a name="line-542"></a> <span class='hs-varop'>>>></span>
<a name="line-543"></a> <span class='hs-varid'>isDefaultAttrKind</span>
<a name="line-544"></a> <span class='hs-varop'>>>></span>
<a name="line-545"></a> <span class='hs-layout'>(</span><span class='hs-varid'>checkAttributeValue</span> <span class='hs-varid'>dtdPart'</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>this</span><span class='hs-layout'>)</span>
<a name="line-546"></a>
<a name="line-547"></a><span class='hs-comment'>-- ------------------------------------------------------------</span>
<a name="line-548"></a>
<a name="line-549"></a><span class='hs-comment'>-- |</span>
<a name="line-550"></a><span class='hs-comment'>-- Removes doublicate declarations from the DTD, which first declaration is</span>
<a name="line-551"></a><span class='hs-comment'>-- binding. This is the case for ATTLIST and ENTITY declarations.</span>
<a name="line-552"></a><span class='hs-comment'>--</span>
<a name="line-553"></a><span class='hs-comment'>-- - returns : A function that replaces the children of DOCTYPE nodes by a list</span>
<a name="line-554"></a><span class='hs-comment'>-- where all multiple declarations are removed.</span>
<a name="line-555"></a>
<a name="line-556"></a><a name="removeDoublicateDefs"></a><span class='hs-definition'>removeDoublicateDefs</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>XmlArrow</span>
<a name="line-557"></a><span class='hs-definition'>removeDoublicateDefs</span>
<a name="line-558"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>replaceChildren</span>
<a name="line-559"></a> <span class='hs-layout'>(</span> <span class='hs-varid'>fromSLA</span> <span class='hs-conid'>[]</span> <span class='hs-layout'>(</span> <span class='hs-varid'>getChildren</span>
<a name="line-560"></a> <span class='hs-varop'>>>></span>
<a name="line-561"></a> <span class='hs-varid'>choiceA</span> <span class='hs-keyglyph'>[</span> <span class='hs-varid'>isDTDAttlist</span> <span class='hs-conop'>:-></span> <span class='hs-layout'>(</span><span class='hs-varid'>removeDoubleAttlist</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>getDTDAttrl</span><span class='hs-layout'>)</span>
<a name="line-562"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>isDTDEntity</span> <span class='hs-conop'>:-></span> <span class='hs-layout'>(</span><span class='hs-varid'>removeDoubleEntity</span> <span class='hs-varop'>$<</span> <span class='hs-varid'>getDTDAttrl</span><span class='hs-layout'>)</span>
<a name="line-563"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>this</span> <span class='hs-conop'>:-></span> <span class='hs-varid'>this</span>
<a name="line-564"></a> <span class='hs-keyglyph'>]</span>
<a name="line-565"></a> <span class='hs-layout'>)</span>
<a name="line-566"></a> <span class='hs-layout'>)</span>
<a name="line-567"></a> <span class='hs-varop'>`when`</span>
<a name="line-568"></a> <span class='hs-varid'>isDTDDoctype</span>
<a name="line-569"></a> <span class='hs-keyword'>where</span>
<a name="line-570"></a> <span class='hs-varid'>checkName'</span> <span class='hs-varid'>n'</span>
<a name="line-571"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>ifA</span> <span class='hs-layout'>(</span> <span class='hs-varid'>getState</span>
<a name="line-572"></a> <span class='hs-varop'>>>></span>
<a name="line-573"></a> <span class='hs-varid'>isA</span> <span class='hs-layout'>(</span><span class='hs-varid'>n'</span> <span class='hs-varop'>`elem`</span><span class='hs-layout'>)</span>
<a name="line-574"></a> <span class='hs-layout'>)</span>
<a name="line-575"></a> <span class='hs-varid'>none</span>
<a name="line-576"></a> <span class='hs-layout'>(</span><span class='hs-varid'>this</span> <span class='hs-varop'>>>></span> <span class='hs-varid'>perform</span> <span class='hs-layout'>(</span><span class='hs-varid'>nextState</span> <span class='hs-layout'>(</span><span class='hs-varid'>n'</span><span class='hs-conop'>:</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-577"></a>
<a name="line-578"></a> <span class='hs-varid'>removeDoubleAttlist</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SLA</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-conid'>XmlTree</span> <span class='hs-conid'>XmlTree</span>
<a name="line-579"></a> <span class='hs-varid'>removeDoubleAttlist</span> <span class='hs-varid'>al</span>
<a name="line-580"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>checkName'</span> <span class='hs-varid'>elemAttr</span>
<a name="line-581"></a> <span class='hs-keyword'>where</span>
<a name="line-582"></a> <span class='hs-varid'>elemAttr</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>elemName</span> <span class='hs-varop'>++</span> <span class='hs-str'>"|"</span> <span class='hs-varop'>++</span> <span class='hs-varid'>attrName</span>
<a name="line-583"></a> <span class='hs-varid'>attrName</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_value</span> <span class='hs-varid'>al</span>
<a name="line-584"></a> <span class='hs-varid'>elemName</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al</span>
<a name="line-585"></a>
<a name="line-586"></a> <span class='hs-varid'>removeDoubleEntity</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Attributes</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SLA</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>String</span><span class='hs-keyglyph'>]</span> <span class='hs-conid'>XmlTree</span> <span class='hs-conid'>XmlTree</span>
<a name="line-587"></a> <span class='hs-varid'>removeDoubleEntity</span> <span class='hs-varid'>al</span>
<a name="line-588"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>checkName'</span> <span class='hs-layout'>(</span><span class='hs-varid'>dtd_name</span> <span class='hs-varid'>al</span><span class='hs-layout'>)</span>
<a name="line-589"></a>
<a name="line-590"></a><span class='hs-comment'>-- ------------------------------------------------------------</span>
</pre></body>
</html>
|