+const char *data1_get_encoding (data1_handle dh, data1_node *n)
+{
+ /* see if we have an xml header that specifies encoding */
+ if (n && n->child && n->child->which == DATA1N_preprocess &&
+ strcmp (n->child->u.preprocess.target, "xml") == 0)
+ {
+ data1_xattr *xp = n->child->u.preprocess.attributes;
+ for (; xp; xp = xp->next)
+ if (!strcmp (xp->name, "encoding") == 0)
+ return xp->value;
+ }
+ /* no encoding in header, so see if "encoding" was specified for abs */
+ if (n && n->which == DATA1N_root &&
+ n->u.root.absyn && n->u.root.absyn->encoding)
+ return n->u.root.absyn->encoding;
+ /* none of above, return a hard coded default */
+ return "ISO-8859-1";
+}
+