Re: [xml] Problem in xsltSaveResultToFile



Hi,

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.


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


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;
 xmlSubstituteEntitiesDefault(1);
 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);
xsltFreeStylesheet(cur);
 xmlFreeDoc(res);
 xmlFreeDoc(doc);
xsltCleanupGlobals();
    xmlCleanupParser();
 return(0);
} Thanks
Arvind

------------------------------------------------------------------------

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


------------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
        <xsl:output method="html" indent="yes" version="4.0"/>
        <xsl:template match="/">
        <html>
                        <head>
                                <title>Test Page</title>
            </head>
            <body>
                 <h2>Artist Detail</h2>
                 Artist: <xsl:value-of select="artist/@name"/>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>


------------------------------------------------------------------------

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml

--
_____________________________________________
Remy HAREL          -        Teamlog        |
____________________________________________|
Linux registered user #224740               |
France Telecom Recherche & Developpement    |
____________________________________________|
__________________@ http://www.chezrem.org @|




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