Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: XML structure

  1. #1
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts

    XML structure

    deciding on the structure of an XML document is prooving difficult for me.... I want an easy to parse representation of the following array for example

    (sorry its long)

    I have come up with several different representations of the below array - all valid in one respect or another, are there any hard and fast rules that would help me in structuring an XML document keeping the logic of the array obvious and usable ? - or is it a case of whatever works for me ?? (in which case I dont see the point) -

    PHP Code:
    <?
    $b_frames
    =array(
        
    $dev_frame=array(
            
    name=>'dev_frame',
            
    title=>'phpdev5',
            
    dev_start=>array('dev_start','','start','forg.xpm','HORZ','start phpdev','dev5_start',''),
            
    dev_stop=>array('dev_stop','','start','forg.xpm','HORZ','shutdown phpdev','dev5_stop',''),
            
    dev_configure=>array('dev_configure','','start','forg.xpm','HORZ','phpdev installation options','run_exe','..\install.bat')
        ),
        
    $ap_frame=array(
            
    name=>'ap_frame',
            
    title=>'apache',
            
    ap_start=>array('ap_start','','start','forg.xpm','HORZ','start the apache server','apache_start',''),
            
    ap_stop=>array('ap_stop','','start','forg.xpm','HORZ','stop the apache server','apache_stop',''),
            
    ap_restart=>array('ap_restart','','start','forg.xpm','HORZ','restart the apache server','apache_restart',''),
            
    ap_swap=>array('ap_swap','','start','forg.xpm','HORZ','swap default apache installation','apache_swap',''),
            
    ap_install=>array('ap_install','','start','forg.xpm','HORZ','install apache as a windows service','apache_install',''),
            
    ap_uninstall=>array('ap_uninstall','','start','forg.xpm','HORZ','uninstall the apache service','apache_uninstall','callback,vars,ok'),
            
    ap_test=>array('ap_test','','start','forg.xpm','HORZ','test the apache configuration','apache_test','callback,vars,ok')
            ),
        
    $my_frame=array(
            
    name=>'my_frame',
            
    title=>'mysql',
            
    my_start=>array('my_start','','start','forg.xpm','HORZ','start mysql','mysql_start','callback,vars,ok'),
            
    my_stop=>array('my_stop','','start','forg.xpm','HORZ','stop mysql','mysql_stop','callback,vars,ok'),
            
    my_status=>array('my_status','','start','forg.xpm','HORZ','check MySQL ','my_status','1'),
            
    my_install=>array('my_install','','start','forg.xpm','HORZ','install mysql as a \'service\'','my_install','callback,vars,ok')
            ),
        
    $other_frame=array(
            
    name=>'other_frame',
            
    title=>'other',
            
    analog_but=>array('analog_but','','start','forg.xpm','HORZ','run the php.ini configuration tool','run_exe',ANALOG_PATH),
            
    configure_but=>array('configure_but','','start','forg.xpm','HORZ','tootip','my_echo','callback,vars,ok'),
            
    gtkdev_but=>array('gtkdev_but','','start','forg.xpm','HORZ','gtkdev app browser','my_echo','callback,vars,ok')
            ),
        
    $ute_frame=array(
            
    name=>'ute_frame',
            
    title=>'utilities',
            
    ping_but=>array('ping_but','','start','forg.xpm','HORZ','ping a host','ping',''),
            
    trace_but=>array('trace_but','','start','forg.xpm','HORZ','run a trace against an IP or hostname','tracert',''),
            
    ip_but=>array('ip_but','','start','forg.xpm','HORZ','get your current IP (NT/XP only)','ip_config',''),
            
    who_but=>array('who_but','','start','forg.xpm','HORZ','run a whois query','run_this_whois','')
            )
    );
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    The Netherlands, Baarn, Ut.
    Posts
    4,252
    Thanks
    0
    Thanked 0 Times in 0 Posts
    firepages,

    i'd say each array is a container which holds all the elements within it; when an element is yet another array, it becomes a container which holds... etc, something like (not the whole lot):
    Code:
    <b_frames>
       <dev_frame>
          <name>dev_frame</name>
          <title>phpdev5</title>
          <dev_start>
             <dev_start_element>dev_start</dev_start_element>
             <dev_start_element></dev_start_element>
             <dev_start_element><start</dev_start_element>
             <dev_start_element>forg.xpm</dev_start_element>
             ...
          </dev_start>
       <dev_stop>
          <dev_stop_element>dev_stop</dev_stop_element>
          ...
          </dev_stop>
       </dev_frame>
       ...
    </b_frames>
    Does that make sense?
    Regards,
    Ronald.
    ronaldvanderwijden.com

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    Hi ronaldb66 - yep that makes sense to me, and one of my attempts is in a similar format, I was just wondering if there is a 'right' or more importantly a 'wrong' way to structure the data ?

    i.e. are there any 'no-nos' apart from the basic validity of the XML, in fact are there any rules at all past basic validity?, all the XML stuff I have read lends me to believe not apart from 'known' formats such as RSS/RDF documents and even then these are not always strictly adhered to.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    The Netherlands, Baarn, Ut.
    Posts
    4,252
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Errmmm... i don't really know. On the element-attribute issue i read a statement like "... if it feels like data it should be an element.", and likewise, attributes should be used for meta-data.

    The whole point is identifying atomic data elements and describing the structure in which they relate to one another; i haven't yet found a receipe for that either. Really more a data modelling issue rather then an XML one, i guess.
    Regards,
    Ronald.
    ronaldvanderwijden.com

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I perfer to use attributes opposed to elements. I have made some very large xml files, useing elements the file came out 16MG and useing attributes 2.5MG.

    Code:
    <b_frames>
        <dev_frames>
             <name a="dev_frame" />
             <title a="phpdev5" />
             <dev_start a="dev_start" b="" c="start" d="forg.xpm" />
             <dev_stop a="dev_stop" b="" c="start" d="forg.xpm" />
             <dev_configure a="dev_configure" b="" c="start" d="forg.xpm" />
         </dev_frames>
    </b_frames>
    USA

  • #6
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,459
    Thanks
    1
    Thanked 23 Times in 21 Posts
    May I make a suggestion?

    Perhaps in the midst of building your XML files you should look at XLink. XLink is a W3C standard for creating links between documents (and that doesn't necessarily mean hyperlinks). You could outsource some of the more detailed info to other files and keep one file as a central summary of everything else.

    That would significantly cut down on file sizes to download.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog


  •  

    Posting Permissions

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