[xml] Multiple use of stylesheet fails
- From: "Kaarle Kaila" <kaarle kaila iki fi>
- To: <xml gnome org>
- Subject: [xml] Multiple use of stylesheet fails
- Date: Fri, 13 Feb 2004 23:33:00 +0200
I create an XML tree using libxml to create my report and when it is ready
I transform it into an html-file using xslt stylesheets.
I have one special case where I need to create several html-files from the
same
doc using the same stylesheet. On for each table. I give the tablenumber
in the parameter to xmlApplyStylesheet.
My code below works only once. If I move the xsltParseStylesheet inside the
for loop it creates all the tables but like this only one table. For all
other
tables xsltApplyStylesheetUser return NULL and nothing is created.
What might be wrong here? I assume I am allowed to use the stylesheet more
than once?
My environment is MSVC 6++ with MFC.
regards
Kaarle
--
Kaarle Kaila
email: kaarle dot kaila at iki dot fi
www.iki.fi/kaila
================================My code sniplet===============
CString tmp;
XmlString util; // my converter from CString to xmlChar*
xmlDocPtr doc;
xsltStylesheetPtr cur = NULL;
xmlDocPtr res;
tmp.Format(_T("%s\\%s"),modPath,_T("tablemain.xsl"));
util.Set(tmp);
cur = xsltParseStylesheetFile(util.GetChar());
ctxt = xsltNewTransformContext(cur, doc);
if (ctxt == NULL) {
ASSERT(FALSE);
return;
}
const char *pars[7];
__int64 table;
pars[0] = "typ";
pars[1] = "'many'";
pars[2] = "tabno";
pars[4]=NULL;
for (table = startTable;table <= endTable;table++) {
tmp.Format(_T("%d"),table);
util.Set(tmp); // takes
a CString (MFC)
pars[3] = (const char *)util.GetChar(); // returns a xmlChar*
res = xsltApplyStylesheetUser(cur,doc,pars,NULL,NULL,ctxt);
aux.Format(_T("%s%s_files\\data%d.html"),dirre,filename,table);
util.Set(aux);
xsltSaveResultToFilename((const char*)util.GetChar(),res,cur,0);
xmlFreeDoc(res);
}
xsltFreeStylesheet(cur);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]