XML Error?

jsandoval

Active member
Joined
Dec 27, 2004
Messages
28
Location
Denver
Programming Experience
10+
Hello All,

I am attempting to create my first XML document just as a proof of concept and have run into an error I cannot figure out. If anyone has a answer to this error I would greatly appreciate it.




The XML page cannot be displayed Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. Required white space was missing. Error processing resource 'http://localhost/XMLDemo/WebForm1.aspx'. Line 2, Position 62
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">



:confused:
 
That is a Html DTD. See here for some info about this matter http://www.w3schools.com/xml/xml_dtd.asp and here http://www.xml.com/lpt/a/2002/09/04/xslt.html

If your proof of concept is to interpret Html document tags as Xml with a Xsl transformation, you should know I have already done that :D (and probably many others also).
If this was not your idea, well never mind, I thought this was fun to play with a while ago, so here is the outline:

For this concept.. here is what has to be done (if html is already validated as Xhtml):
- rename .htm to .xml
- replace toplevel doctype definition with xml definition (you can add info to xsl output statement too)
- replace inline script escaping <!--...//--> with <![CDATA[...]]>
- remove <html>-attribute xmlns (conflicts)
- add fixed stylesheet generic html.xsl
I have attached the stylesheet, by no means complete, but anyone will get the idea.
 

Attachments

  • html.zip
    771 bytes · Views: 38
Thank you for your response John,

Perhaps some more information will help to make more sense of what I am trying to do.

I have created a web page with nothing more than a XML control. The code behind VB selects all columns from the Employee table in Pubs.

Below is the full HTML as well as the code behind:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="XMLDemo.WebForm1" ContentType="text/xml"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:xml id="Xml1" runat="server"></asp:xml></form>
</body>
</HTML>



----------------------------------------------------------------------



PrivateSub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
'Put user code to initialize the page here
Dim Connection AsNew SqlConnection("Integrated Security=True;" & _
"Server=PSA607;" & _
"Initial Catalog=Pubs")
Dim MyCommand AsNew SqlDataAdapter("Select * from Employee", Connection)
Dim dsEmployee AsNew DataSet
MyCommand.Fill(dsEmployee, "Employee")
Dim XmlDoc As XmlDataDocument = New XmlDataDocument(dsEmployee)
Xml1.Document = XmlDoc
XmlDoc.Save("Employee1.xml")
EndSub

 
Ok cool, but that will not produce a Xml document. What you can do is to start a new webpage, remove ALL text and add this text instead:
HTML:
<%@ Import Namespace="System.Xml" %>
<script language="VB" runat="server">
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim Connection As New SqlConnection("Integrated Security=True;" & _
"Server=PSA607;" & _
"Initial Catalog=Pubs")
Dim MyCommand As New SqlDataAdapter("Select * from Employee", Connection)
Dim dsEmployee As New DataSet
MyCommand.Fill(dsEmployee, "Employee")
Dim XmlDoc As New XmlDataDocument(dsEmployee)
Response.ContentType = "text/xml"
Response.Write(XmlDoc.OuterXml)
End Sub
</script>
 
I have now run into a new issue, the following is the last of the XML document. Not all records are bing displayed:

</Employee>
- <Employee>
<emp_id>MFS52347M</emp_id>
<fname>Martin</fname>
<minit>F</minit>
<lname>Sommer</lname>
<job_id>10</job_id>
<job_lvl>165</job_lvl>
<pub_id>0736</pub_id>
<hire_date>1990-04-13T00:00:00.0000000-06:00</hire_date>
</Employee>
- <Employee>
<emp_id>GHT50241M</emp_id>
<fname>Gary</fname>
<minit>H</minit>
<lname>Thomas</lname>
<job_id>9</job_id>
<job_lvl>170</job_lvl>
<pub_id>0736</pub_id>
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.

--------------------------------------------------------------------------------
Cannot have a DOCTYPE declaration outside of a prolog. Error processing resource 'http://localhost/XMLDemo/WebForm2.aspx'. ...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
----------^
="margin-left:1em;text-indent:-2em"> <hire_date>1988-08-09T00:00:00.0000000-06:00</hire_date>
</Employee>
- <Employee>
<emp_id>DBT39435M</emp_id>
<fname>Daniel</fname>
<minit>B</minit>
 
so where does that DOCTYPE come from? didn't you remove it like I told?
 
Back
Top