Click here to Skip to main content
15,886,873 members
Articles / Desktop Programming / WTL

XSLT Extension Functions

Rate me:
Please Sign up or sign in to vote.
3.40/5 (5 votes)
30 Jan 20045 min read 49.7K   948   10  
Extending the functionality of the XSLT Processor.
// BibTitles.h : Declaration of the CBibTitles

#pragma once
#include "resource.h"       // main symbols

#include "TitlesExtFunc.h"

// CBibTitles

class ATL_NO_VTABLE CBibTitles : 
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CBibTitles, &CLSID_BibTitles>,
	public IDispatchImpl<IBibTitles, &IID_IBibTitles, &LIBID_TitlesExtFunc, /*wMajor =*/ 1, /*wMinor =*/ 0>
{
public:
	CBibTitles()
	{
	}

DECLARE_REGISTRY_RESOURCEID(IDR_BIBTITLES)


BEGIN_COM_MAP(CBibTitles)
	COM_INTERFACE_ENTRY(IBibTitles)
	COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()


	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		HRESULT hr;

		if(FAILED(hr = dbConn.OpenFromInitializationString(_T("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\bib2.mdb"))))
		{
			return AtlReportError(GetObjectCLSID(), _T("Failure opening database connection"), 
				GUID_NULL, hr);
			
		}

		if(FAILED(hr = session.Open(dbConn)))
		{
			return AtlReportError(GetObjectCLSID(), _T("Failure opening database session"),
					GUID_NULL, hr);
			
		}

		return S_OK;
	}
	
	void FinalRelease() 
	{
		session.Close();
		dbConn.Close();
	}

public:

	STDMETHOD(GetBookTitle)(BSTR isbn, BSTR* bookTitle);
	STDMETHOD(GetYearPublished)(BSTR isbn, LONG* yearPublished);

private:

	CDataSource dbConn;
	CSession	session;

public:
	STDMETHOD(GetIsbnByYear)(LONG year, BSTR* result);
	STDMETHOD(get_ProcessTime)(BSTR* pVal);
};

OBJECT_ENTRY_AUTO(__uuidof(BibTitles), CBibTitles)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions