Problems with XML config file

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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 ...
    4. 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...
    5. 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...
  3. #2

    Default Re: Problems with XML config file

    Bump...
    mate of the state Guest

  4. #3

    Default 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

  5. #4

    Default 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

  6. #5

    Default 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

  7. #6

    Default 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

  8. #7

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139