-
Xml, Xslt, Vb.net
ok, here is the situation, I am trying to transform my xml into a webpage, via xslt, however i get this error when it gets to the actuall transformation process...I have searched for two days, and cannot figure out what is going on. If anyone can offer suggestions, critisism, or ANYTHING, I would be very thankful. Thanx in advance.
StackTrace
at System.Xml.XPath.FilterQuery.SetXsltContext(XsltContext input)
at System.Xml.XPath.FilterQuery.SetXsltContext(XsltContext input)
at System.Xml.XPath.MergeFilterQuery.SetXsltContext(XsltContext input)
at System.Xml.XPath.CompiledXpathExpr.SetContext(XmlNamespaceManager nsManager)
at System.Xml.Xsl.Processor.GetValueQuery(Int32 key)
at System.Xml.Xsl.CopyOfAction.Execute(Processor processor, ActionFrame frame)
at System.Xml.Xsl.ActionFrame.Execute(Processor processor)
at System.Xml.Xsl.Processor.Execute()
at System.Xml.Xsl.XslTransform.Transform(XPathNavigator input, XsltArgumentList args, XmlWriter output, XmlResolver resolver)
at System.Xml.Xsl.XslTransform.Transform(IXPathNavigable input, XsltArgumentList args, XmlWriter output, XmlResolver resolver)
at Weekly_Summary.frmMain.ConvertXML(String inpath, String outpath) in C:\Documents and Settings\user\My Documents\Visual Studio Projects\Weekly Summary\Weekly Summary\Form1.vb:line 349"
Here is my code for the process:
Function ConvertXML(ByVal inpath As String, ByVal outpath As String)
'declare local variables
Dim xmlDoc As New XmlDocument
Dim xslDoc As New XslTransform
Dim Xres As XmlResolver
Dim TWrtr As New XmlTextWriter(outpath, System.Text.Encoding.Default)
'open the xml file
xmlDoc.Load(inpath)
' Open the XSL file.
xslDoc.Load("c:/Summary/Formatter.xslt")
' Transform the XSL and save it to a file.
Try
xslDoc.Transform(xmlDoc, Nothing, TWrtr, Xres)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
here is my XML input file(Snippet)
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Table1>
<Client>All Clients</Client>
<StartDate>2004-10-27T00:00:00.0000000-05:00</StartDate>
<EndDate>"</EndDate>
<Status>Open</Status>
<Priority>0</Priority>
<Description>testing</Description>
<Type>Software</Type>
</Table1>
<Table1>
<Client>AR - SOS</Client>
<StartDate>2004-10-01T00:00:00.0000000-05:00</StartDate>
<EndDate>10/10/2004</EndDate>
<Status>Open</Status>
<Priority>0</Priority>
<Description>test task</Description>
<Type>"</Type>
</Table1>
<Table1>
<Client>DORA - Client Type Name</Client>
<StartDate>2004-10-24T00:00:00.0000000-05:00</StartDate>
<EndDate>"</EndDate>
<Status>Open</Status>
<Priority>0</Priority>
<Description>blahbyity</Description>
<Type>Software</Type>
</Table1>
<Table1>
<Client>DORA - Client Type Name</Client>
<StartDate>2004-10-27T00:00:00.0000000-05:00</StartDate>
<EndDate>10/29/2004</EndDate>
<Status>Complete</Status>
<Priority>3</Priority>
<Description>nothing but test</Description>
<Type>Client</Type>
</Table1>
<Table1>
<Client>IA - Linn</Client>
<StartDate>2004-10-01T00:00:00.0000000-05:00</StartDate>
<EndDate>10/15/2004</EndDate>
<Status>Open</Status>
<Priority>1</Priority>
<Description>test</Description>
<Type>Client</Type>
</Table1>
finally my Formatter.Xslt:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:set="http://exslt.org/set" version="1.0" extension-element-prefixes="set" set:doc="http://www.exslt.org/set" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl: output encoding="utf-8" method="html" />
<xsl:include href="style1.xsl"/>
<!--
The essence of using the variable to store our elements is very similar to a
key table. In this solution, all products are put into the variable (which itself is
in document order) -->
<xsl:variable name="AllIssues" select="/"/>
<!--
The variable $AllRegions will be initialized with all of the distinct
region elements. This collection of nodes is created using the set:distinct
template from EXSLT.org (see bottom) -->
<xsl:variable name="AllClientsDistinct">
<xsl:call-template name="set:distinct">
<xsl:with-param name="nodes" select="//NewDataSet/Table1/Client" />
</xsl:call-template>
</xsl:variable>
<!--
The variable $AllRegions, will hold the "nodeset" equivalent of the
Result Tree Fragment generated by the "set:distinct template.
-->
<xsl:variable name="AllClients" select="msxsl:node-set($AllClientsDistinct)"/>
<!-- Template for root rule -->
<xsl:template match="/">
<xsl:call-template name="Style1"/>
<h2>Issues and Tasks for Managers Attention:</h2>
<xsl:apply-templates />
</xsl:template>
<!-- Template for products rule -->
<xsl:template match="NewDataSet">
<!-- Iterate through the variable containing all of the unique regions -->
<xsl:for-each select="$AllClients/Client">
<xsl:variable name="Client" select="." /><BR></BR>
<H3><xsl:value-of select="$Client" /></H3>
<table border="1">
<tr>
<th>StartDate</th>
<th>EndDate</th>
<th>Status</th>
<th>Priority</th>
<th>Type</th>
</tr>
<!-- Grab the product elements that match the current retion. At this point
the products are retrived from our variable rather than the document itself -->
<xsl:for-each select="$AllClients/NewDataSet/Table1[Client=$Client]">
<xsl:sort select="name"/>
<tr>
<td><xsl:value-of select="StartDate" /></td>
<td><xsl:value-of select="EndDate" /></td>
<td><xsl:value-of select="Status" /></td>
<td><xsl:value-of select="Priority" /></td>
<td><xsl:value-of select="Type" /></td>
</tr>
<tr>
<td>-</td>
<td><xsl:value-of select="Description" /></td>
</tr>
</xsl:for-each>
</table>
</xsl:for-each>
</xsl:template>
<!-- The following template was created by Jeni Tennison of -->
<!-- http://www.JeniTennison.com and is part of an extremely useful -->
<!-- collection of extension functions and templates at http://www.exslt.org -->
<xsl:template name="set:distinct">
<xsl: param name="nodes" select="/.." />
<xsl:choose>
<xsl:when test="not($nodes)" />
<xsl: otherwise>
<xsl:copy-of select="$nodes[1][not(. = $nodes[position() > 1])]" />
<xsl:call-template name="set:distinct">
<xsl:with-param name="nodes" select="$nodes[position() > 1]" />
</xsl:call-template>
</xsl: otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
StackTrace StackTrace
-
Does it say what kind of exception is thrown?
The input XML you posted lacks the final closing tag, but I suppose that's a posting issue.
-
yes, that was a postig issue, since i just posted a snippet, i forgot to post the closing tag..
i thought the exception was in the stack trace, im sorry
its a:
System.NullReferenceException: Object reference not set to an instance of an object
Thanx to anyone who may offer some suggestions.
-
Very weird. It doesn't perchance also say what the variable is called that is not supposed to be null?
-
no...i have tried everything i know to get a more detailed answer of what exactly is null...but i can only get this info that i posted....no more info available. It is very frustrating b/c i can't see anything that im missing, and I work in a vba shop, I'm the only vb.net coder here(we are switching now) so noone here can help either.
-
And of course there's no hope of debugging into the system libraries either...