2
0
Fork 0
ff/source/_posts/X4O-Java-xml-library.md

4.2 KiB

title: 'X4O: Java xml library' date: 2015-07-01 19:24:59 tags: - java - x4o

Site: http://www.x4o.org Source: http://git.savannah.gnu.org/cgit/x4o.git Status: Discontinued development

Framework to define your xml languages with full scheme and namespace support.

Small example of parsing a simple example language;

<root:JFrame
	xmlns:root="http://swixml.x4o.org/xml/ns/swixml-root"
	xmlns="http://swixml.x4o.org/xml/ns/swixml-lang"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://test.x4o.org/xml/ns/test-root test-root-1.0.xsd"
	name="mainframe" size="800,600" title="SWIXML-X4O" plaf="com.sun.java.swing.plaf.windows.WindowsLookAndFeel" defaultCloseOperation="3"
	>
	<JMenubar name="menubar">
		<JMenu name="filemenu" text="File">
			<JMenuItem name="mi_new" text="New" icon="icons/new.gif" mnemonic="VK_N" accelerator="control N" Action="newAction"/>
			<JMenuItem name="mi_open" text="Open" icon="icons/open.gif" mnemonic="VK_O" Accelerator="control O" ActionCommand="open"/>
			<JMenuItem name="mi_save" text="Save" icon="icons/save.gif" mnemonic="VK_S" ActionCommand="save"/>
			<JMenu name="propmenu" text="Properties" icon="icons/new.gif" >
				<JMenuItem name="mi_prop_edit" text="Edit" icon="icons/new.gif"/>
				<JMenuItem name="mi_prop_clear" text="Clear" icon="icons/new.gif"/>	
			</JMenu>
			<JMenu.Separator/>
			<JMenuItem name="mi_exit" text="Exit" icon="icons/exit.gif" mnemonic="VK_X" Accelerator="control X" ActionCommand="exit" Action="exitAction"/>
		</JMenu>
		<JMenu text="Help">
			<JMenuItem name="mi_about" text="About" enabled="true" icon="icons/info.gif" Accelerator="alt A" Action="aboutAction" />
		</JMenu>
	</JMenubar>
	<JDesktopPane>
		<JInternalFrame title="Flow Layout (right aligned)" bounds="10,10,150,150" layout="FlowLayout(FlowLayout.RIGHT)" visible="true" resizable="true">
			<JButton text="1"/>
			<JButton text="2"/>
			<JButton text="3"/>
			<JButton text="4"/>
		</JInternalFrame>
		<JInternalFrame title="Grid Layout" bounds="200,10,170,170" layout="GridLayout(4,3)" visible="true" resizable="true">
			<JButton text="1"/><JButton text="2"/><JButton text="3"/>
			<JButton text="4"/><JButton text="5"/><JButton text="6"/>
			<JButton text="7"/><JButton text="8"/><JButton text="9"/>
			<JButton text="*"/><JButton text="0"/><JButton text="#"/>
		</JInternalFrame>
		<JInternalFrame title="Border Layout" bounds="390,10,150,150" layout="borderlayout" visible="true" resizable="true">
			<JButton constraints="BorderLayout.NORTH" text="1"/>
			<JButton constraints="BorderLayout.EAST"  text="2"/>
			<JButton constraints="BorderLayout.SOUTH" text="3"/>
			<JButton constraints="BorderLayout.WEST"  text="4"/>
		</JInternalFrame>
		<JInternalFrame title="Tree Window" bounds="10,170,350,360" layout="borderlayout" visible="true" resizable="true">
			<JPanel layout="borderlayout" constraints="BorderLayout.CENTER">
				<JSplitPane oneTouchExpandable="true" dividerLocation="200">
					<JSplitPane oneTouchExpandable="true" dividerLocation="140" orientation="VERTICAL">
						<JScrollPane background="blue" >
							<JTree name="tree"/>
						</JScrollPane>
						<JPanel layout="borderlayout">
							<JPanel constraints="BorderLayout.NORTH">
								<JButton name="btn_copy" toolTipText="JPanel" enabled="true" borderPainted="false" focusPainted="false" icon="icons/copy.gif" size="24,24"/>
								<JButton name="btn_paste" toolTipText="JJButton" enabled="true" borderPainted="false" focusPainted="false" icon="icons/paste.gif" size="24,24"/>
								<JButton name="btn_cut" toolTipText="JLabel" enabled="true" icon="icons/cut.gif" borderPainted="false" focusPainted="false" size="24,24"/>
							</JPanel>
							<JScrollPane constraints="BorderLayout.CENTER">
								<JTable name="table"/>
							</JScrollPane>
						</JPanel>
					</JSplitPane>
					<JPanel name="preview" border="LoweredBevelBorder">
						<JTextArea name="ta" text="Tree Status Log....." background="red"/>
					</JPanel>
				</JSplitPane>
			</JPanel>
			<JPanel constraints="BorderLayout.SOUTH">
				<JLabel text="Status:"/>
				<JTextField text="OK"/>
			</JPanel>
		</JInternalFrame>
	</JDesktopPane>
</root:JFrame>

X4O swixml example