~ubuntu-branches/ubuntu/maverick/conglomerate/maverick

« back to all changes in this revision

Viewing changes to src/plugin-dtd.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2005-11-08 05:07:06 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051108050706-bcg60nwqf1z3w0d6
Tags: 0.9.1-1ubuntu1
* Resynchronise with Debian (Closes: #4397).
  - Thanks, Jordan Mantha.

Show diffs side-by-side

added added

removed removed

Lines of Context:
514
514
 
515
515
 
516
516
        /* Build up the document and its content: */
517
 
        converter->xml_doc = xmlNewDoc("1.0");
 
517
        converter->xml_doc = xmlNewDoc((const xmlChar*)"1.0");
518
518
        
519
519
        converter->grammar_node = xmlNewDocNode (converter->xml_doc,
520
520
                                                 NULL, /* xmlNsPtr ns, */
521
 
                                                 "grammar",
 
521
                                                 (const xmlChar*)"grammar",
522
522
                                                 NULL);
523
523
        converter->xml_ns = xmlNewNs (converter->grammar_node, 
524
 
                                      RELAX_NG_NS_URI, 
 
524
                                      (const xmlChar*)RELAX_NG_NS_URI, 
525
525
                                      NULL);
526
526
        xmlSetNs (converter->grammar_node, 
527
527
                  converter->xml_ns);
534
534
                GList *iter;
535
535
                converter->start_node = xmlNewDocNode (converter->xml_doc,
536
536
                                                       converter->xml_ns,
537
 
                                                       "start",
 
537
                                                       (const xmlChar*)"start",
538
538
                                                       NULL);
539
539
 
540
540
                xmlAddChild (converter->grammar_node,
547
547
                if (converter->list_of_start_elements->next) {
548
548
                        choice_node = xmlNewDocNode (converter->xml_doc,
549
549
                                                     converter->xml_ns,
550
 
                                                     "choice",
 
550
                                                     (const xmlChar*)"choice",
551
551
                                                     NULL);
552
552
                        xmlAddChild (converter->start_node,
553
553
                                     choice_node);
586
586
 
587
587
        xmlAddChild (xml_node,
588
588
                     xmlNewDocComment (xml_node->doc,
589
 
                                       "element is cross-referenced"));
 
589
                                       (const xmlChar*)"element is cross-referenced"));
590
590
}
591
591
 
592
592
/* Adds the element either via a ref, or directly inline, depending on whether its referenced elsewhere or not: */
633
633
{
634
634
        CongNodePtr node_ref = xmlNewDocNode(parent_node->doc,
635
635
                                             converter->xml_ns, 
636
 
                                             "ref",
 
636
                                             (const xmlChar*)"ref",
637
637
                                             NULL);
638
638
        xmlAddChild (parent_node, 
639
639
                     node_ref);
640
640
        
641
641
        xmlSetProp (node_ref,
642
 
                    "name",
 
642
                    (const xmlChar*)"name",
643
643
                    dtd_element->name);
644
644
}
645
645
 
659
659
{
660
660
        CongNodePtr node_element = xmlNewDocNode(parent_node->doc,
661
661
                                                 converter->xml_ns,
662
 
                                                 "element",
 
662
                                                 (const xmlChar*)"element",
663
663
                                                 NULL);
664
664
        xmlAddChild (parent_node, 
665
665
                     node_element);
666
666
        
667
667
        xmlSetProp (node_element,
668
 
                    "name",
 
668
                    (const xmlChar*)"name",
669
669
                    dtd_element->name);
670
670
        
671
671
        /* set up the content model */
695
695
 
696
696
                node_define = xmlNewDocNode (converter->xml_doc,
697
697
                                             converter->xml_ns,
698
 
                                             "define",
 
698
                                             (const xmlChar*)"define",
699
699
                                             NULL);                     
700
700
                xmlAddChild (converter->grammar_node, 
701
701
                             node_define);
702
702
                
703
703
                xmlSetProp (node_define,
704
 
                            "name",
 
704
                            (const xmlChar*)"name",
705
705
                            dtd_element->name);
706
706
                
707
707
                
730
730
 
731
731
        xml_ns = xmlSearchNsByHref (node_element->doc,
732
732
                                    node_element,
733
 
                                    RELAX_NG_NS_URI);
 
733
                                    (const xmlChar*)RELAX_NG_NS_URI);
734
734
        g_assert (xml_ns);
