x2j is an extension in the 'xml/sax' addon, which allows to
compactly describe XML parsing in a declarative way.

  http://www.jsoftware.com/jwiki/Addons/xml/sax/x2j%20Examples

I hope this will finally overcome the entry barrier for
people to take on using XML with J.

Simple things are really simple; complex are, well, possible.
Just to give you an idea. Say, covert an HTML table to J table.

  <table>
    <tr>
      <td>0 0</td><td>0 1</td><td>0 2</td><td>0 3</td>
    </tr><tr>
      <td>1 0</td><td>1 1</td><td>1 2</td><td>1 3</td>
    </tr><tr>
      <td>2 0</td><td>2 1</td><td>2 2</td><td>2 3</td>
    </tr>
  </table>

Here's all the code with definition and execution:

require 'xml/sax/x2j'
x2jclass 'px2j3'

'Items' x2jDefn
  /   :=  table             : table=: 0 0$0
  tr  :=  table=: table,row : row=: ''
  td  :=  row=: row,<y
)

    process_px2j3_ TESTX2J3
+---+---+---+---+
|0 0|0 1|0 2|0 3|
+---+---+---+---+
|1 0|1 1|1 2|1 3|
+---+---+---+---+
|2 0|2 1|2 2|2 3|
+---+---+---+---+

See the link above for more of exciting examples,
such as nested structures and attributes handling.



      
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to