Click to See Complete Forum and Search --> : XSL problems in VB


afterfire
October 5th, 2000, 09:17 AM
Hello

I've got a question concerning XSL transformation of XML data
in Visual Basic 6

Here are a code-example, from XSLT Programmer's Reference to look at:

XML-file:

&lt?xml version="1.0"?&gt
&ltbook&gt
&lttitle&gtDesign Patterns&lt/title&gt
&ltauthor&gtErich Gamma&lt/author&gt
&ltauthor&gtRichard Helm&lt/author&gt
&ltauthor&gtRalph Johnson&lt/author&gt
&ltauthor&gtJohn Vlissides&lt/author&gt
&lt/book&gt

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

XSL-file:

&ltxsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"&gt
&ltxsl:template match="book"&gt
&ltxsl:value-of select="title"/&gt
by &ltxsl:for-each select="author"&gt
&ltxsl:value-of select="."/&gt
&ltxsl:if test="position()!=last()"&gt, &lt/xsl:if&gt
&ltxsl:if test="position()=last()-1"&gtand &lt/xsl:if&gt
&lt/xsl:for-each&gt
&lt/xsl:template&gt
&lt/xsl:transform&gt


Which according to the XSLT book shall result in the following output:

Design Patterns
by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides


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


In Visual Basic I try to XSL-transform the XML code using the following code:

Dim xml As New DOMDocument
Dim xsl As New DOMDocument
Dim transformed As New DOMDocument

xml.Load("c:\test.xml")
xsl.Load("c:\test.xsl")
xml.transformNodeToObject xsl, transformed



After executing this, the trans.xml contains only the xsl-code itself instead
of the correct transformed result.

The problem seems to have something to do with XSL-Namespaces

If I use the namespace xmlns:xsl="http://www.w3.org/TR/WD-xsl" in more
simple xml-xsl examples, it transforms just fine, but then I can't
get the &ltxsl:if&gt and more complex xsl-structures to work.

I thought that similar structures should work with the namespace
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" but as I tried to
explain, all I get back from the transformation is the XSL-code.

Does anyone have a clue?? I would really appreciate some help.
Thanks in advance.

Sherry Li
January 4th, 2001, 01:50 AM
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"> not support by MSXML2.5. You need upgrade to MSXML3.0 in replace mode.