From be7fa211269fb4f31acd497186c9d72fb8f8f973 Mon Sep 17 00:00:00 2001 From: Marc Cromme Date: Wed, 28 Feb 2007 14:46:41 +0000 Subject: [PATCH] closing bug #928 by dropping DOM document to xmlbuffer and re-reading into DOM each time a XSLT transform did occur. Yes, ugly, ugly, but no other possibility. Added output of XML after each transformation on YLOG_DEBUG level, run indexer with '-v debug' to see all transformations --- doc/.cvsignore | 3 +++ index/mod_dom.c | 30 +++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/doc/.cvsignore b/doc/.cvsignore index 6687c9d..9ec5f35 100644 --- a/doc/.cvsignore +++ b/doc/.cvsignore @@ -1,5 +1,8 @@ Makefile Makefile.in +domfilter.eps +domfilter.png +domfilter.pdf zebra.tex zebra.out zebra.log diff --git a/index/mod_dom.c b/index/mod_dom.c index 30a7799..3963033 100644 --- a/index/mod_dom.c +++ b/index/mod_dom.c @@ -1,4 +1,4 @@ -/* $Id: mod_dom.c,v 1.22 2007-02-28 13:16:24 marc Exp $ +/* $Id: mod_dom.c,v 1.23 2007-02-28 14:46:41 marc Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -338,12 +338,33 @@ static ZEBRA_RES perform_convert(struct filter_info *tinfo, { for (; convert; convert = convert->next) { + xmlChar *buf_out = 0; + int len_out = 0; xmlDocPtr res_doc = xsltApplyStylesheet(convert->stylesheet_xsp, *doc, params); if (last_xsp) *last_xsp = convert->stylesheet_xsp; + xmlFreeDoc(*doc); - *doc = res_doc; + /* *doc = res_doc; */ + + /* now saving into buffer and re-reading into DOM to avoid annoing + XSLT problem with thrown-out indentation text nodes */ + if (res_doc){ + xsltSaveResultToString(&buf_out, &len_out, res_doc, + convert->stylesheet_xsp); + xmlFreeDoc(res_doc); + } + + + *doc = xmlParseDoc(buf_out); + + yaz_log(YLOG_DEBUG, "%s: %s \n %s", + tinfo->fname ? tinfo->fname : "none ", + convert->stylesheet, + buf_out); + + xmlFree(buf_out); } return ZEBRA_OK; } @@ -1068,11 +1089,10 @@ static int convert_extract_doc(struct filter_info *tinfo, /* finally, do the indexing */ if (doc) - { extract_dom_doc_node(tinfo, p, doc); - /* extract_doc_alvis(tinfo, p, doc); */ + + if (doc) xmlFreeDoc(doc); - } return RECCTRL_EXTRACT_OK; } -- 1.7.10.4