Re: [xml] Problem in xsltSaveResultToFile


Can you be more explicit please ? Does it compile well ? When does it crash ?

 Have you tried something like that :

void myClass::dump( ostream &out )  {
        /* libxml2's api doesn't provide any function to dump the xml tree to an
         * ostream, so we first have to dump it into memory then dump this one
         * to the desired output stream.
        int * size;
        xmlChar **mem;

        // add encoding to the output
        xmlDocDumpFormatMemory (doc, mem, size, 1);
        out.write((const char*) *mem, *size);
        // free ( **mem ) ;

// of course, doc is my xmlDocPtr.

You just have to give the desired output stream as an parameter. Works well for me with GNU C++ compiler ( g++ ).

If you just want to dump directly and always to stdout, it's even simplier, look at the xmlDocDumpxxx functions.

Whao.... M$ systems and Britney spears...Please my god show him the right way...

Arvind wrote:
Hi All
I am getting the problem in the statement int iWri = xsltSaveResultToFile(stdout, res, cur); It is getting crashed. I am compiling and running the program in VC++ 6.0 I tried a lot to solve the problem but i m not getting why it is crashing...???
the xslt and xml file which i m using is attached in this mail...
Pls help me.... #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/debugXML.h>
#include <libxml/HTMLtree.h>
#include <libxml/xmlIO.h>
#include <libxml/DOCBparser.h>
#include <libxml/xinclude.h>
#include <libxml/catalog.h>
#include <libxslt/xslt.h>
#include <libxslt/xsltInternals.h>
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
extern int xmlLoadExtDtdDefaultValue; int main() { const char *params[16 + 1];
 int nbparams = 0;
 xsltStylesheetPtr cur = NULL;
 xmlDocPtr doc, res;
params[nbparams++] = "rootid";
 params[nbparams++] = "'asect1'";
 params[nbparams] = NULL;
 xmlLoadExtDtdDefaultValue = 1;
cur = xsltParseStylesheetFile((const xmlChar *)"C:\\Arvind\\XSLT\\Data File\\Test.xsl");
 doc = xmlParseFile("C:\\Arvind\\XSLT\\Data File\\Test.xml");
 res = xsltApplyStylesheet(cur, doc, params);
 int iWri = xsltSaveResultToFile(stdout, res, cur);
} Thanks


<?xml version="1.0" encoding="UTF-8"?>
<artist name="Britney Spears"/>


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl=""; version="1.0">
        <xsl:output method="html" indent="yes" version="4.0"/>
        <xsl:template match="/">
                                <title>Test Page</title>
                 <h2>Artist Detail</h2>
                 Artist: <xsl:value-of select="artist/@name"/>


xml mailing list, project page
xml gnome org

Remy HAREL          -        Teamlog        |
Linux registered user #224740               |
France Telecom Recherche & Developpement    |
__________________@ @|

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]