complete most xml relax ng work.
work on real interface xml
work on python scripts for parsing interface xml
This commit is contained in:
lizhi-rocky
2010-07-08 11:52:50 +08:00
commit d1760bad48
11 changed files with 900 additions and 0 deletions

38
xml/install.xml Normal file
View File

@@ -0,0 +1,38 @@
<?xml version='1.0' encoding='UTF-8'?>
<install>
<serial-number>123456789012</serial-number>
<partition device="/dev/hda1" boot="no" type="primary" id="5" size="101MB"/>
<partition device="/dev/hda2" boot="no" type="primary" id="5" size="101MB"/>
<partition device="/dev/hda3" boot="no" type="primary" id="5" size="203MB"/>
<partition device="/dev/hda4" boot="no" type="extended" id="5" size="9828MB"/>
<partition device="/dev/hda5" boot="no" type="logic" id="5" size="203MB"/>
<partition device="/dev/hda6" boot="no" type="logic" id="5" size="203MB"/>
<partition device="/dev/hdb1" boot="no" type="primary" id="83" size="5004MB"/>
<partition device="/dev/hdb2" boot="no" type="primary" id="82" size="800MB"/>
<partition device="/dev/hdb3" boot="no" type="extended" id="5" size="4431MB"/>
<partition device="/dev/hdb5" boot="no" type="logic" id="83" size="502MB"/>
<raid raid-device="/dev/md0" raid-type="RAID0">
<raw-device>/dev/hda1</raw-device>
<raw-device>/dev/hda2</raw-device>
</raid>
<raid raid-device="/dev/md1" raid-type="RAID5">
<raw-device>/dev/hda3</raw-device>
<raw-device>/dev/hda5</raw-device>
<raw-device>/dev/hda6</raw-device>
</raid>
<mount-point device="/dev/hdb1" directory="/" file-system="ext3"/>
<mount-point device="/dev/hdb5" directory="/usr" file-system="ext2"/>
<network hostname="localhost" configuration="static" ip="192.168.1.25" mask="255.255.255.0" gateway="192.168.1.254" primary_dns="192.168.1.254" secondary_dns="" domain="in.linx"/>
<service name="ssh" start="yes"/>
<group name="base">
<description>base software packages</description>
<including package="acct" type="mandatory" install="yes"/>
</group>
</install>

149
xml/install_ng.xml Normal file
View File

@@ -0,0 +1,149 @@
<?xml version="1.0" encoding="UTF-8" ?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<element name="install">
<ref name="serial-number"/>
<ref name="partitions"/>
<ref name="raids"/>
<ref name="mount-points"/>
<ref name="network"/>
<ref name="services"/>
<ref name="groups"/>
</element>
</start>
<define name="serial-number">
<element name="serial-number">
<text/>
</element>
</define>
<define name="partitions">
<oneOrMore>
<element name="partition">
<attribute name="device"/>
<attribute name="boot">
<ref name="mybool"/>
</attribute>
<attribute name="type">
<choice>
<value>primary</value>
<value>extended</value>
<value>logic</value>
</choice>
</attribute>
<attribute name="id"/>
<attribute name="size"/>
</element>
</oneOrMore>
</define>
<define name="raids">
<zeroOrMore>
<element name="raid">
<attribute name="raid-device"/>
<attribute name="raid-type">
<choice>
<value>RAID0</value>
<value>RAID1</value>
<value>RAID5</value>
</choice>
</attribute>
<oneOrMore>
<element name="raw-device">
<text/>
</element>
</oneOrMore>
</element>
</zeroOrMore>
</define>
<define name="mount-points">
<oneOrMore>
<element name="mount-point">
<attribute name="device"/>
<attribute name="directory"/>
<attribute name="file-system"/>
</element>
</oneOrMore>
</define>
<define name="network">
<element name="network">
<attribute name="hostname"/>
<attribute name="configuration">
<choice>
<value>dynamic</value>
<value>static</value>
</choice>
</attribute>
<optional>
<group>
<attribute name="ip"/>
<attribute name="mask"/>
<attribute name="gateway"/>
<attribute name="primary_dns"/>
<attribute name="secondary_dns"/>
<attribute name="domain"/>
</group>
</optional>
</element>
</define>
<define name="services">
<zeroOrMore>
<element name="service">
<attribute name="name"/>
<attribute name="start">
<ref name="mybool"/>
</attribute>
</element>
</zeroOrMore>
</define>
<define name="groups">
<oneOrMore>
<element name="group">
<attribute name="name"/>
<attribute name="install">
<ref name="mybool"/>
</attribute>
<optional>
<ref name="description"/>
</optional>
<oneOrMore>
<ref name="including"/>
</oneOrMore>
</element>
</oneOrMore>
</define>
<define name="description">
<element name="description">
<text/>
</element>
</define>
<define name="including">
<element name="including">
<attribute name="package"/>
<attribute name="type">
<choice>
<value>mandatory</value>
<value>optional</value>
</choice>
</attribute>
<attribute name="install">
<ref name="mybool"/>
</attribute>
</element>
</define>
<define name="mybool">
<choice>
<value>yes</value>
<value>no</value>
</choice>
</define>
</grammar>