735
735
 
736
736
        switch (attr->def) {
740
740
                /* Attribute is optional: */
741
741
                node_occurrence = xmlNewDocNode(node_element->doc,
742
742
                                                xml_ns,
743
 
                                                "optional",
 
743
                                                (const xmlChar*)"optional",
744
744
                                                NULL);
745
745
                
746
746
                xmlAddChild (node_element,
757
757
 
758
758
        node_attribute= xmlNewDocNode(node_element->doc,
759
759
                                      xml_ns,
760
 
                                      "attribute",
 
760
                                      (const xmlChar*)"attribute",
761
761
                                      NULL);                    
762
762
        xmlAddChild (node_occurrence,
763
763
                     node_attribute);
764
764
        
765
765
        xmlSetProp (node_attribute,
766
 
                    "name",
 
766
                    (const xmlChar*)"name",
767
767
                    attr->name);
768
768
 
769
769
        /* FIXME: do we need to handle the default? */
807
807
                {
808
808
                        CongNodePtr node_choice = xmlNewDocNode(node_element->doc,
809
809
                                                                xml_ns,
810
 
                                                                "choice",
 
810
                                                                (const xmlChar*)"choice",
811
811
                                                                NULL);
812
812
                        xmlAddChild (node_attribute, 
813
813
                                     node_choice);
819
819
                                for (iter = attr->tree; iter; iter=iter->next) {
820
820
                                        CongNodePtr node_value = xmlNewDocNode(node_element->doc,
821
821
                                                                               xml_ns,
822
 
                                                                               "value",
 
822
                                                                               (const xmlChar*)"value",
823
823
                                                                               iter->name);
824
824
                                        xmlAddChild (node_choice,
825
825
                                                     node_value);
845
845
 
846
846
        xml_ns = xmlSearchNsByHref (node_parent->doc,
847
847
                                    node_parent,
848
 
                                    RELAX_NG_NS_URI);
 
848
                                    (const xmlChar*)RELAX_NG_NS_URI);
849
849
        g_assert (xml_ns);
850
850
 
851
851
        switch (content->ocur) {
858
858
        case XML_ELEMENT_CONTENT_OPT:
859
859
                node_occurrence = xmlNewDocNode(node_parent->doc,
860
860
                                                xml_ns,
861
 
                                                "optional",
 
861
                                                (const xmlChar*)"optional",
862
862
                                                NULL);
863
863
                xmlAddChild (node_parent, 
864
864
                             node_occurrence);
867
867
        case XML_ELEMENT_CONTENT_MULT:
868
868
                node_occurrence = xmlNewDocNode(node_parent->doc,
869
869
                                                xml_ns,
870
 
                                                "zeroOrMore",
 
870
                                                (const xmlChar*)"zeroOrMore",
871
871
                                                NULL);
872
872
                xmlAddChild (node_parent, 
873
873
                             node_occurrence);
876
876
        case XML_ELEMENT_CONTENT_PLUS:
877
877
                node_occurrence = xmlNewDocNode(node_parent->doc,
878
878
                                                xml_ns,
879
 
                                                "oneOrMore",
 
879
                                                (const xmlChar*)"oneOrMore",
880
880
                                                NULL);
881
881
                xmlAddChild (node_parent, 
882
882
                             node_occurrence);
892
892
                {
893
893
                        CongNodePtr node_text = xmlNewDocNode(node_occurrence->doc,
894
894
                                                              xml_ns,
895
 
                                                              "text",
 
895
                                                              (const xmlChar*)"text",
896
896
                                                              NULL);
897
897
                        xmlAddChild (node_occurrence, 
898
898
                                     node_text);
920
920
                        } else {
921
921
                                CongNodePtr node_group = xmlNewDocNode(node_occurrence->doc,
922
922
                                                                       xml_ns,
923
 
                                                                       "group",
 
923
                                                                       (const xmlChar*)"group",
924
924
                                                                       NULL);
925
925
                                xmlAddChild (node_occurrence, 
926
926
                                             node_group);
954
954
                                /* Non-optimised case: */
955
955
                                CongNodePtr node_choice = xmlNewDocNode(node_occurrence->doc,
956
956
                                                                        xml_ns, 
957
 
                                                                        "choice",
 
957
                                                                        (const xmlChar*)"choice",
958
958
                                                                        NULL);
959
959
                                xmlAddChild (node_occurrence, 
960
960
                                             node_choice);