473,470 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

doctype

I'm having a really tough time finding references for XML with ASP.
Everything I find assumes I already have an XML file and want to display it
with ASP. I'm looking for reference material where I can CREATE XML files
using ASP.

Currently I am looking for a way to put in the following line in an XML file
using ASP.

<!DOCTYPE FREIGHT SYSTEM 'freight.dtd'>

I can add

<?xml version="1.0" encoding="ISO-8859-1"?>

using...

set pi = objXML.createProcessingInstruction("xml", "version='1.0'
encoding='ISO-8859-1'")
objXML.insertBefore pi, objXML.firstChild

and...

<?xml-stylesheet type='text/xsl' href='freight.xsl'?>

using...

set pi2 = objXML.createProcessingInstruction("xml-stylesheet",
"type='text/xsl' href='freight.xsl'")
objXML.insertBefore pi2, objXML.firstChild

but I cannot find a way to include:
<!DOCTYPE FREIGHT SYSTEM 'freight.dtd'>

I tried using:

dim node
set node = objXML.createTextNode("<!DOCTYPE FREIGHT SYSTEM 'freight.dtd'>")
objXML.insertBefore node, objXML.firstChild

but I get an error:
msxml4.dll error '80004005'
This operation can not be performed with a Node of type PCDATA.

/dev/freight2.asp, line 55

Apparently MSFT seems to think nobody uses VBScript in ASP to work with XML.
All examples are in JScript and they give you a guideline of how to convert
examples/syntax but still nothing re: doctype. The info only tells you how
to use it to OBTAIN doctype info from an existing XML file.

Since I have no references, I thought I'd try something else:

objXML.doctype = "<!DOCTYPE FREIGHT SYSTEM 'freight.dtd'>"

but I get an errror:

Wrong number of arguments or invalid property assignment: 'objXML.doctype'

I'm betting the latter since I believe using it this way is read-only.

If someone could just point me to a reference with all commands with
vbscript syntax, I'd forever be appreciative.

TIA...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #1
3 5836


Roland Hall wrote:

Currently I am looking for a way to put in the following line in an XML file
using ASP.

<!DOCTYPE FREIGHT SYSTEM 'freight.dtd'>


Well using the MSXML APIs doesn't depend on whether you do it in ASP
and/or with VBScript or JScript or VB.
When you create a new document from scratch then the only way I have
found to add a DOCTYPE declaration is to use the loadXML to load the
DOCTYPE declaration and the root element e.g.
Dim XmlDocument1, XmlDocument2, XmlSource
Set XmlDocument1 = Server.CreateObject("Msxml2.DOMDocument.3.0")
XmlSource = "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf & _
"<!DOCTYPE FREIGHT SYSTEM ""test2004123001.dtd"">" &
vbCrLf & _
"<FREIGHT />"
XmlDocument1.validateOnParse = False
XmlDocument1.loadXML(XmlSource)

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 22 '05 #2

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:eU**************@TK2MSFTNGP10.phx.gbl...
:
:
: Roland Hall wrote:
:
:
: > Currently I am looking for a way to put in the following line in an XML
file
: > using ASP.
: >
: > <!DOCTYPE FREIGHT SYSTEM 'freight.dtd'>
:
: Well using the MSXML APIs doesn't depend on whether you do it in ASP
: and/or with VBScript or JScript or VB.
: When you create a new document from scratch then the only way I have
: found to add a DOCTYPE declaration is to use the loadXML to load the
: DOCTYPE declaration and the root element e.g.
: Dim XmlDocument1, XmlDocument2, XmlSource
: Set XmlDocument1 = Server.CreateObject("Msxml2.DOMDocument.3.0")
: XmlSource = "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf & _
: "<!DOCTYPE FREIGHT SYSTEM ""test2004123001.dtd"">" &
: vbCrLf & _
: "<FREIGHT />"
: XmlDocument1.validateOnParse = False
: XmlDocument1.loadXML(XmlSource)

Thanks Martin but then how do I get that to save to a file?
If I use XmlDocument1.save(XmlFileName) the file is 0 bytes.
Jul 22 '05 #3


Roland Hall wrote:

Thanks Martin but then how do I get that to save to a file?
If I use XmlDocument1.save(XmlFileName) the file is 0 bytes.


I think before calling loadXML one needs to set
resolveExternals = False
as otherwise the XML parser would try to load the DTD but can't resolve
the relative URL. Then the following example works here for me:

<%@ Language="VBScript" %>
<%
Dim XmlDocument1, XmlSource, FileName, Element, Loaded
Set XmlDocument1 = Server.CreateObject("Msxml2.DOMDocument.3.0")
XmlSource = "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf & _
"<!DOCTYPE FREIGHT SYSTEM ""test2004123001.dtd"">" &
vbCrLf & _
"<FREIGHT />"
XmlDocument1.validateOnParse = False
XmlDocument1.resolveExternals = False
Loaded = XmlDocument1.loadXML(XmlSource)
If Loaded Then
Set Element = XmlDocument1.createElement("BOX")
Element.appendChild(XmlDocument1.createTextNode("b icycle"))
XmlDocument1.documentElement.appendChild(Element)
FileName = "test2004123002Output.xml"
XmlDocument1.save Server.MapPath(FileName)
Response.Write "<p><a href=""" & FileName & """>XML</a></p>" & vbCrLf
Else
Response.Write "<p>" & XmlDocument1.parseError.reason & "</p>"
End If
%>

The file is saved and can be loaded from the link generated.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: CMAR | last post by:
I create my website using Front Page 2000. I notice that none of my pages have a DocType statement at the top. I have read that if you want IE6 to use "Standards mode" rather than the "Quirks...
6
by: Patrick | last post by:
Hi I am fairly new to CSS and the web.I am trying to build a site more to practice my skills than for the site itself. I have been focusing on CSS and try my best to make it work in I.E 6.0,...
2
by: DartmanX | last post by:
I doubt this is possible, but I want to ask, just in case it is. I have a project going using Google Maps. This project spits out an HTML page template for people to post to their website and...
25
by: Viken Karaguesian | last post by:
Hello all, I'm somewhat of a newbie to webscripting. I've made a couple of websites in the past with WYSIWYG software, but now I'm much more interested in manual scripting. I have some...
2
by: PapaRandy | last post by:
Hello, I am trying to validate the following .py webpage as HTML (through W3C). I put: ----------------------------------------------------------------------------- print "Content-type:...
24
by: Jim Michaels | last post by:
I can't get any "universal" code working that tries to detect whether the document it's in is xhtml or html. I found this, which tells me I have a hill to climb with no equipment....
6
by: Rolf Welskes | last post by:
Hello, if I have for example: <table style="width: 100%; height: 100%;" border="1"> <tr> <td style="width: 100px">k </td> <td style="width: 100px">k </td> </tr>
0
drhowarddrfine
by: drhowarddrfine | last post by:
The Doctype or DTD Many coders get confused by all the talk of doctypes and how they affect browsers and the display of their web pages. This article will get right to the point about doctypes...
11
by: rfr | last post by:
When I add a transitional doctype to the weather page on my community website, I loose certain Js scripts, but not all of them. This puzzles me. The main menu is powered by a js script and...
6
by: WT | last post by:
Hello, I am searching for a way to generate automatically from codebehind the <!Doctype....for asp.net pages using .net 3.5 c# and vs2008. Subidiary question: if I do a server transfert in my...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.