150
xml/interface_ng.xml Normal file
View File

@@ -0,0 +1,150 @@
<?xml version="1.0" encoding="UTF-8" ?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<element name="interface">
<attribute name="base_widget"/>
<attribute name="sequence"/>
<oneOrMore>
<ref name="widget"/>
<zeroOrMore>
<ref name="message"/>
</zeroOrMore>
</oneOrMore>
<oneOrMore>
<ref name="sequence"/>
</oneOrMore>
</element>
</start>
<define name="widget">
<element name="widget">
<attribute name="type"/>
<optional>
<attribute name="name"/>
</optional>
<optional>
<ref name="widget_attribute"/>
</optional>
<interleave>
<optional>
<!-- geometry management is to manage its sons -->
<ref name="geometry_management"/>
</optional>
<optional>
<!-- geometry location is the location inside its parent -->
<ref name="geometry_location"/>
</optional>
</interleave>
<zeroOrMore>
<ref name="widget"/>
</zeroOrMore>
</element>
</define>
<!-- I split widget attributes from attributes added by I. So I
can easily convert add widget attributes into a dict without processing
on special cases -->
<define name="widget_attribute">
<element name="widget_attribute">
<interleave>
<optional>
<attribute name="background"/>
</optional>
<optional>
<attribute name="height"/>
</optional>
<optional>
<attribute name="width"/>
</optional>
<optional>
<attribute name="text"/>
</optional>
<optional>
<attribute name="command"/>
</optional>
<optional>
<attribute name="image"/>
</optional>
<optional>
<attribute name="state"/>
</optional>
</interleave>
</element>
</define>
<define name="geometry_management">
<!-- why choice? because there may be other geometry management-->
<choice>
<element name="grid_management">
<attribute name="rows"/>
<attribute name="columns"/>
<oneOrMore>
<element name="configure">
<choice>
<attribute name="row"/>
<attribute name="column"/>
</choice>
<attribute name="weight"/>
</element>
</oneOrMore>
</element>
</choice>
</define>
<define name="geometry_location">
<!-- why choice? because there may be other geometry location -->
<choice>
<element name="grid_location">
<attribute name="row"/>
<attribute name="column"/>
<interleave>
<optional>
<attribute name="columnspan"/>
</optional>
<optional>
<attribute name="rowspan"/>
</optional>
<optional>
<attribute name="sticky"/>
</optional>
<optional>
<attribute name="padx"/>
</optional>
<optional>
<attribute name="pady"/>
</optional>
</interleave>
</element>
</choice>
</define>
<define name="message">
<element name="message">
<optional>
<attribute name="key"/>
</optional>
<interleave>
<element name="English">
<text/>
</element>
<element name="Chinese">
<text/>
</element>
</interleave>
</element>
</define>
<define name="sequence">
<element name="sequence">
<attribute name="name"/>
<oneOrMore>
<element name="widget">
<attribute name="name"/>
</element>
</oneOrMore>
</element>
</define>
</grammar>

