Domain name XML

In XML creation: Part 1, I went about creating an XML document, with both a CSS and XSLT, that was used to store my video game information.

Yesterday I was going through my domains, and realized that it would be pretty helpful to have an XML document where I could store domain name information, since I've got too many to keep track of in my head.

The layout

Using lists, this the version 1 that I came up with yesterday:

  • domains
    • domain
      • name
      • created
        • year
        • month
        • day
      • expires
        • year
        • month
        • day
      • registrar
      • servers
        • server
          • ip
          • path
      • subdomains
        • subdomain
          • name
          • path
          • server

Now that we've got a layout, let's create an empty structure.

Empty structure

Unlike the last time we did this, we'll use attributes much more this time.

I'll be using <oXygen/> XML Editor to create this.


<?xml version="1.0" encoding="UTF-8"?>
    <domains>
        <domain id="1">
            <name>jamesrskemp.net</name>
            <created year="2002" month="12" day="11"/>
            <expires year="2009" month="5" day="15"/>
            <registrar>GoDaddy</registrar>
            <servers>
                <server id="1">
                    <ip>76.12.10.196</ip>
                    <path>\Inetpub\wwwroot\jamesrskemp</path>
                </server>
            </servers>
            <subdomains>
                <subdomain id="1" name="www" server="1">
                    <path>http://jamesrskemp.com</path>
                </subdomain>
            </subdomains>
        </domain>
    </domains>

Document Type Definition (DTD)

The domain_names.dtd for the above XML is listed below.


<!ELEMENT domains (domain*)>
<!ELEMENT domain (name, created, expires, registrar, servers*, subdomains*)>
<!ATTLIST domain id CDATA #REQUIRED>

<!ELEMENT name (#PCDATA)>
<!ELEMENT created EMPTY>
<!ATTLIST created year CDATA #REQUIRED>
<!ATTLIST created month CDATA #REQUIRED>
<!ATTLIST created day CDATA #REQUIRED>
<!ELEMENT expires EMPTY>
<!ATTLIST expires year CDATA #REQUIRED>
<!ATTLIST expires month CDATA #REQUIRED>
<!ATTLIST expires day CDATA #REQUIRED>
<!ELEMENT registrar (#PCDATA)>

<!ELEMENT servers (server*)>

<!ELEMENT server (ip, path)>
<!ATTLIST server id CDATA #REQUIRED>

<!ELEMENT ip (#PCDATA)>
<!ELEMENT path (#PCDATA)>

<!ELEMENT subdomains (subdomain*)>

<!ELEMENT subdomain (path)>
<!ATTLIST subdomain id CDATA #REQUIRED>
<!ATTLIST subdomain name CDATA #REQUIRED>
<!ATTLIST subdomain server CDATA #REQUIRED>

I've yet to figure out how to serve the DTD like the W3C is. Any ideas? I've already tried serving content as application/xml-dtd, but then Validome.org couldn't handle the DTD, so I had to switch it to application/xml.

Final XML

With the XML and DTD created, we now have a valid XML document.

View the completed XML document.