531 xmlNodePtr node, num_node;
532 xmlNodePtr the_setting, the_point;
533 xmlNodePtr sp_node, ps_node, pp_node;
534 xmlAttrPtr s_node, p_node;
538 node =
findnode (racine -> children,
"settings");
539 if (node == NULL)
return 0;
540 s_node = node -> properties;
541 if (s_node == NULL)
return 0;
544 num_node = s_node -> children;
545 if (num_node == NULL)
return 0;
546 if (g_strcmp0 (
"num",(
char *)s_node -> name) == 0)
548 content = xmlNodeGetContent(num_node);
552 s_node = s_node -> next;
556 spg -> settings = g_malloc0(spg -> nums*
sizeof*spg -> settings);
557 node = node -> children;
558 if (node == NULL)
return 0;
560 for (sp_node = node; sp_node; sp_node = sp_node -> next)
562 if (sp_node -> type == XML_ELEMENT_NODE)
564 s_node = sp_node -> properties;
565 if (s_node == NULL)
return 0;
568 the_setting = s_node -> children;
569 if (the_setting == NULL)
return 0;
570 content = xmlNodeGetContent(the_setting);
571 if (g_strcmp0 (
"name",(
char *)s_node -> name) == 0)
573 spg -> settings[j].
name = g_strdup_printf (
"%s", content);
575 else if (g_strcmp0 (
"origin",(
char *)s_node -> name) == 0)
579 else if (g_strcmp0 (
"x",(
char *)s_node -> name) == 0)
581 spg -> settings[j].pos[0] = g_strdup_printf (
"%s", content);
583 else if (g_strcmp0 (
"y",(
char *)s_node -> name) == 0)
585 spg -> settings[j].pos[1] = g_strdup_printf (
"%s", content);
587 else if (g_strcmp0 (
"z",(
char *)s_node -> name) == 0)
589 spg -> settings[j].pos[2] = g_strdup_printf (
"%s", content);
592 s_node = s_node -> next;
594 ps_node =
findnode (sp_node -> children,
"points");
597 p_node = ps_node -> properties;
598 if (p_node == NULL)
return 0;
601 num_node = p_node -> children;
602 if (num_node == NULL)
return 0;
603 if (g_strcmp0 (
"num",(
char *)p_node -> name) == 0)
605 content = xmlNodeGetContent(num_node);
609 p_node = p_node -> next;
612 spg -> settings[j].nump =
val;
613 spg -> settings[j].points = g_malloc0(
val*
sizeof*spg -> settings[j].points);
614 ps_node = ps_node -> children;
615 if (ps_node == NULL)
return 0;
617 for (pp_node = ps_node; pp_node; pp_node = pp_node->next)
619 if (pp_node -> type == XML_ELEMENT_NODE)
621 s_node = pp_node -> properties;
622 if (s_node == NULL)
return 0;
623 spg -> settings[j].points[k] = g_malloc0(3*
sizeof*spg -> settings[j].points[k]);
626 the_point = s_node -> children;
627 if (the_point == NULL)
return 0;
628 content = xmlNodeGetContent(the_point);
629 if (g_strcmp0 (
"x",(
char *)s_node -> name) == 0)
631 spg -> settings[j].points[k][0] = g_strdup_printf (
"%s", content);
633 else if (g_strcmp0 (
"y",(
char *)s_node -> name) == 0)
635 spg -> settings[j].points[k][1] = g_strdup_printf (
"%s", content);
637 else if (g_strcmp0 (
"z",(
char *)s_node -> name) == 0)
639 spg -> settings[j].points[k][2] = g_strdup_printf (
"%s", content);
642 s_node = s_node -> next;
665 xmlTextReaderPtr reader;
666 xmlNodePtr racine, node, num_node;
667 xmlNodePtr cp_node, wp_node, wc_node;
668 xmlNodePtr the_wyck, the_pos;
669 xmlAttrPtr c_node, w_node, p_node;
673 reader = xmlReaderForFile(
filetoread, NULL, 0);
681 if (doc == NULL)
return 0;
682 racine = xmlDocGetRootElement(doc);
683 if (g_strcmp0 ((
char *)(racine -> name),
"sg-xml") != 0)
return clean_sgl_data (doc, reader);
684 spg = g_malloc0(
sizeof*spg);
685 node =
findnode (racine -> children,
"space-group");
687 content = xmlNodeGetContent(node);
688 spg -> name = g_strdup_printf (
"%s", content);
691 node =
findnode (racine -> children,
"sg-num");
693 content = xmlNodeGetContent(node);
697 node =
findnode (racine -> children,
"hm-symbol");
699 content = xmlNodeGetContent(node);
700 spg -> hms = g_strdup_printf (
"%s", content);
703 node =
findnode (racine -> children,
"bravais");
705 content = xmlNodeGetContent(node);
706 spg -> bravais = g_strdup_printf (
"%s", content);
712 node =
findnode(racine -> children,
"wyckoff");
714 c_node = node -> properties;
718 num_node = c_node -> children;
720 if (g_strcmp0 (
"num",(
char *)c_node -> name) == 0)
722 content = xmlNodeGetContent(num_node);
726 c_node = c_node -> next;
729 spg -> wyckoff = g_malloc0(spg -> numw*
sizeof*spg -> wyckoff);
731 node = node -> children;
733 for (cp_node = node; cp_node; cp_node = cp_node->next)
735 if (cp_node -> type == XML_ELEMENT_NODE)
737 w_node = cp_node -> properties;
741 the_wyck = w_node -> children;
743 content = xmlNodeGetContent(the_wyck);
744 if (g_strcmp0 (
"mul",(
char *)w_node -> name) == 0)
748 else if (g_strcmp0 (
"let",(
char *)w_node -> name) == 0)
750 spg -> wyckoff[i].let = g_strdup_printf (
"%s", content);
752 else if (g_strcmp0 (
"site",(
char *)w_node -> name) == 0)
754 spg -> wyckoff[i].site = g_strdup_printf (
"%s", content);
757 w_node = w_node -> next;
759 spg -> wyckoff[i].pos = g_malloc0(spg -> wyckoff[i].
multi*
sizeof*spg -> wyckoff[i].pos);
760 wp_node = cp_node -> children;
763 for (wc_node = wp_node; wc_node; wc_node = wc_node->next)
765 if (wc_node -> type == XML_ELEMENT_NODE)
767 p_node = wc_node -> properties;
769 spg -> wyckoff[i].pos[j] = g_malloc0(3*
sizeof*spg -> wyckoff[i].pos[j]);
772 the_pos = p_node -> children;
774 content = xmlNodeGetContent(the_pos);
775 if (g_strcmp0 (
"x",(
char *)p_node -> name) == 0)
777 spg -> wyckoff[i].pos[j][0] = g_strdup_printf (
"%s", content);
779 else if (g_strcmp0 (
"y",(
char *)p_node -> name) == 0)
781 spg -> wyckoff[i].pos[j][1] = g_strdup_printf (
"%s", content);
783 else if (g_strcmp0 (
"z",(
char *)p_node -> name) == 0)
785 spg -> wyckoff[i].pos[j][2] = g_strdup_printf (
"%s", content);
788 p_node = p_node -> next;
798 xmlFreeTextReader(reader);