University of Cincinnati logo and link  
XML Document Structure
 
  UC ingot
  • XML files often start with an optional header:

  • <?xml version="1.0" ?>
  • The next line is a document type declaration.  This example comes from an Orion configuration file.

  • <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">
    • Though not required, the DTD entry is used to verify the file.  In this example, the tag references a DTD that can be found online.  You can go to that link and choose Save As to view the file.  For your conveinience, the text of the file is pasted at the end of this document.
  • Finally, the XML document has the tags.  It starts with the root element, which may contain child elements, which may contain text or more child elements.
  • Practice: Look for XML files on your computer.  Open them up.
More about XML elements

Sample DTD:

     
    <!ENTITY % CLASSNAME "CDATA">

    <!-- A list of arguments to used when invoking the app-client if starting it in-process (auto-start="true"). -->
    <!ELEMENT arguments (argument*)>

    <!-- Logging settings. -->
    <!ELEMENT log (file*, mail*)>

    <!-- An argument used when invoking the client. -->
    <!ELEMENT argument (#PCDATA)>
    <!ATTLIST argument value CDATA #IMPLIED
    >

    <!-- A group that this security-role-mapping implies. Ie all the members of the specified group are included in this role. -->
    <!ELEMENT group (#PCDATA)>
    <!ATTLIST group name CDATA #IMPLIED
    >

    <!-- A user that this security-role-mapping implies. -->
    <!ELEMENT user (#PCDATA)>
    <!ATTLIST user name CDATA #IMPLIED
    >

    <!-- The runtime mapping (to groups and users) of a role. Maps to a security-role of the same name in the assembly descriptor. -->
    <!ELEMENT security-role-mapping (group*, user*)>
    <!ATTLIST security-role-mapping impliesAll CDATA #IMPLIED
    name CDATA #IMPLIED
    >

    <!-- A relative/absolute path to log events to. -->
    <!ELEMENT file (#PCDATA)>
    <!ATTLIST file path CDATA #IMPLIED
    >

    <!-- Contains a name/value pair initialization param. -->
    <!ELEMENT property (#PCDATA)>
    <!ATTLIST property name CDATA #IMPLIED
    value CDATA #IMPLIED
    >

    <!-- A resource with a specific security setting. -->
    <!ELEMENT namespace-resource (security-role-mapping)>
    <!ATTLIST namespace-resource root CDATA #IMPLIED
    >

    <!-- An application-client module of the application. An app-client is a GUI or console-based standalone client that interracts with the server. -->
    <!ELEMENT client-module (arguments?)>
    <!ATTLIST client-module auto-start (true|false) "false"
    deployment-time CDATA #IMPLIED
    path CDATA #IMPLIED
    user CDATA #IMPLIED
    >

    <!-- A relative/absolute path/URL to a directory or a .jar/.zip to add as a library-path for this server. Directories are scanned for jars/zips to include at startup. -->
    <!ELEMENT library (#PCDATA)>
    <!ATTLIST library path CDATA #IMPLIED
    >

    <!-- A e-mail address to log events to. A valid mail-session also needs to be specified if this option is used. -->
    <!ELEMENT mail (#PCDATA)>
    <!ATTLIST mail address CDATA #IMPLIED
    >

    <!-- A web-application module of the application. Each web-application can be installed on any site and in any context on those sites (for instance http://www.myserver.com/myapp/). -->
    <!ELEMENT web-module (#PCDATA)>
    <!ATTLIST web-module id CDATA #IMPLIED
    path CDATA #IMPLIED
    >

    <!-- An orion-ejb-jar.xml file contains the deploy-time info for an application.
       It is located in ORION_HOME/application-deployments/deploymentName/orion-application.xml after deployment and META-INF/orion-application.xml below the application root if bundled with the application or if no deployment-directory is specified in server.xml. If using deployment-directory (which is the default) the bundled version will be copied to the deployment location if and only if no file exists at that location. It is used to specify initial (first time) deployment properties.
       After each deployment the deployment file is reformatted/augmented/altered by the server to add any new/missing info to it. -->
    <!ELEMENT orion-application (ejb-module*,web-module*,client-module*,security-role-mapping*, persistence?, library*, principals?, mail-session*, user-manager?, log?, data-sources?, namespace-access?)>
    <!ATTLIST orion-application auto-alter-tables (true|false) "false"
    auto-create-tables (true|false) "true"
    auto-delete-tables (true|false) "false"
    default-data-source CDATA #IMPLIED
    deployment-version CDATA #IMPLIED
    treat-zero-as-null (true|false) "false"
    >

    <!-- Specifies an optional user-manager to use, example user-managers are com.evermind.sql.DataSourceUserManager,
       com.evermind.ejb.EJBUserManager, etc... Used to integrate existing systems and provide custom user-managers for
       web-applications. -->
    <!ELEMENT user-manager (description?, property*)>
    <!ATTLIST user-manager class %CLASSNAME; #IMPLIED
    display-name CDATA #IMPLIED
    >

    <!-- Defines the relative/absolute path to a <a class="link" href="data-sources.xml.html">data-sources XML-file</a> containing the installed datasources on this server. -->
    <!ELEMENT data-sources (#PCDATA)>
    <!ATTLIST data-sources path CDATA #IMPLIED
    >

    <!-- The session SMTP-server host (if using SMTP). -->
    <!ELEMENT mail-session (description?, property*)>
    <!ATTLIST mail-session location CDATA #IMPLIED
    smtp-host CDATA #IMPLIED
    >

    <!-- A ejb-jar module of the application. -->
    <!ELEMENT ejb-module (#PCDATA)>
    <!ATTLIST ejb-module path CDATA #IMPLIED
    remote (true|false) "false"
    >

    <!-- A short description of this component. -->
    <!ELEMENT description (#PCDATA)>

    <!-- The read-access policy. -->
    <!ELEMENT read-access (namespace-resource)>

    <!-- Namespace (naming context) security policy for RMI clients. -->
    <!ELEMENT namespace-access (read-access, write-access)>

    <!-- A relative (to the application root) or absolute path to a <a class="link" href="principals.xml.html">principals XML-file</a> containing the users/groups for this application. -->
    <!ELEMENT principals (#PCDATA)>
    <!ATTLIST principals path CDATA #IMPLIED
    >

    <!-- The write-access policy. -->
    <!ELEMENT write-access (namespace-resource)>

    <!-- A relative (to the application root) or absolute path to a directory where application state should be stored across restarts. -->
    <!ELEMENT persistence (#PCDATA)>
    <!ATTLIST persistence path CDATA #IMPLIED
    >