#if defined(_WIN32)
# define WIN32_LEAN_AND_MEAN 1
# include <windows.h>
# define DLLHANDLE HMODULE
# define LOADERLIB "p6loader.dll"
# define LOADLIB(fn) LoadLibraryA((fn))
# define LOADSYMBOL(h,s) GetProcAddress((HMODULE)(h),(s))
# define FREELIB(h) FreeLibrary((HMODULE)(h))
#else
# include <errno.h>
# include <dlfcn.h>
# define DLLHANDLE void*
# define LOADERLIB "libp6loader.so"
# define LOADLIB(fn) dlopen((fn),RTLD_NOW)
# define LOADSYMBOL(h,s) dlsym((h),(s))
# define FREELIB(h) !dlclose((h))
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory>
#include "filestream.h"
#include "cxpathextend.h"
#include "p6xjr.h"
using namespace P6R;
{
public:
{
if (!ppIface) return eAccessFault;
*ppIface = NULL;
if(iid == IID_p6ICom) *ppIface =
static_cast<p6IDataStream*
>(
this);
else if(iid == IID_p6IDataStream) *ppIface =
static_cast<p6IDataStream*
>(
this);
else return eNoInterface;
return eOk;
}
{
return m_cRef++;
}
{
if(0 == (tmp = (--m_cRef))) { delete this; }
return tmp;
}
{
return eOk;
}
{
if (m_cBuffer && cData+1 > m_cBuffer)
{
free( m_pBuffer );
m_pBuffer = NULL;
m_cBuffer = 0;
}
if (!m_pBuffer)
{
m_pBuffer = (
P6CHAR*) malloc(cData+1);
m_cBuffer = cData;
}
if (m_pBuffer)
{
memcpy( m_pBuffer, pData, cData+1 );
m_pBuffer[cData] = '\0';
printf( m_pBuffer );
}
return eOk;
}
{
CConsoleStream *pObj = NULL;
if (NULL != (pObj = new (std::nothrow) CConsoleStream() ))
{
if (
P6FAILED(err = pObj->queryInterface( iid, ppIface )))
delete pObj;
}
return err;
}
CConsoleStream() : m_cRef(0), m_pBuffer(NULL), m_cBuffer(0) {;}
virtual ~CConsoleStream() { if (m_pBuffer) free(m_pBuffer); }
protected:
};
{
CFileStream *pObj = NULL;
CXpathExtend *pConnector = NULL;
"<?xml version='1.0' encoding='ISO-8859-1'?>\n" \
"<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'" \
" xmlns:P6RTEST='http://www.p6r.com/namespaces/test' >\n" \
"<xsl:output method='xml'/>\n" \
"<xsl:include href='embeddedxml.xsl'/>\n" \
" \n" \
" <!-- embedded XML in the stylesheet are parsed into root-less XML fragments -->" \
"<xsl:variable name='months' as='element()*'>\n" \
" <month>January</month>" \
" <month>February</month>" \
" <month>March</month>" \
"</xsl:variable>\n" \
"<xsl:variable name='gv3' select='/list/item'/>\n" \
" \n" \
"<xsl:function name='asXML' as='element()*'>\n" \
" <month id='aéb'c'>June</month>\n" \
" <month>July - < é - <![CDATA[é]]></month>\n" \
" <month>August</month>\n" \
" <month>September</month>\n" \
"</xsl:function>\n" \
" \n" \
"<xsl:template name='listlist'>\n" \
" <xsl:param name='p1' />\n" \
" <xsl:param name='p2' as='element()'>\n" \
" <month>Decemeber</month>\n" \
" </xsl:param>\n" \
" <xsl:copy-of select='$p1'/>\n" \
" <xsl:copy-of select='$p2'/>\n" \
"</xsl:template>\n" \
" \n" \
"<xsl:template name='spring' as='element()*'>\n" \
" <month>April</month>\n" \
" <month>May</month>\n" \
"</xsl:template>\n" \
" \n" \
"<xsl:template match='/'>\n" \
"<calendar>\n" \
"<xsl:copy-of select='$externdays'/>\n" \
"<xsl:copy-of select='$months'/>\n" \
"<xsl:call-template name='spring' />\n" \
"<xsl:copy-of select='asXML()'/>\n" \
"<xsl:call-template name='listlist'>\n" \
" <xsl:with-param name='p1' as='element()*'>\n" \
" <month>October</month>\n" \
" <month>November</month>\n" \
" </xsl:with-param>\n" \
"</xsl:call-template>\n" \
"<xsl:if test=\"P6RTEST:setclick88( 'www.abc.com', $gv3 )\"> \n" \
" <xsl:comment>extended XSLT processor func works</xsl:comment>\n" \
"</xsl:if>\n" \
"<xsl:if test='$externalVar1 = 55'>\n" \
" <xsl:comment>extended <XSLT<![CDATA[é]]> processor évariable works</xsl:comment>\n" \
"</xsl:if>\n" \
"</calendar>\n" \
"</xsl:template>\n" \
"</xsl:stylesheet>\n";
"<?xml version='1.0' encoding='UTF-8' ?>\n" \
"<list>" \
" <index><title number='1'>Items 1 to 6</title></index>" \
" <item id='123' ref='789'>Item 1</item>" \
" <item id='456' ref='000'>Item 2</item>" \
" <item id='789' ref='010'>Item 3</item>" \
" <item id='111' ref='100'>Item 4</item>" \
" <item id='222' ref='001'>Item 5</item>" \
" <item id='333' ref='111'>Item 6</item>" \
" <index><title number='2'>List of boxes</title>" \
" </index>" \
" <names>" \
" <!-- test distinct and document order -->" \
" <name>123</name><name>456</name><name>333</name>" \
" <name>222</name><name>111</name><name>789</name>" \
" <name>123</name><name>789</name><name>222</name>" \
" </names>"
"</list>";
{
printf( "Error: p6IXSLT Initialize failed\n" );
return err;
}
if (NULL != (pObj = new (std::nothrow) CFileStream() ))
{
pObj->initialize( "example-xslt3.xml" );
if (
P6FAILED( err = pObj->queryInterface( IID_p6IDataStream, (
P6VOID**)&pOutStream1 )))
{
delete pObj;
return err;
}
}
if (NULL != (pConnector = new (std::nothrow) CXpathExtend()))
{
err = pConnector->initialize( cpStr );
}
err = cpXSLT->initialize( P6XSLT_NOFLAGS, pOutStream1 );
if (
P6SUCCEEDED( err )) err = cpXSLT->setExternalFunctions( pXconnect );
if (
P6SUCCEEDED( err )) err = cpXSLT->compileTemplates( pTemplate, pOutStream1 );
bufSize = (
P6UINT32) strlen( pXMLData );
if (
P6SUCCEEDED( err )) err = cpXSLT->startTransform( pOutStream1, pXMLData, bufSize,
P6TRUE );
return err;
}
int main(int argc,char *argv[])
{
{
{
err = runXSLT( cpDataStream );
printf( "runXSLT result: [ %x ]\n", err );
}
else printf("ERROR: Failed to initialize the loader [ %x ]\n", err );
}
else printf( "ERROR: Failed to create CConsoleStream [ %x ]\n", err );
return err;
}