127
xml/interface_t.xml Normal file
View File

@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8" ?>
<interface base_widget='main' sequence='main'>
<!--
column 0 column 1 column 2
____________________________________________________________
row 0 | logo version |
row 1 |____________________________________________________________|
row 2 | |
row 3 | copyright information |
row 4 | quit previous next |
|____________________________________________________________|
-->
<widget type='Frame' name='main'>
<grid_management rows='5' columns='3'>
<configure row='2' weight='1'/>
<configure column='0' weight='1'/>
<configure column='1' weight='3'/>
<configure column='2' weight='1'/>
</grid_management>
<grid_location row='0' column='0' sticky='NSWE'/>
<widget type="Label">
<widget_attribute image='/home/zhi/git/install/graphicalinstall/images/linxlogo.gif'/>
<grid_location row='0' column='0' sticky='W' padx='5' pady='5'/>
</widget>
<widget type='Label'>
<widget_attribute text='#os-name'/>
<grid_location row='0' column='2' sticky='E'/>
</widget>
<widget type='Frame'>
<widget_attribute height='3' background='black'/>
<grid_location row='1' column='0' columnspan='3' sticky='WE'/>
</widget>
<widget type='Label'>
<widget_attribute text='Copyright'/>
<grid_location row='3' column='0' columnspan='3' pady='20'/>
</widget>
<widget type='Button'>
<widget_attribute text='quit' command='quit'/>
<grid_location row='4' column='0'/>
</widget>
<widget type='Button'>
<widget_attribute text='previous' command='previous'/>
<grid_location row='4' column='1'/>
</widget>
<widget type='Button'>
<widget_attribute text='next' command='next'/>
<grid_location row='4' column='2' pady='20'/>
</widget>
</widget>
<message key='#os-name'>
<English>Rocky 4.2</English>
<Chinese>磐石 4.2</Chinese>
</message>
<message>
<English>Copyright</English>
<Chinese>版权</Chinese>
</message>
<!--
column 0 column 1 column 2
____________________________________________________________
row 0 | |
row 1 | |
row 2 | Welcome to Rocky OS |
row 3 | |
row 4 | |
|____________________________________________________________|
-->
<widget type='Label' name='welcome'>
<widget_attribute text='Welcome'/>
<grid_location row='2' column='0' columnspan='3'/>
</widget>
<!--
column 0 column 1 column 2
____________________________________________________________
row 0 | |
row 1 | |
row 2 | _________ _________________ |
| | text | | serial number | |
| | | | ______________ | |
| | | || | | |
| |_________| ||______________| | |
| |_________________| |
row 3 | |
row 4 | |
|____________________________________________________________|
-->
<widget type='Frame' name='serial_no'>
<grid_management rows='1' columns='3'>
<configure row='0' weight='1'/>
<configure column='0' weight='1'/>
<configure column='1' weight='1'/>
<configure column='2' weight='1'/>
</grid_management>
<grid_location row='2' column='0' columnspan='3' sticky='NSWE'/>
<widget type='Text'>
<widget_attribute width='40' height='15' state='disabled'/>
<grid_location row='0' column='0'/>
</widget>
<widget type='Frame'>
<grid_location row='0' column='1'/>
<widget type='Label'>
<widget_attribute text='serial number'/>
<grid_location row='0' column='0' sticky='W'/>
</widget>
<widget type='Entry'>
<widget_attribute width='12'/>
<grid_location row='1' column='0'/>
</widget>
</widget>
</widget>
<sequence name='main'>
<widget name='welcome'/>
<widget name='serial_no'/>
</sequence>
</interface>