[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: [C++/XSL/MSXML] XHTML from MSXML - problems
From: "Shane Porter" <Shane.Porter@xxxxxxxxxxxxxxx>
Date: Thu, 11 Sep 2003 15:44:21 +0100
ixslprocessorptr
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.