xsl-list
[Top] [All Lists]

[C++/XSL/MSXML] XHTML from MSXML - problems

2003-09-11 07:44:21
Hi,

I have had a good scout around to try and find some information but have only 
found part of the answer.

My source:

MSXML2::IXMLDOMDocumentPtr source;
source.CreateInstance( "Msxml2.FreeThreadedDOMDocument");
source->async = VARIANT_FALSE;
source->loadXML( _bstr_t( "<page></page>"));

MSXML2::IXMLDOMDocumentPtr stylesheet;
stylesheet.CreateInstance( "Msxml2.FreeThreadedDOMDocument");
stylesheet->async = VARIANT_FALSE;
stylesheet->load( "C:\\XHTMLhome.xsl"); 

MSXML2::IXMLDOMDocumentPtr result;
result.CreateInstance( "Msxml2.FreeThreadedDOMDocument");
result->async = VARIANT_FALSE;
result->validateOnParse = VARIANT_FALSE;

MSXML2::IXSLTemplatePtr pXSLTemplate;
pXSLTemplate.CreateInstance( "Msxml2.XSLTemplate");
pXSLTemplate->stylesheet = stylesheet;
MSXML2::IXSLProcessorPtr pXSLProcessor = pXSLTemplate->createProcessor();

pXSLProcessor->input = result.GetInterfacePtr();      
pXSLProcessor->addParameter( "title", L"This is the title", L"");
pXSLProcessor->transform();

source->transformNodeToObject( stylesheet, result.GetInterfacePtr());

// BAD - no parameter
// GOOD - no encoding
MessageBoxW( NULL, result->xml, L"", MB_OK);

// GOOD - parameter
// BAD - encoding
MessageBoxW( NULL, pXSLProcessor->output.bstrVal, L"", MB_OK);

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

My XSL:


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output omit-xml-declaration="no" method="xml" encoding="iso-8859-1"/>
        <xsl:param name="title"/>
        <xsl:template match="/">
                <html xmlns="http://www.w3.org/1999/xhtml";>
                        <head>
                                <title><xsl:value-of select="$title"/></title>
                        </head>
                        <body>
                                This is XHTML...
                        </body>
                </html>
        </xsl:template>
</xsl:stylesheet>

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

I need to be able to add parameters using addParameter, but I know that if I 
use the 'output' property of the pXSLProcessor pointer, encoding is set to 
UTF-16 because it's a string.

So, I try transformNodeToObject, but I can't seem to get parameter values set!!!

// BAD - no parameter
// GOOD - no encoding
MessageBoxW( NULL, result->xml, L"", MB_OK);

// GOOD - parameter
// BAD - encoding
MessageBoxW( NULL, pXSLProcessor->output.bstrVal, L"", MB_OK);

I need to be able to add parameters AND use transformNodeToObject (because _I_ 
want to specify the encoding).

Any help would be much appreciated.

Thanks
Shane.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>