[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Newbie question: XML design for configuration file

  • From: "Thomas B. Passin" <tpassin@h...>
  • To: xml-dev <xml-dev@l...>
  • Date: Mon, 23 Jul 2001 19:11:45 -0400

configuration file design
[Erin O'Neill]

Are you really asking if you should use a namespace?  I don't see any other
difference between your two versions.  I'd get squared away on the rest of
your structures first, then see if you need to protect against possible
ambiguity by using a namespace.  That might also depend on whether you might
merge several of these files in the future.

It seems like this might be a good place to use attributes:

 <section name="global">
 <conf key="logDir" value='/var/logs'/>
 <conf key="notify" value='eon@k...'/>
 </section>

This way would probably make it easier to build your Hashmap.  But this also
depends on whether you might need more structure in your fields; if so,
you'd want to stick with elements.

In fact, you might want to see if you could take more advantage of XML's
ability to delineate structure.  Maybe there are dependencies that are
waiting to be captured in the configuration data.

Here's a portion of a tools configuration file from my XML Cooktop
installation:

========================================
<XSLTS >
 <XSLT  name="MSXML"
   type="embeded"
   exec=""
   path=""
   supported_func="system-property|function-available"
   http-support="yes" />

 <XSLT  name="MSXSL (external)"
   type="external"
   exec="%CONFIG%\xslt\msxsl &#34;!xml!&#34; &#34;!xsl!&#34; -v -t -o
&#34;!res!&#34; !params! "
   path="%CONFIG%\xslt\saxon"
   supported_func="system-property|function-available"
   http-support="yes"
   param-patern="&#34;!param!&#34;=&#34;!val!&#34;"
   />
=========================================

And here's some mode-specific editing configuration fragments from my JEdit
installation:

==================================
<MODE>
 <PROPS>
  <PROPERTY NAME="commentStart" VALUE="&lt;!--" />
  <PROPERTY NAME="commentEnd" VALUE="--&gt;" />
 </PROPS>
 <RULES IGNORE_CASE="TRUE">
  <!-- WHITE SPACE ( SPACE, TAB ) -->
  <WHITESPACE> </WHITESPACE>
  <WHITESPACE> </WHITESPACE>

  <!-- JavaScript -->
  <SPAN TYPE="MARKUP" DELEGATE="javascript::MAIN">
   <BEGIN>&lt;xsl:script</BEGIN>
   <END>&lt;/xsl:script&gt;</END>
  </SPAN>
=======================================

Cheers,

Tom P

> Hi all!
> I'm a newbie to XML (and java, tho I have more java experience &
training).  Currently we have an app that needs extensive & complex
configuration.  It seems logical to put the configuration into several xml
docs.  There is no one inhouse with xml experience but the experienced java
programmer seems to think I should "Super" generalize the xml doc.
>
> The configurations will ultimately endup in a HashMap containing a string
key & a value that can be either a string, hashtable, arrayList, etc.  He
thinks I should basically do something like this:
>
> ...
>
> <section name="global">
> <conf key="logDir">/var/logs</conf>
> <conf key="notify">eon@k...</conf>
> </section>
> <section name="server">
> <conf key="RunAsDaemon">0</conf>
> <conf key="username">eon</conf>
> </section>
> <section name="Fields" type="hashtable">
> <conf key="fullName">A1</conf>
> <conf key="SSN">A5</conf>
> <conf key="Dept">HR</conf>
> </section>
> <section name="Auth" type="ArrayList">
> <conf key="SSN"/>
> <conf key="employeeNumber"/>
> <conf key="fullName"/>
> </section>
> ...
> something like that. The DTD would be fairly easy to write & a Schema
could be written to set up data restrictions.
>
> However, in the Java & XML book & the tutorials I've taken, it seems to
me, that this might be too general of an XML design (it does parse as a well
formed XML document). So I'm confused as to how to design the documentation.
It's primary use if for a Java Class but we could add some HTML tags & then
have a java class turn it into HTML documentation (wow 2 uses for one doc!).
>
> Should I instead make if more specific?? with something like:
> ...
> <myXML:section name="global">
> <myXML:notify>eon@k...</myXML:notify>
> <myXML:logDir>/var/logs</myXML:logDir>
> </myXML:section>
> <myXML:section name="server">
> <myXML:RunAsDaemon>0</myXML:RunAsDeamon>
> <myXML:username>eon</myXML:username>
> </myXML:section>
> <myXML:section name="Fields" type="hashtable">
> <myXML:fullName>A1</myXML:fullName>
> <myXML:SSN>A5</myXML:SSN>
> <myXML:Dept>HR</myXML:Dept>
> </section>
> <section name="Auth" type="ArrayList">
> <myXML:SSN/>
> <myXML:employeeNumber/>
> <myXML:fullName/>
> </section>
> ...
>
> It does seem like the more general is more java like & the more specific
seems more HTML like.  I'm confused!
>
> thanks in advance.
> erin
>
> ------------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To unsubscribe from this elist send a message with the single word
> "unsubscribe" in the body to: xml-dev-request@l...
>


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.