473,320 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 5834


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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.