XML transform via XLS

R

Richard Koch

Hi folks!

I want to transform a XML document using a XLS stylesheet
(transformNodeToObject()). I did my code as the MSDN examples suggest, the
transformation succeeds S_OK. Unfortunately, the XML result doc is not
valid, e.g. get_xml() fails, the string is empty.
Does that sound familiar to anyone? If yes, thanks for your help!

Richard
 
D

Dimitre Novatchev

Richard Koch said:
Hi folks!

I want to transform a XML document using a XLS stylesheet
(transformNodeToObject()). I did my code as the MSDN examples suggest, the
transformation succeeds S_OK. Unfortunately, the XML result doc is not
valid, e.g. get_xml() fails, the string is empty.
Does that sound familiar to anyone? If yes, thanks for your help!

You may pass any stream object to contain the result -- e.g. the Response
object (in ASP) or ADODB.Stream


Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
 
R

Richard Koch

Sorry, but I do not know what you mean...

Dimitre Novatchev said:
Richard Koch said:
Hi folks!

I want to transform a XML document using a XLS stylesheet
(transformNodeToObject()). I did my code as the MSDN examples suggest, the
transformation succeeds S_OK. Unfortunately, the XML result doc is not
valid, e.g. get_xml() fails, the string is empty.
Does that sound familiar to anyone? If yes, thanks for your help!

You may pass any stream object to contain the result -- e.g. the Response
object (in ASP) or ADODB.Stream


Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
 
D

Dimitre Novatchev

Richard Koch said:
Sorry, but I do not know what you mean...

Read your MSXML4 SDK Documentation. Here's how the second argument to the
method is described:

"outputObject
An object. On return, contains the product of the transformation of this XML
document based on the XSLT style sheet. If the variant represents the
DOMDocument object, the document is built according to its properties and
its child nodes are replaced during this transformation process. The XML
transformation can also be sent to a stream. "

mk:mad:MSITStore:C:\Program%20Files\MSXML%204.0\doc\xmlsdk.chm::/htm/xml_mth_sz
_2jp0.htm


Note the last sentence. This is what you need. If the result tree does not
represent a well-formed xml document (e.g. has more than one top element),
the outputObject cannot be a XMLDOMDocument object. But it still can be any
stream object (one that supports the IStream interface) and the stream
object will process (e.g. write to a file) it.

This is a FAQ -- see for example:

http://sources.redhat.com/ml/xsl-list/2002-07/msg01310.html


Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
 
J

Julian Reschke

Richard said:
Hi folks!

I want to transform a XML document using a XLS stylesheet
(transformNodeToObject()). I did my code as the MSDN examples suggest, the
transformation succeeds S_OK. Unfortunately, the XML result doc is not
valid, e.g. get_xml() fails, the string is empty.
Does that sound familiar to anyone? If yes, thanks for your help!

The output of an XSLT is not necesarily wellformed XML, for instance
when you're using the "text" or "html" output method. Note that XSLT
defaults to the "html" output method when the document element produced
is "html" (either lowercase or uppercase).

So if you need XML, specify "xsl:eek:utput method='xml'".

Julian
 
P

Patrick TJ McPhee

% So if you need XML, specify "xsl:eek:utput method='xml'".

Keeping in mind that this doesn't guarantee that your XSL will
generate well-formed XML. For that, you need to define the transformation
correctly.
 
D

Dimitre Novatchev

Patrick TJ McPhee said:
% So if you need XML, specify "xsl:eek:utput method='xml'".

Keeping in mind that this doesn't guarantee that your XSL will
generate well-formed XML. For that, you need to define the transformation
correctly.

Yes, the example I gave -- more than one top element, or no top element at
all (just one text node -- such results can be produced using "xsl:eek:utput
method='xml'".


Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top