Example #1
0
void queryMacroList::saveList(xmlTextWriterPtr writer)
{
	size_t i;

	for (i = 0; i < macros.GetCount(); i++)
	{
		xmlTextWriterStartElement(writer, XML_STR("macro"));
		xmlTextWriterWriteAttribute(writer, XML_STR("key"),
		                            XML_FROM_WXSTRING(macros.Item(i)->GetKey()));
		xmlTextWriterWriteAttribute(writer, XML_STR("name"),
		                            XML_FROM_WXSTRING(macros.Item(i)->GetName()));
		xmlTextWriterWriteString(writer,
		                         XML_FROM_WXSTRING(macros.Item(i)->GetQuery()));
		xmlTextWriterEndElement(writer);
	}
}
Example #2
0
void queryFavouriteFolder::saveFolder(xmlTextWriterPtr writer)
{
	size_t i;

	for (i = 0; i < favourites.GetCount(); i++)
	{
		if (favourites.Item(i)->GetId() == -2)
		{
			queryFavouriteFolder *subfolder = (queryFavouriteFolder *)favourites.Item(i);

			xmlTextWriterStartElement(writer, XML_STR("folder"));
			xmlTextWriterWriteAttribute(writer, XML_STR("title"), XML_FROM_WXSTRING(subfolder->title));
			subfolder->saveFolder(writer);
			xmlTextWriterEndElement(writer);
		}
		else
		{
			xmlTextWriterStartElement(writer, XML_STR("favourite"));
			xmlTextWriterWriteAttribute(writer, XML_STR("title"), XML_FROM_WXSTRING(favourites.Item(i)->GetTitle()));
			xmlTextWriterWriteString(writer, XML_FROM_WXSTRING(favourites.Item(i)->GetContents()));
			xmlTextWriterEndElement(writer);
		}
	}
}
Example #3
0
wxString frmReport::XslProcessReport(const wxString &xml, const wxString &xsl)
{
	xmlChar *output = 0;
	xmlDocPtr ssDoc = 0, xmlDoc = 0, resDoc = 0;
	xsltStylesheetPtr ssPtr = 0;
	int length;

	wxBeginBusyCursor();

	// Apply the stylesheet
	xmlSubstituteEntitiesDefault (1); // Substitute entities
	xmlLoadExtDtdDefaultValue = 1; // Load external entities

	// Parse the stylesheet
	ssDoc = xmlParseDoc(XML_FROM_WXSTRING(xsl));
	if (!ssDoc)
	{
		wxEndBusyCursor();
		wxLogError(_("Failed to parse the XML stylesheet!"));
		goto cleanup;
	}

	ssPtr = xsltParseStylesheetDoc(ssDoc);
	if (!ssPtr)
	{
		wxEndBusyCursor();
		wxLogError(_("Failed to parse the XSL stylesheet!"));
		goto cleanup;
	}

	// Parse the data
	xmlDoc = xmlParseDoc(XML_FROM_WXSTRING(xml));
	if (!xmlDoc)
	{
		wxEndBusyCursor();
		wxLogError(_("Failed to parse the XML document!"));
		goto cleanup;
	}

	// Apply the stylesheet
	resDoc = xsltApplyStylesheet(ssPtr, xmlDoc, NULL);
	if (!resDoc)
	{
		wxEndBusyCursor();
		wxLogError(_("Failed to apply the XSL stylesheet to the XML document!"));
		goto cleanup;
	}

	// Get the result
	xsltSaveResultToString (&output, &length, resDoc, ssPtr);
	if (!resDoc)
	{
		wxEndBusyCursor();
		wxLogError(_("Failed to read the processed document!"));
		goto cleanup;
	}

cleanup:

	// Cleanup
	if (resDoc)
		xmlFreeDoc(resDoc);

	if (xmlDoc)
		xmlFreeDoc(xmlDoc);

	if (ssPtr)
		xsltFreeStylesheet(ssPtr);

	// This crashes - dunno why :-(
	// if (ssDoc)
	//  xmlFreeDoc(ssDoc);

	xsltCleanupGlobals();

	wxEndBusyCursor();

	if (output)
		return WXSTRING_FROM_XML(output);
	else
		return wxEmptyString;
}