[xslt] Simple sample?


I have a silly, but important question. I have coded myself a simplest of samples yet it triggers an illlegal operation (or some other error). I'm using winXP SP2 w/ 1GB RAM etc... and MS VC++ 6.0 and here was my source code. While it compiles just fine, it crashes when I run it.

#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];
 size_t nbparams = 0;
 params[nbparams] = NULL;
 xmlLoadExtDtdDefaultValue = 1;
 xsltStylesheetPtr cur = xsltParseStylesheetFile((const xmlChar*) "employees.xsl");
   xmlDocPtr doc = xmlParseFile("employees.xml");
 xmlDocPtr res = xsltApplyStylesheet(cur, doc, params);
 //  FILE* p = fopen("out.html", "w");
 xsltSaveResultToFile(stdout, res, cur); // <<<<<I think it crashes here!?
 //  fclose(p);
   return 0;

I don't think my employee.xsl/xml source files are to blame, here they are too:

<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
   <xsl:output method="html" indent="yes" />
   <!-- Match the root node -->
   <xsl:template match="/">
         <body bgcolor="c0c0c0" text="000000">
            <table cellspacing="0" cellpadding="0" border="1" width="100%">
               <tr bgcolor="ffffff">
                  <th width="20%">Department</th>
                  <th width="10%">ID</th>
                  <th width="20%">Title</th>
                  <th width="50%">Name</th>
               <xsl:apply-templates select="employees/employee">
                  <xsl:sort select="department" order="ascending"/>
   <!-- Match each employee -->
   <xsl:template match="employees/employee">
            <xsl:when test="position() mod 2 = 1">
               <xsl:attribute name="bgcolor">c0c0c0</xsl:attribute>
               <xsl:attribute name="bgcolor">cccccc</xsl:attribute>
            <xsl:value-of select="department" />
            <xsl:value-of select="department/@id" />
            <xsl:value-of select="title" />
         <td><xsl:value-of select="family-name" />, <xsl:value-of select="first-name" /></td>


<?xml version="1.0" encoding="utf-8" ?>
      <department id="ADM">Administration</department>

I'm hoping I've just made a silly mistake and someone here can point it out to me.

Thanks in advance,


Send instant messages to your online friends http://au.messenger.yahoo.com

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