954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

XSLT code doesn't seem to work!!

I am new to XML/XSLT and have taken a fascination to XSLT.
Please take a look at the following and let me know.
==========================================================
<?xml version="1.0"?>

This file is saved as family.xml
==========================================================
<?xml version="1.0" ?>

This file is saved as test.xsl
==========================================================
Dim oDoc As DOMDocument
Dim oXSLT As DOMDocument
Dim sResult As String
Dim sPath As String

Set oDoc = New DOMDocument
Set oXSLT = New DOMDocument

oDoc.async = False
oXSLT.async = False

oDoc.Load txtSource.Text
oXSLT.Load txtTransformer.Text

sResult = oDoc.transformNode(oXSLT)

Set fso = New Scripting.FileSystemObject
sPath = fso.BuildPath("C:\VB\XML\", "Dest.xml")
fso.CreateTextFile sPath
Set ts = fso.OpenTextFile(sPath, ForWriting)
ts.Write sResult
ts.Close

Set ts = Nothing
Set fso = Nothing
Set oDoc = Nothing
Set oXSLT = Nothing

In my VB IDE the project references MSXML v4.0
This code should be very self-explanatory.
==============================================================
My problem:
The code generates the result file, but is a copy of the xsl file minus the xml PI.

It is supposed to generate the following:

What am I doing wrong?

krishnakr
Newbie Poster
1 post since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

Hi I did a minor change to your xsl and i think i got the result you are after:

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/">
		<root_node>
			<xsl:apply-templates select="*" mode="result_nodes"/>
		</root_node>
	</xsl:template>
	
	<xsl:template match="*" mode="result_nodes">
		<result_node>
			<xsl:apply-templates select="*" mode="result_nodes"/>
		</result_node>
	</xsl:template>
</xsl:stylesheet>
alpha_foobar
Junior Poster
182 posts since May 2005
Reputation Points: 20
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You