[gTrouble] We have parsing!



Hi developers, hello hackers,

I guess most of you saw the gTrouble thread on the gnome-list. I have
not been idle. I've started to put together some crude code to
demonstrate my intentions in this matter, and to help me see how the
xml must be formed. This has been a useful evening. I now have a much
better idea of how the xml 'guide' files will look.

For your persusal, I have checked in to CVS a module called gtrouble.
I don't like the name, but this is not the final product, it is a
little test-rig to use to develop the syntax.

All it does now is read the xml in the format show below, parse it, 
and build the structure of the guide, then print it out in plain text
to you.  You can see what's already there, the thing should compile
without any warnings. Make sure you run it from the source dir, as 
that's where it expects to find the test.xml file.

(And the thing doesn't yet grok the choices or tests, Its pretty late in
the UK now, so I'll implement these functions tomorrow).

There are many naughty bits in the code, like where I have
questions[100] instead of a nice malloc, but I think I did ok for 3
hours work. I'll tidy this stuff up after I've touched base with you
guys to make sure I'm not barking up the wrong tree.

If you think the source code is untidy, you should see my flat.

The test.xml file is included here, as I have refined the syntax
loads, and would like some feedback. The example is highly basic
(there are only questions, but no answers - not ideal, but you can see
from the questions what format answers will have). (An answer can be
another question, if you see what I mean).

Let me know if I'm on the right track here folks...

Its late, I'm going to bed :)


<?xml version="1.0"?>
<guide:Guide xmlns:guide="http://www.gnome.org/guide-spec-location">
  <guide:Guides>

    <guide:Guide ID="gnome-ppp-troubleshooting-mk1">
      <guide:Application>gnome-ppp</guide:Application>
      <guide:Category>Troubleshooting</guide:Category>
      <guide:Intro>Welcome to this test guide. I hope it effectively
      demonstrates my intentions (and doesn't suck)</guide:Intro>
      <guide:Status>Open</guide:Status>
      <guide:Modified>Sat, 25 Sep 1999 20:27:45</guide:Modified>

<guide:Questions>

    <guide:Question ref="is_modem_connected">
        <guide:Qtext>
            Is your modem correctly connected?
        </guide:Qtext>
        <guide:Choices>
	<guide:Choice value="Yes" action="Q_next">
	Yes
	</guide:Choice>
        <guide:Choice value="No" action="goto_page" target="connect_modem">
	No
	</guide:Choice>
        </guide:Choices>
        <guide:TellMe>
            Test this by examining the connections at the back of your
            modem (if it is external). This is a simple example, so that's
            as far as I go
        </guide:TellMe>
        <guide:Test lang="perl" ifposchoice="Yes" ifnegchoice="No">
            <guide:Testtext>
	    This can be tested for you if you wish...
            </guide:Testtext>
            <guide:Testscript>
             open dev, "/dev/ttyS0" ||
             open dev, "/dev/ttyS1" ||
             return "NODE:Could not open any modem device";
            </guide:Testscript>
	    </guide:Test>
    </guide:Question>

    <guide:Question ref="modem_type">
        <guide:Qtext>
            What kind of modem is installed in your machine?
        </guide:Qtext>
	<guide:Choices>
        <guide:Choice value="int_isa" action="Q_next">
	Internal ISA
	</guide:Choice>
        <guide:Choice value="int_pci" action="goto_page" target="UhOh-Winmodem">
	Internal PCI
	</guide:Choice>
        <guide:Choice value="ext_ser" action="Q_next">
	External Serial
	</guide:Choice>
        <guide:Choice value="pcmia" action="goto_page" target="PCMIA_modem">
	Internal PCMIA
	</guide:Choice>
        <guide:Choice value="other" action="Q_next">
	Other (or don't know)
	</guide:Choice>
	</guide:Choices>
        <guide:TellMe>
            How to tell what type of modem you have... Blah, blah.
        </guide:TellMe>
    </guide:Question>

    <guide:Question ref="pppd_installed">
        <guide:Qtext>
            Is pppd installed on your machine?
        </guide:Qtext>
	<guide:Choices>
        <guide:Choice value="yes" action="Q_next">
	Yes
	</guide:Choice>
        <guide:Choice value="no" action="goto_page" target="install_pppd">
	No
	</guide:Choice>
	</guide:Choices>
        <guide:TellMe>
            Type pppd --version, and see if you get any output. If you
            have a redhat system, you can query the ppp rpm using rpm -V ppp
        </guide:TellMe>
        <guide:Test lang="sh" ifposchoice="Yes" ifnegchoice="No">
            <guide:Testtext>
            This can be automatically tested for you if you wish. The Test
	    will fail if you have a peculiar pppd install, but then you'd
	    probably know about it!
            </guide:Testtext>
	    <guide:Testscript>
	    which pppd || ls /usr/sbin/pppd || ls /sbin/pppd
	    </guide:Testscript>
        </guide:Test>
    </guide:Question>
</guide:Questions>

      <guide:Developers>
        <guide:Developer>
        <guide:Person>Miguel de Icaza</guide:Person>
        <guide:Email>miguel@gnu.org</guide:Email>
        <guide:Company>
        </guide:Company>
        <guide:Organisation>
        </guide:Organisation>
        <guide:Webpage></guide:Webpage>
        <guide:Snailmail>
        </guide:Snailmail>
        <guide:Phone>
        </guide:Phone>	
        </guide:Developer>
	
        <guide:Developer>
        <guide:Person>Elliot Lee</guide:Person>
        <guide:Email>sopwith@redhat.com</guide:Email>
        <guide:Company>
        </guide:Company>
        <guide:Organisation>
        </guide:Organisation>
        <guide:Webpage></guide:Webpage>
        <guide:Snailmail>
        </guide:Snailmail>
        <guide:Phone>
        </guide:Phone>
        </guide:Developer>
	
	<guide:Developer>
        <guide:Person>David C. Mason</guide:Person>
        <guide:Email>dcm@redhat.com</guide:Email>
        <guide:Company>
        </guide:Company>
        <guide:Organisation>
        </guide:Organisation>
        <guide:Webpage></guide:Webpage>
        <guide:Snailmail>
        </guide:Snailmail>
        <guide:Phone>
        </guide:Phone>
        </guide:Developer>	
      </guide:Developers>

      <guide:Contact>
        <guide:Person>Tom Gilbert</guide:Person>
        <guide:Email>gilbertt@tomgilbert.freeserve.co.uk</guide:Email>
        <guide:Company>
        </guide:Company>
        <guide:Organisation>
        </guide:Organisation>
        <guide:Webpage>www.tomgilbert.freeserve.co.uk</guide:Webpage>
        <guide:Snailmail>
        </guide:Snailmail>
        <guide:Phone>
        </guide:Phone>
      </guide:Contact>
      
    </guide:Guide>

  </guide:Guides>
</guide:Guide>

Tom.
-- 
            .-------------------------------------------------------.
    .^.     | Tom Gilbert, England | tom@tomgilbert.freeserve.co.uk |
    /V\     |----------------------| www.tomgilbert.freeserve.co.uk |
   // \\    | Sites I recommend:   `--------------------------------|
  /(   )\   | www.freshmeat.net www.enlightenment.org www.gnome.org |
   ^^-^^    `-------------------------------------------------------'



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]