[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] [C++/XSL/MSXML] XHTML from MSXML - problems


Subject: RE: [xsl] [C++/XSL/MSXML] XHTML from MSXML - problems
From: "Shane Porter" <Shane.Porter@xxxxxxxxxxxxxxx>
Date: Thu, 11 Sep 2003 16:54:39 +0100

I've managed to get somewhere by using the pXSLProcessor stuff for the parameters, and using the following in the XSL:

<xsl:output
		indent="yes"
		method="xml"
		omit-xml-declaration="yes"
		media-type="application/xml+xhtml"
		doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>

...but if I want the XML declaration at the top, I still get UTF-16.  Any thoughts?

-----Original Message-----
From: Shane Porter 
Sent: 11 September 2003 15:44
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] [C++/XSL/MSXML] XHTML from MSXML - problems


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


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



Current Thread
Keywords