1 / 17

XML for Scientific Applications

XML for Scientific Applications. Marlon Pierce ERDC Tutorial August 16 2001. What is XML?. Standard rule set for defining custom tags. Make your (meta)data human-readable. Separate data content from presentation (XSL). Rules for a particular dialect defined in either DTD or Schema.

walkerk
Télécharger la présentation

XML for Scientific Applications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML for Scientific Applications Marlon Pierce ERDC Tutorial August 16 2001

  2. What is XML? • Standard rule set for defining custom tags. • Make your (meta)data human-readable. • Separate data content from presentation (XSL). • Rules for a particular dialect defined in either DTD or Schema. • W3C: Standards Making Body • Same people that produced HTML. • See http://www.w3c.org

  3. XML for E&M Input Data

  4. Ex: XML for Electricity and Magnetism <?xml version="1.0"?> <!DOCTYPE ProjectDesc SYSTEM "GridViewer.dtd"> <ProjectDesc> <GridData> <NumberOfMaterials>2</NumberOfMaterials> <GridDimensions> Tags omitted for brevity </GridDimensions> <DataFile> <FileName>balloon.dat</FileName> <FileType>ASCII</FileType> <FileFormat>P3D</FileFormat> <Compression>none</Compression> </DataFile> </GridData> …Tags omitted for brevity… </ProjectDesc>

  5. EX: E&M DTD Fragment <!ELEMENT ProjectDesc (GridData,MaterialList)> <!ELEMENT GridData (GridDimensions,DataFile)> <!ELEMENT GridDimensions (X,Y,Z)> Cut for brevity. <!ELEMENT DataFile (FileName,FileType,FileFormat,Compression)> <!ELEMENT FileName (#PCDATA)> <!ELEMENT FileType (#PCDATA)> <!ELEMENT FileFormat (#PCDATA)> <!ELEMENT Compression (#PCDATA)> <!ELEMENT MaterialList (Material+)> <!ELEMENT Material (Name,Color,Epsilon*,Mu*,Sigma*,Mag*)>

  6. What the DTD Tells You • What tags can be included • Parent/child relationships • The number of allowed tags of a particular type • 1 only, 0 or 1, 0 or more, 1 or more. • Names of attributes • If the tag takes parsable character data

  7. Ex: E&M Schema Fragment <schema> <element name="ProjectDesc" type="ProjectDescType"/> <complexType name="ProjectDescType"> <element name="GridData" type="GridDataType"/> <element name="MaterialList" type="MatListType"/> <complextType> <complexType name="GridDataType"> <element name="NumberOfMaterials type="int"/> <element name="GridDimensions" type="GridDimType"/> <element name="DataFile" type="DataFileType"/> </complexType> ….</schema>

  8. Schema v. DTD(a partial list) • Schemas are in XML; DTDs are not. • Schemas have several simple types (integers, strings, floats, …); DTDs treat everything as character data. • Schema complex types support inheritance • Bee complex type can be extended by drone, queen, worker subtypes. • But DTDs have been around longer.

  9. Now What? • Get a parser for your favorite language • Apache XML Project’s Xerces parser supports Java, C++, Perl • http://xml.apache.org • Write code using the parser: • Validates XML files. • Returns the DOM. • You can now navigate the XML document tree

  10. Document Object Model • Defines general entities that make up the document. • Forms a tree • Objects include • Document • Node • Element • Attribute ProjectDesc GridData MaterialList

  11. Practical Drawbacks • The DOM classes are very general. They only provide you with the most general way of navigating the tree. • Typically for every XML dialect you create, you will have to write new code to extract the information. • It would be nice if there was a better way to do this….

  12. Automatic JavaBeans with Castor • XML trees map nicely into Java Bean components. Get/Set methods return the information. • Castor: automatically generates JavaBeans from XML and vice versa. • You just write the Bean classes (simple) and Castor handles the mapping to XML. • http://castor.exolabs.org

  13. Some Standard XML Dialects • Don’t reinvent what already exists. See http://www.w3c.org/TR • MathML • ChemistryML • SVG: Scalable Vector Graphics • SOAP: Simple Object Access Protocol • RDF: Resource Description Framework

  14. Scientific Visualization with SVG

  15. XML Namespaces • Namespaces allow you to mix different types of XML. • You can combine custom and standard tags • Ex: combine GEMML plus MathML

  16. Namespace Example <gem xmlns:gem="http://www.gem.org/gem" xmlns:m="http://www.w3c.org/TR/REC-MathML/"> <gem:analysis> <m:math> <!-- MathML expressions --> </m:math> <!-- GEM analysis content --> </gem:analysis> </gem>

  17. Additional References and Resources • Inside XML by Steven Holzner. New Riders (2001). • The W3C has a nice schema tutorial at www.w3.org/TR/xmlschema-0/ • The ARL ICE project mixes XML and HDF5: www.arl.hpc.mil/ice/XdmfUser.html • XSIL is a markup language for scientific data: www.cacr.caltech.edu/SDA/xsil

More Related