X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;ds=inline;f=src%2Fnormalize_record.c;h=322566eb4e5f2c56efab062597f19b1f5e275322;hb=cdf7e43aa085ccd9ee8d8c9129bc1cdb0cc0c547;hp=c33cd2eb3847cb3127ed42a14800971aa957577e;hpb=54b131a596a6e9a516d30321888fe48c3ac6d146;p=pazpar2-moved-to-github.git diff --git a/src/normalize_record.c b/src/normalize_record.c index c33cd2e..322566e 100644 --- a/src/normalize_record.c +++ b/src/normalize_record.c @@ -124,30 +124,32 @@ int normalize_record_transform(normalize_record_t nt, xmlDoc **doc, const char **parms) { struct normalize_step *m; - for (m = nt->steps; m; m = m->next) - { - xmlNodePtr root = 0; - xmlDoc *new; - if (m->stylesheet) - { - new = xsltApplyStylesheet(m->stylesheet, *doc, parms); - } - else if (m->marcmap) - { - new = marcmap_apply(m->marcmap, *doc); - } - - root = xmlDocGetRootElement(new); - - if (!new || !root || !root->children) - { - if (new) - xmlFreeDoc(new); - xmlFreeDoc(*doc); - return -1; - } - xmlFreeDoc(*doc); - *doc = new; + if (nt) { + for (m = nt->steps; m; m = m->next) + { + xmlNodePtr root = 0; + xmlDoc *new; + if (m->stylesheet) + { + new = xsltApplyStylesheet(m->stylesheet, *doc, parms); + } + else if (m->marcmap) + { + new = marcmap_apply(m->marcmap, *doc); + } + + root = xmlDocGetRootElement(new); + + if (!new || !root || !root->children) + { + if (new) + xmlFreeDoc(new); + xmlFreeDoc(*doc); + return -1; + } + xmlFreeDoc(*doc); + *doc = new; + } } return 0; }