Click here to Skip to main content
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 4:30am

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 504
1 Maciej Los 349
2 Kornfeld Eliyahu Peter 325
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,303
1 DamithSL 4,764
2 Maciej Los 4,306
3 Kornfeld Eliyahu Peter 3,914
4 Sergey Alexandrovich Kryukov 3,538


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 18 Dec 2012
Copyright © CodeProject, 1999-2014
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