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:
<?xml version="1.0"?>
<book>
<title>Design Patterns</title>
<author>Erich Gamma</author>
<author>Richard Helm</author>
<author>Ralph Johnson</author>
<author>John Vlissides</author>
</book>
----------------------------------
XSL-file:
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="book">
<xsl:value-of select="title"/>
by <xsl:for-each select="author">
<xsl:value-of select="."/>
<xsl:if test="position()!=last()">, </xsl:if>
<xsl:if test="position()=last()-1">and </xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:transform>
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 <xsl:if> 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.
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:
<?xml version="1.0"?>
<book>
<title>Design Patterns</title>
<author>Erich Gamma</author>
<author>Richard Helm</author>
<author>Ralph Johnson</author>
<author>John Vlissides</author>
</book>
----------------------------------
XSL-file:
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="book">
<xsl:value-of select="title"/>
by <xsl:for-each select="author">
<xsl:value-of select="."/>
<xsl:if test="position()!=last()">, </xsl:if>
<xsl:if test="position()=last()-1">and </xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:transform>
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 <xsl:if> 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.