MathJAXP

Handling Java API for XML Processing with Mathematica

Here is a brief sample output of XML processing with J/Link.

Junzo SATO

July 2001

Copyright (c) 2001, Junzo SATO. All rights reserved.

DOM

[Graphics:Images/MathJAXP_gr_1.gif]
[Graphics:Images/MathJAXP_gr_2.gif]
[Graphics:Images/MathJAXP_gr_3.gif]
[Graphics:Images/MathJAXP_gr_4.gif]
[Graphics:Images/MathJAXP_gr_5.gif]
[Graphics:Images/MathJAXP_gr_6.gif]

Show DOM

[Graphics:Images/MathJAXP_gr_7.gif]
[Graphics:Images/MathJAXP_gr_8.gif]
[Graphics:Images/MathJAXP_gr_9.gif]
[Graphics:Images/MathJAXP_gr_10.gif]
[Graphics:Images/MathJAXP_gr_11.gif]
[Graphics:Images/MathJAXP_gr_12.gif]
[Graphics:Images/MathJAXP_gr_13.gif]
[Graphics:Images/MathJAXP_gr_14.gif]
[Graphics:Images/MathJAXP_gr_15.gif]
[Graphics:Images/MathJAXP_gr_16.gif]
[Graphics:Images/MathJAXP_gr_17.gif]
[Graphics:Images/MathJAXP_gr_18.gif]
[Graphics:Images/MathJAXP_gr_19.gif]
[Graphics:Images/MathJAXP_gr_20.gif]
[Graphics:Images/MathJAXP_gr_21.gif]
[Graphics:Images/MathJAXP_gr_22.gif]
[Graphics:Images/MathJAXP_gr_23.gif]
[Graphics:Images/MathJAXP_gr_24.gif]
[Graphics:Images/MathJAXP_gr_25.gif]
[Graphics:Images/MathJAXP_gr_26.gif]
[Graphics:Images/MathJAXP_gr_27.gif]
[Graphics:Images/MathJAXP_gr_28.gif]
[Graphics:Images/MathJAXP_gr_29.gif]
[Graphics:Images/MathJAXP_gr_30.gif]
[Graphics:Images/MathJAXP_gr_31.gif]

Traverse Node

[Graphics:Images/MathJAXP_gr_32.gif]
[Graphics:Images/MathJAXP_gr_33.gif]
1 0 10 DocumentType
1 1 1 Element...Order xmlns http://www.example.com/myschema.xml
2 3 1 Element...Customer
3 3 1 Element...Name
4 0 3 Text... Bill Buckram
3 7 1 Element...Cardnum
4 0 3 Text... 234 234 234 234
2 7 1 Element...Manifest
3 3 1 Element...Item
4 3 1 Element...ID
5 0 3 Text... 209
4 7 1 Element...Title
5 0 3 Text... \n\t\tDuke: A Biography of the Java Evangelist\n\t    
4 11 1 Element...Quantity
5 0 3 Text... 1
4 15 1 Element...UnitPrice
5 0 3 Text... $10.75
3 7 1 Element...Item
4 3 1 Element...ID
5 0 3 Text... 208
4 7 1 Element...Title
5 0 3 Text... \n\t\t100% Pure: Making Cross Platform Deployment a Reality\n\t    
4 11 1 Element...Quantity
5 0 3 Text... 1
4 15 1 Element...UnitPrice
5 0 3 Text... $10.75
3 11 1 Element...Item
4 3 1 Element...ID
5 0 3 Text... 204
4 7 1 Element...Title
5 0 3 Text... \n\t\tMaking the Transition from C++ to the Java(tm) Language\n\t    
4 11 1 Element...Quantity
5 0 3 Text... 1
4 15 1 Element...UnitPrice
5 0 3 Text... $10.75
3 15 1 Element...Item
4 3 1 Element...ID
5 0 3 Text... 202
4 7 1 Element...Title
5 0 3 Text... Web Servers for Fun and Profit
4 11 1 Element...Quantity
5 0 3 Text... 1
4 15 1 Element...UnitPrice
5 0 3 Text... $10.75
3 19 1 Element...Item
4 3 1 Element...ID
5 0 3 Text... 210
4 7 1 Element...Title
5 0 3 Text... \n\t\tI Think Not: Dukes Likeness to the Federation Insignia\n\t    
4 11 1 Element...Quantity
5 0 3 Text... 1
4 15 1 Element...UnitPrice
5 0 3 Text... $10.75
2 11 1 Element...Receipt
3 3 1 Element...Subtotal
4 0 3 Text... $53.75
3 7 1 Element...Tax
4 0 3 Text... $4.43
3 11 1 Element...Total
4 0 3 Text... $58.18

