Click here to Skip to main content
11,633,454 members (78,545 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hi all,

Newbie to vb so please be gentle....

I am trying to transform some xml using xslcompliedtransform and the xsltargumentlist to another xml file. The file is created, but with only a root element

The main projects.xml file is loaded into a data grid view with some basic details, once a row is clicked, i want to filter the main xml file to create a html report containing all the xml data for the selected entry.

Obviously, not the full correct xml, but is an edited structure...

<?xml version="1.0" encoding="UTF-8"?>
<Root>
	<Row A1="123456">
		<F48>Open</F48>
		<F49>Project One</F49>
	</Row>
	<Row A1="654321">
		<F48>Open</F48>
		<F49>Project One A</F49>
	</Row>
	<Row A1="223344">
		<F48>Closed</F48>
		<F49>Project Two</F49>
	</Row>
</Root>

The XSL being used:

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:decimal-format name="NN" NaN="0" />
<xsl:param name="ID" />
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="/@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="Root">
<xsl:copy>
<xsl:apply-templates select="Row[@A1=$ID]" />
</xsl:copy>
</xsl:template>
<xsl:template match="Row">
<Row>
<xsl:apply-templates select="@A1 | F49 | F48" />
</Row>
</xsl:template>
</xsl:stylesheet>


The vb code running on a button click is

Dim oXSL As New XslCompiledTransform()
oXSL.Load("findProject.xsl")
Dim oXslArg As New XsltArgumentList()
oXslArg.AddParam("ID", "", dgList.Rows(e.RowIndex).Cells(0).Value
oXSL.Transform(New XPathDocument("projects.xml"), XmlWriter.Create(dgList.Rows(e.RowIndex).Cells(0).Value & ".xml"))


The file that is created is

<?xml version="1.0" encoding="utf-8"?><Root />


When running the transformation in XML Notepad or other xml editor, the transform works perfectly....any ideas people? Or any suggestions for a better method?

Many thanks

Graham
Posted 18-Dec-12 3:30am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 8,618
1 Sergey Alexandrovich Kryukov 8,189
2 Mika Wendelius 6,415
3 F-ES Sitecore 2,321
4 Suvendu Shekhar Giri 2,075


Advertise | Privacy | Mobile
Web03 | 2.8.150728.1 | Last Updated 18 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100