Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
mate of the state #1
Problems with XML config file
Hi all,
I am trying to setup an XML file to hold general, site/app-wide configuration
settings like the official company name, datasources, etc. etc. I have the
basics setup, and wanted to start testing it, but I get the following error
when attempting to parse the file with xmlParse(): "Document root element is
missing."
Attached is the file, which clearly has a root element. Thanks.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE config PUBLIC [
<!ELEMENT config (properties?,datasource:)>
<!ELEMENT properties (property+)>
<!ELEMENT datasource (dbtables:,dsn:)>
<!ELEMENT dbtables (group+)>
<!ELEMENT group (table+)>
<!ELEMENT table (rel*,col*)>
]>
<config>
<!-- // GENERAL PROPERTIES // -->
<properties>
<property key="companyName" value="Matt Lindholm" />
</properties>
<!-- // DATASOURCE // -->
<datasource>
<dsn>lindholm</dsn>
<dbtables>
<!--
- It is assumed that all tables will have an 'id' field that is the primary
key.
- <rel /> elements indicate a relationship (id) to another primary key in
another table.
-->
<!-- coupons -->
<group name="coupons">
<table name="coupons">
<rel name="customer" group="customers" table="customers" />
<col name="offer" type="text" />
<col name="conditions" type="text" />
<col name="expires" type="datetime" />
</table>
<table name="coupons_categories">
<col name="title" type="varchar" />
<col name="description" type="text" />
</table>
<table name="coupons2categories">
<rel name="coupon" group="coupons" table="coupons" />
<rel name="category" group="coupons" table="categories" />
</table>
</group>
<!-- customers -->
<group name="customers">
<table name="customers">
<col name="user" type="varchar" />
<col name="password" type="varchar" />
<col name="nameFirst" type="varchar" />
<col name="nameLast" type="varchar" />
<col name="companyName" type="varchar" />
</table>
<table name="customers_locations">
<col name="address" type="varchar" />
<col name="city" type="varchar" />
<col name="state" type="varchar" />
<col name="zip" type="varchar" />
</table>
</group>
</dbtables>
</datasource>
</config>
mate of the state Guest
-
problems with Application.config()
Hi There, I'm having problems with setting variables and accessing them through Application.config. I have set custom tags within<config> tags... -
Error loading XML file c:\windows\microsoft.net\framework\v1.0.3705\Config\machine.config
I had many ASP.NET web applications that I created before I had to rebuild my machine. After a fresh install of XP Pro, VS.NET 2003, etc, I now... -
web.config problems
Hi, I have problems in configuring a web.config file of an ASP.NET Web Service project. I declared a new settings section group named ... -
config file: a) what Module ? b) conditionals in config (for multiple hosts)
Hi, a) I am looking for a module to handle config files. There are a number of these modules, like AppCconig. Any consensus about The Right... -
xxxxxx.dll.config problems
Hello everyone I am having a bit of a problem reading a configuration file for an app host via IE. If I make a simple .net app with just a... -
-
Adam Cameron #3
Re: Problems with XML config file
> Bump...
I really don't think there's any need to BUMP your post after only six
hours!
But anyway... you XML doc worked for me if I got rid of the word "PUBLIC"
in your <doctype> tag. I don't know enough about XML and embedded DTDs to
know whether it's essential for what you're doing, but Firefox doesn't
think it's valid with that in there.
--
Adam
Adam Cameron Guest
-
mate of the state #4
Re: Problems with XML config file
Well, considering that it was about to drop off the first page, and that most
threads are lucky if they get double digit replies if they even get ANY, I
wanted to make sure it stayed fresh in people's minds.
That said... I feel like I tried what you are recommending, but I will double
check. Thanks for the feedback.
mate of the state Guest
-
Kronin555 #5
Re: Problems with XML config file
Not that anyone else follows them, but bumping posts is against the posted guidelines for this forum:
[url]http://www.macromedia.com/support/forums/guidelines.html[/url]
Kronin555 Guest
-
mate of the state #6
Re: Problems with XML config file
Okay, simply removing that had no effect. Maybe a little more detail will shed
some light... My Application.cfm file has a <CFapplication /> tag to start, and
then the next bit of code checks for the existence of the config file. If it
finds it, it instantiates the 'root' CFC for the site and then calls that
component's init() method which looks like so:
Attached are the contents of that CFC thus far...
<CFcomponent hint="Root CFC">
<!--- // PROPERTIES // --->
<!--- // METHODS // --->
<!--- loadXML() --->
<CFfunction
name="loadXML"
returntype="void"
hint="Simplifies first two requisite steps for processing XML data."<CFargument name="configPath" type="string" required="yes" />>
<CFargument name="encoding" type="string" required="no" default="utf-8" />
<CFfile action="read" file="#arguments.configPath#" variable="config"
charset="utf-8" />
<CFset config = xmlParse(arguments.configPath) />
<CFreturn config />
</CFfunction>
<!--- init() --->
<CFfunction name="init" returntype="void">
<CFargument name="configPath" type="string" required="yes" />
<!--- HTTP headers --->
<CFheader name="Content-Type" value="text/html; utf-8" />
<CFscript>
// load the config file
this.configXML = this.loadXML(arguments.configPath);
// create config settings container
// config = structNew();
</CFscript>
</CFfunction>
</CFcomponent>
mate of the state Guest
-
mate of the state #7
Re: Problems with XML config file
Ugh... that code is sloppy, I apologize. I didn't use the charset argument I
setup, and if I'm trying to have a generic method for processing XML, I
shouldn't call the other argument 'configPath' but nonetheless...
mate of the state Guest



Reply With Quote