Create XML

document

New XmlDocument object is created in the memory.

[Graphics:Images/MathJAXP_gr_34.gif]
[Graphics:Images/MathJAXP_gr_35.gif]
[Graphics:Images/MathJAXP_gr_36.gif]
[Graphics:Images/MathJAXP_gr_37.gif]
comment: <!--Comment String-->

GetDate[] returns canonical string representation of the date.

[Graphics:Images/MathJAXP_gr_38.gif]
[Graphics:Images/MathJAXP_gr_39.gif]
[Graphics:Images/MathJAXP_gr_40.gif]

Create a comment node in the XML document.

[Graphics:Images/MathJAXP_gr_41.gif]
[Graphics:Images/MathJAXP_gr_42.gif]
[Graphics:Images/MathJAXP_gr_43.gif]
root
[Graphics:Images/MathJAXP_gr_44.gif]
[Graphics:Images/MathJAXP_gr_45.gif]
[Graphics:Images/MathJAXP_gr_46.gif]
element

<name />

[Graphics:Images/MathJAXP_gr_47.gif]
[Graphics:Images/MathJAXP_gr_48.gif]

<name>text</name>

[Graphics:Images/MathJAXP_gr_49.gif]
[Graphics:Images/MathJAXP_gr_50.gif]
Write to file
[Graphics:Images/MathJAXP_gr_51.gif]
[Graphics:Images/MathJAXP_gr_52.gif]
[Graphics:Images/MathJAXP_gr_53.gif]
[Graphics:Images/MathJAXP_gr_54.gif]

Variations of encoding are "Shift_JIS", "UTF-8", "UTF-16", "MS932", etc. System.getProperty("file.encoding") is also valid.

[Graphics:Images/MathJAXP_gr_55.gif]
[Graphics:Images/MathJAXP_gr_56.gif]

CSV

[Graphics:Images/MathJAXP_gr_57.gif]
[Graphics:Images/MathJAXP_gr_58.gif]
[Graphics:Images/MathJAXP_gr_59.gif]
[Graphics:Images/MathJAXP_gr_60.gif]
[Graphics:Images/MathJAXP_gr_61.gif]
[Graphics:Images/MathJAXP_gr_62.gif]

The parseCSV[] returns a matrix of strings in a CSV file. The user should be aware that this method reads entire records into the memory.

[Graphics:Images/MathJAXP_gr_63.gif]
[Graphics:Images/MathJAXP_gr_64.gif]
[Graphics:Images/MathJAXP_gr_65.gif]
[Graphics:Images/MathJAXP_gr_66.gif]
[Graphics:Images/MathJAXP_gr_67.gif]
[Graphics:Images/MathJAXP_gr_68.gif]
[Graphics:Images/MathJAXP_gr_69.gif]
[Graphics:Images/MathJAXP_gr_70.gif]
[Graphics:Images/MathJAXP_gr_71.gif]

Quit

[Graphics:Images/MathJAXP_gr_72.gif]
[Graphics:Images/MathJAXP_gr_73.gif]
[Graphics:Images/MathJAXP_gr_74.gif]


Converted by Mathematica      August 10, 2001