* xmlValidBuildAContentModel: * @content: the content model * @ctxt: the schema parser context * @name: the element name whose content is being built * * Generate the automata sequence needed for that type * * Returns 1 if successful or 0 in case of error. */
| 444 | * Returns 1 if successful or 0 in case of error. |
| 445 | */ |
| 446 | static int |
| 447 | xmlValidBuildAContentModel(xmlElementContentPtr content, |
| 448 | xmlValidCtxtPtr ctxt, |
| 449 | const xmlChar *name) { |
| 450 | if (content == NULL) { |
| 451 | xmlErrValidNode(ctxt, NULL, XML_ERR_INTERNAL_ERROR, |
| 452 | "Found NULL content in content model of %s\n", |
| 453 | name, NULL, NULL); |
| 454 | return(0); |
| 455 | } |
| 456 | switch (content->type) { |
| 457 | case XML_ELEMENT_CONTENT_PCDATA: |
| 458 | xmlErrValidNode(ctxt, NULL, XML_ERR_INTERNAL_ERROR, |
| 459 | "Found PCDATA in content model of %s\n", |
| 460 | name, NULL, NULL); |
| 461 | return(0); |
| 462 | break; |
| 463 | case XML_ELEMENT_CONTENT_ELEMENT: { |
| 464 | xmlAutomataStatePtr oldstate = ctxt->state; |
| 465 | xmlChar fn[50]; |
| 466 | xmlChar *fullname; |
| 467 | |
| 468 | fullname = xmlBuildQName(content->name, content->prefix, fn, 50); |
| 469 | if (fullname == NULL) { |
| 470 | xmlVErrMemory(ctxt); |
| 471 | return(0); |
| 472 | } |
| 473 | |
| 474 | switch (content->ocur) { |
| 475 | case XML_ELEMENT_CONTENT_ONCE: |
| 476 | ctxt->state = xmlAutomataNewTransition(ctxt->am, |
| 477 | ctxt->state, NULL, fullname, NULL); |
| 478 | break; |
| 479 | case XML_ELEMENT_CONTENT_OPT: |
| 480 | ctxt->state = xmlAutomataNewTransition(ctxt->am, |
| 481 | ctxt->state, NULL, fullname, NULL); |
| 482 | xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state); |
| 483 | break; |
| 484 | case XML_ELEMENT_CONTENT_PLUS: |
| 485 | ctxt->state = xmlAutomataNewTransition(ctxt->am, |
| 486 | ctxt->state, NULL, fullname, NULL); |
| 487 | xmlAutomataNewTransition(ctxt->am, ctxt->state, |
| 488 | ctxt->state, fullname, NULL); |
| 489 | break; |
| 490 | case XML_ELEMENT_CONTENT_MULT: |
| 491 | ctxt->state = xmlAutomataNewEpsilon(ctxt->am, |
| 492 | ctxt->state, NULL); |
| 493 | xmlAutomataNewTransition(ctxt->am, |
| 494 | ctxt->state, ctxt->state, fullname, NULL); |
| 495 | break; |
| 496 | } |
| 497 | if ((fullname != fn) && (fullname != content->name)) |
| 498 | xmlFree(fullname); |
| 499 | break; |
| 500 | } |
| 501 | case XML_ELEMENT_CONTENT_SEQ: { |
| 502 | xmlAutomataStatePtr oldstate, oldend; |
| 503 | xmlElementContentOccur ocur; |
no test coverage detected