www.webdeveloper.com
+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2012
    Posts
    1

    Question Need help with formatting this xml document

    I needed to create a taxonomy for a domain, and then create the xml document and schema for my taxonomy. The domain i chose was "countries" and this is the taxonomy i came up with:



    Countries
    -Language
    --Official Language
    --National Language

    Cities
    -Capital
    --Name
    --Location

    -Other cities
    --Name
    --Location

    Government
    -First Name
    -Sur Name
    -Date of birth
    -Position
    -Length of power

    Religion
    -Main group
    -Sect

    Monument
    -location
    -size
    -image
    -meaning

    Flag
    -Name
    -Colour
    -Design
    -Adoption

    Currency
    -Name
    -Code
    -Inflation (%)
    -Subunit/ Sub-divisor
    -Year of introduction

    Airport
    -Airlines
    --Airplanes
    --Staff
    ---First Name
    ---Surname
    ---Role
    --Staff
    ---First Name
    ---Surname
    ---Role

    Telecommunications
    -Type
    --Telephony
    ---Calling code
    ---Area codes
    ---Service Providers/ networks

    --Internet
    ---Users
    ---Service Providers

    --Mass Media


    Education
    -Establishments
    --School
    ---Name
    ---Location
    ---Specialisation

    --Universities
    ---Name
    ---Location
    ---Specialisation

    Size
    -Total area
    -Land area
    -Water area
    -Highest point
    -Lowest Point

    Culture
    -Literature
    --Poets
    ---First Name
    ---Sur Name
    ---Genre

    --Novelists
    ---First Name
    ---Sur Name
    ---Genre

    -Music
    --Artist
    ---First Name
    ---Sur Name
    ---Stage Name
    ---Date of birth
    ---Genre
    -Cinema
    --Films
    ---Title
    ---Genre
    ---Actors
    ----First Name
    ----Sur Name
    ----Date of birth
    ----Genre

    -Sports
    --Type
    ---Teams
    ----Players
    -----First Name
    -----Sur Name
    -----Date of Birth
    -----Position
    -----Number
    -Cuisine
    --Dishes
    --Deserts
    --Drinks


    once i created my taxonomy, i then created my xml document:

    Code:
    <?xml version="1.0" [encoding="UTF-8"] [standalone="yes"] ?> 
    
     <Country name="UK">
    
           <Cities>
              <Capital>
                   <Name> London </Name>
                   <Location> South East </Location>
              </Capital>
              <Other Cities>
                  <Name> Liverpool </Name>
    
                  <part-of>UK</part-of>
    
                  <Location> West </Location>
              </Other Cities>
           </Cities>
        </Country>
    <language> 
        <official language> English </official language>
        <national language> Irish, Ulster Scots, Welsh, Cornish </national language>
    </language>
    
    <cities>
       <capital>
         <name> London </name>
         <location> South East </location>
       </capital>
       <other cities> 
          <name> Birmingham </name>
         <location> Central </location>
         <name> Blackpool </name>
         <location> Northwest </location>
         <name> Exmouth </name>
         <location> South West </location>
         <name> Ipswich </name>
         <location> East </location>
         <name>Carlisle </name>
         <location> North </location>
       </other cities>
    </cities>
    <Government>
        <First name> Gordon </First name>
       <Sur name> Brown </Sur name>
       <Date of Birth> 20/02/1951 </Date of Birth>
       <Position> Prime minister </Position>
       <Length of power> 3 Years </Length of power>
    </Government>
    <Religion>
      <Main Group> Christianity </Main Group>
      <Sect> Protestant </Sect>
    </Religion>
    <Monument>
       <Location> London </Location>
       <Size> 96.3 Meters </Size>
       <Image> Clock </Image>
       <Name> Big Ben </Name> 
    </Monument>
    <Flag>
    <Name> St Georges Cross </Name>
    <Colour> White and Red </Colour>
    <Design> Cross </Design>
    <Adoption>1606 </Adoption>
    </Flag>
    <Currency>
       <Name> Pound </Name> 
       <Code> GBP </Code> 
       <Inflation> 4.0 </Inflation>
       <Subunit> Penny </Subunit>
       <Year of introduction> 1990 </Year of introduction>
    </Currency>
    <Airport>
       <Airlines>
          <Airplanes>British airways </Airplanes>
          <staff>
            <first name> John </first name>
            <sur name> Doe </sur name>
            <role> Air host </role>
          </staff>
       </Airlines>
       <staff>
         <first name> Steve </first name>
          <sur name> Grey </sur name>
          <role> Light Technician </role>
       </staff>
    </Airport>
    <Telecommunications>
       <type>
          <Telephony>
             <calling code>+44 </calling code> 
             <area codes>020, 029, 0113, 0116, 0131 </area codes> 
             <networks> T.mobile, orange, vodaphone, 3 </networks>
          </Telephony>
          <Internet>
            <users>50.7% </users>
            <service providers> 364</service providers>
         </Internet>
       </type>
    </Telecommunications>
    <Education>
        <Establishments>
           <School>
              <Name> Westminster Academy </Name>
              <Location> West London </Location>
              <Specialisation> Business and enterprise </Specialisation>
              <Name> Quintin Kynaston </Name>
              <Location> North West London </Location>
              <Specialisation> Information Technology </Specialisation>
              <Name> Padington Academy </Name>
              <Location> West London </Location>
              <Specialisation> Performing Arts </Specialisation>
           </School>
           <University>
              <Name> Westminster </Name>
              <Location> Central London </Location>
              <Specialisation> Electronics and computer Science </Specialisation>
              <Name> Metropolitan </Name>
              <Location> East London </Location>
              <Specialisation>  Television and broadcasting</Specialisation>
              <Name> Queen Mary </Name>
              <Location> East London </Location>
              <Specialisation> Business and accounting </Specialisation>
           </University>
        </Establishments>
    </Education>
    <Size>
       <Total area> 130,395 km2 </Total <area>
       <Land Area>129,720 kmē </Land Area> 
       <Water Area> 675kmē </Water Area>
       <Highest Point> 978 m </Highest Point>
       <Lowest Point>-4 m </Lowest Point> 
    </Size>
    <Culture>
       <Literature>
           <Poets>
              <First name>William </First name>
              <Sur name>Shakespeare </Sur name>
              <Genre>Shakespearien </Genre>
           </Poets>
           <Novelist>
               <First name>Roald </First name>
              <Sur name>Dahl </Sur name>
              <Genre>Adventure </Genre>
          </Novelist>
       </Literature>
       <Music>
          <Artist>
            <First name>Jessica </First name>
              <Sur name>Cornish </Sur name>
              <Genre>Pop </Genre>
              <Stage name>Jessie J </Stage name>
              <Date of birth>27/03/1988 </Date of birth>
          <Artist>
        </Music>
        <Cinema>
           <Films>
               <Title> Tomb Raider</Title>
               <Genre>Action adventure </Genre>
               <Actors> 
                    <First name> Angelina </First Name>
                    <Sur name> Jolie </Sur name>
                    <Date of birth> 04/06/1975</Date of birth> 
              </Actors> 
           </Films>
        </Cinema>
        <Sports>
        <Type>Football </Type>
            <Teams>A.C Milan </Teams>
                 <players>
                   <first name> David</first name>
                   <sur name> Beckham </sur name>
                   <date of birth> 02/05/1975 </date of birth>
                   <position>Midfielder </position>
                   <number>23 </number>
             </players>
        </Sports>
        <Cuisine>
            <Dishes>Sunday Roast </Dishes>
            <Desert> Apple Crumble</Desert>
            <Drink> Pespi </Drink>
        </Cuisine>
    </Culture>
    
    
    </Country>
    but when i presented my taxonomy, document and schema, i was told that it was flat. Im not quite sure what they meant, they didnt explain themself properly (the lecturer).

    So im kinda confussed as to whats wrong with my document. I would really appreciate it if someone could help me out here.

  2. #2
    Join Date
    Nov 2007
    Posts
    401
    Other than an extra </Country> near the top of the document, the XML is valid.
    "Flat XML" is not necessarily a bad thing, it is simply a term used to describe XML structures like the one you created.

    If you need to create 'Structured XML' instead, check this article which has examples of the same information using both designs. This article appears to have been created for using XML to insert records into a database, but the design concepts are universal:
    http://www.phpunit.de/manual/3.4/en/...tasets.flatxml

    There are free tools available that will convert Flat XML to Structured XML, but I have never used one... e.g., http://freecode.com/projects/fx2sx.
    If the tool works, comparing the original document with the resulting Structured XML may be helpful for you to understand the difference.
    Last edited by nap0leon; 02-15-2012 at 08:26 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

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



Recent Articles