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;
537 node =
findnode (racine -> children,
"settings");
538 if (node == NULL)
return 0;
539 s_node = node -> properties;
540 if (s_node == NULL)
return 0;
543 num_node = s_node -> children;
544 if (num_node == NULL)
return 0;
545 if (g_strcmp0 (
"num",(
char *)s_node -> name) == 0)
549 s_node = s_node -> next;
554 node = node -> children;
555 if (node == NULL)
return 0;
557 for (sp_node = node; sp_node; sp_node = sp_node -> next)
559 if (sp_node -> type == XML_ELEMENT_NODE)
561 s_node = sp_node -> properties;
562 if (s_node == NULL)
return 0;
565 the_setting = s_node -> children;
566 if (the_setting == NULL)
return 0;
567 if (g_strcmp0 (
"name",(
char *)s_node -> name) == 0)
569 spg ->
settings[j].
name = g_strdup_printf (
"%s", (
char *)xmlNodeGetContent(the_setting));
571 else if (g_strcmp0 (
"origin",(
char *)s_node -> name) == 0)
575 else if (g_strcmp0 (
"x",(
char *)s_node -> name) == 0)
577 spg ->
settings[j].pos[0] = g_strdup_printf (
"%s", (
char *)xmlNodeGetContent(the_setting));
579 else if (g_strcmp0 (
"y",(
char *)s_node -> name) == 0)
581 spg ->
settings[j].pos[1] = g_strdup_printf (
"%s", (
char *)xmlNodeGetContent(the_setting));
583 else if (g_strcmp0 (
"z",(
char *)s_node -> name) == 0)
585 spg ->
settings[j].pos[2] = g_strdup_printf (
"%s", (
char *)xmlNodeGetContent(the_setting));
587 s_node = s_node -> next;
589 ps_node =
findnode (sp_node -> children,
"points");
592 p_node = ps_node -> properties;
593 if (p_node == NULL)
return 0;
596 num_node = p_node -> children;
597 if (num_node == NULL)
return 0;
598 if (g_strcmp0 (
"num",(
char *)p_node -> name) == 0)
602 p_node = p_node -> next;
607 ps_node = ps_node -> children;
608 if (ps_node == NULL)
return 0;
610 for (pp_node = ps_node; pp_node; pp_node = pp_node->next)
612 if (pp_node -> type == XML_ELEMENT_NODE)
614 s_node = pp_node -> properties;
615 if (s_node == NULL)
return 0;
616 spg ->
settings[j].points[k] = g_malloc(3*
sizeof*spg ->
settings[j].points[k]);
619 the_point = s_node -> children;
620 if (the_point == NULL)
return 0;
621 if (g_strcmp0 (
"x",(
char *)s_node -> name) == 0)
623 spg ->
settings[j].points[k][0] = g_strdup_printf (
"%s", (
char *)xmlNodeGetContent(the_point));
625 else if (g_strcmp0 (
"y",(
char *)s_node -> name) == 0)
627 spg ->
settings[j].points[k][1] = g_strdup_printf (
"%s", (
char *)xmlNodeGetContent(the_point));
629 else if (g_strcmp0 (
"z",(
char *)s_node -> name) == 0)
631 spg ->
settings[j].points[k][2] = g_strdup_printf (
"%s", (
char *)xmlNodeGetContent(the_point));
633 s_node = s_node -> next;
655 const xmlChar sgl[8]=
"sg-xml";
657 xmlTextReaderPtr reader;
658 xmlNodePtr racine, node, num_node;
659 xmlNodePtr cp_node, wp_node, wc_node;
660 xmlNodePtr the_wyck, the_pos;
661 xmlAttrPtr c_node, w_node, p_node;
664 reader = xmlReaderForFile(
filetoread, NULL, 0);
672 if (doc == NULL)
return 0;
673 racine = xmlDocGetRootElement(doc);
674 if (g_strcmp0 ((
char *)(racine -> name), (
char *)sgl) != 0)
return clean_sgl_data (doc, reader);
675 spg = g_malloc0(
sizeof*spg);
676 node =
findnode (racine -> children,
"space-group");
678 spg -> name = g_strdup_printf (
"%s", (gchar *)xmlNodeGetContent(node));
680 node =
findnode (racine -> children,
"sg-num");
684 node =
findnode (racine -> children,
"hm-symbol");
686 spg -> hms = g_strdup_printf (
"%s", (gchar *)xmlNodeGetContent(node));
688 node =
findnode (racine -> children,
"bravais");
690 spg -> bravais = g_strdup_printf (
"%s", (gchar *)xmlNodeGetContent(node));
695 node =
findnode(racine -> children,
"wyckoff");
697 c_node = node -> properties;
701 num_node = c_node -> children;
703 if (g_strcmp0 (
"num",(
char *)c_node -> name) == 0)
705 spg -> numw = (int)
string_to_double ((gpointer)xmlNodeGetContent(num_node));
707 c_node = c_node -> next;
710 spg -> wyckoff = g_malloc0(spg -> numw*
sizeof*spg -> wyckoff);
712 node = node -> children;
714 for (cp_node = node; cp_node; cp_node = cp_node->next)
716 if (cp_node -> type == XML_ELEMENT_NODE)
718 w_node = cp_node -> properties;
722 the_wyck = w_node -> children;
724 if (g_strcmp0 (
"mul",(
char *)w_node -> name) == 0)
726 spg -> wyckoff[i].multi = (int)
string_to_double ((gpointer)xmlNodeGetContent(the_wyck));
728 else if (g_strcmp0 (
"let",(
char *)w_node -> name) == 0)
730 spg -> wyckoff[i].let = g_strdup_printf (
"%s", (gchar *)xmlNodeGetContent(the_wyck));
732 else if (g_strcmp0 (
"site",(
char *)w_node -> name) == 0)
734 spg -> wyckoff[i].site = g_strdup_printf (
"%s", (gchar *)xmlNodeGetContent(the_wyck));
736 w_node = w_node -> next;
738 spg -> wyckoff[i].pos = g_malloc(spg -> wyckoff[i].
multi*
sizeof*spg -> wyckoff[i].pos);
739 wp_node = cp_node -> children;
742 for (wc_node = wp_node; wc_node; wc_node = wc_node->next)
744 if (wc_node -> type == XML_ELEMENT_NODE)
746 p_node = wc_node -> properties;
748 spg -> wyckoff[i].pos[j] = g_malloc(3*
sizeof*spg -> wyckoff[i].pos[j]);
751 the_pos = p_node -> children;
753 if (g_strcmp0 (
"x",(
char *)p_node -> name) == 0)
755 spg -> wyckoff[i].pos[j][0] = g_strdup_printf (
"%s", (gchar *)xmlNodeGetContent(the_pos));
757 else if (g_strcmp0 (
"y",(
char *)p_node -> name) == 0)
759 spg -> wyckoff[i].pos[j][1] = g_strdup_printf (
"%s", (gchar *)xmlNodeGetContent(the_pos));
761 else if (g_strcmp0 (
"z",(
char *)p_node -> name) == 0)
763 spg -> wyckoff[i].pos[j][2] = g_strdup_printf (
"%s", (gchar *)xmlNodeGetContent(the_pos));
765 p_node = p_node -> next;
775 xmlFreeTextReader(reader);