O
One Handed Man \( OHM - Terry Burns \)
I've been battling with this stupid problem for hours now.
WebApp:
Trying to do a simple transformation using XSLT to a Web Page, but it just
failes without an error message ( In other words, it bums out with a general
exeption with no message ).
It creates the Ouput.html, but errors and does not fill it with HTML.
Where am I going wrong ?
Cheers - OHM
//**********************************
//CODE
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim xreader As New XmlTextReader(Server.MapPath("XDATA.XML"))
Dim xDoc As XPathDocument = New XPathDocument(xreader)
Dim oXSLT As XslTransform = New XslTransform
Dim xWriter As XmlTextWriter = New
XmlTextWriter(Server.MapPath("Output.html"), Nothing)
Try
oXSLT.Load(Server.MapPath("XDATA.XSLT"))
oXSLT.Transform(xDoc, Nothing, xWriter)
Catch ex As XsltException
Response.Write("<B>FAILED - XSLT Exception </B" & ex.Message)
Catch ex As XsltCompileException
Response.Write("<B>FAILED: XLST Compilation Exception</B" &
ex.Message)
Catch ex As Exception
Response.Write("<B>FAILED: Unkown Exception - </B" & ex.Message)
Finally
xreader.Close()
xWriter.Close()
End Try
End Sub
//**************************************
// XML
<?xml version="1.0" encoding="utf-8" ?>
<bookstore xmlns="x-schmema:XDATA.xsd">
<book title="Wind In the Willows" author="Author Winkle"/>
<book title="Wind In the Bows" author="Martha Winkle"/>
<book title="Gale In the Willows" author="Susan Winkle"/>
</bookstore>
//****************************************
// XSD
<?xml version="1.0"?>
<xs:schema id="bookstore" targetNamespace="x-schmema:XDATA.xsd"
xmlns:mstns="x-schmema:XDATA.xsd" xmlns="x-schmema:XDATA.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="bookstore" msdata:IsDataSet="true" msdata:Locale="en-GB"
msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="book">
<xs:complexType>
<xs:attribute name="title" form="unqualified" type="xs:string"
/>
<xs:attribute name="author" form="unqualified" type="xs:string"
/>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
//*********************************************
// TRANSFORM
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns=xsl:"http://www.w3.org/1999/XSL/Transform"
xmlns
p="x-schemas:XDATA.xsd">
<xsl:template match="op:bookstore">
<HTML><BODY>
<TABLE>
<TR>
<TD><B>Title</B></TD>
<TD><B>Author</B></TD>
</TR>
<xsl:apply-templates select="op:book"/>
</TABLE>
</BODY></HTML>
</xsl:template>
<xsl:template match="op:book">
<TR>
<TR>
<TD><xsl:value-of select="op:title"/></TD>
</TR>
</TR>
</xsl:template>
</xsl:stylesheet>
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don't know what you're doing
WebApp:
Trying to do a simple transformation using XSLT to a Web Page, but it just
failes without an error message ( In other words, it bums out with a general
exeption with no message ).
It creates the Ouput.html, but errors and does not fill it with HTML.
Where am I going wrong ?
Cheers - OHM
//**********************************
//CODE
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim xreader As New XmlTextReader(Server.MapPath("XDATA.XML"))
Dim xDoc As XPathDocument = New XPathDocument(xreader)
Dim oXSLT As XslTransform = New XslTransform
Dim xWriter As XmlTextWriter = New
XmlTextWriter(Server.MapPath("Output.html"), Nothing)
Try
oXSLT.Load(Server.MapPath("XDATA.XSLT"))
oXSLT.Transform(xDoc, Nothing, xWriter)
Catch ex As XsltException
Response.Write("<B>FAILED - XSLT Exception </B" & ex.Message)
Catch ex As XsltCompileException
Response.Write("<B>FAILED: XLST Compilation Exception</B" &
ex.Message)
Catch ex As Exception
Response.Write("<B>FAILED: Unkown Exception - </B" & ex.Message)
Finally
xreader.Close()
xWriter.Close()
End Try
End Sub
//**************************************
// XML
<?xml version="1.0" encoding="utf-8" ?>
<bookstore xmlns="x-schmema:XDATA.xsd">
<book title="Wind In the Willows" author="Author Winkle"/>
<book title="Wind In the Bows" author="Martha Winkle"/>
<book title="Gale In the Willows" author="Susan Winkle"/>
</bookstore>
//****************************************
// XSD
<?xml version="1.0"?>
<xs:schema id="bookstore" targetNamespace="x-schmema:XDATA.xsd"
xmlns:mstns="x-schmema:XDATA.xsd" xmlns="x-schmema:XDATA.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="bookstore" msdata:IsDataSet="true" msdata:Locale="en-GB"
msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="book">
<xs:complexType>
<xs:attribute name="title" form="unqualified" type="xs:string"
/>
<xs:attribute name="author" form="unqualified" type="xs:string"
/>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
//*********************************************
// TRANSFORM
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns=xsl:"http://www.w3.org/1999/XSL/Transform"
xmlns

<xsl:template match="op:bookstore">
<HTML><BODY>
<TABLE>
<TR>
<TD><B>Title</B></TD>
<TD><B>Author</B></TD>
</TR>
<xsl:apply-templates select="op:book"/>
</TABLE>
</BODY></HTML>
</xsl:template>
<xsl:template match="op:book">
<TR>
<TR>
<TD><xsl:value-of select="op:title"/></TD>
</TR>
</TR>
</xsl:template>
</xsl:stylesheet>
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don't know what you're doing