xml and svg from pql by dave doulton computing services university of southampton

20
XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

Upload: herbert-phillips

Post on 05-Jan-2016

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

XML and SVG from PQL

By Dave Doulton

Computing Services

University of Southampton

Page 2: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

XML and SVG

• This presentation only covers a very small but usable subset of what can be done with XML and SVG.

• Further details available from Professional XML 2nd Edition (Wrox) 1267 pages.

Page 3: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

Outline

• What is XML?

• What use is it?

• How do I generate it?

• What is SVG?

• How do I generate it?

Page 4: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

What is XML

• XML is eXtensible Markup Language

• It is a way of marking up data to impose some structure.

• It is hierarchical in nature and uses tags similar to HTML

Page 5: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

What is XML

• Basically data is divided up in a tree structure with tags defining the levels in the tree.

• There must be one root to the tree.

• An example of an outline tree for the company database would be

Page 6: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

Example XML

• <COMPANY>• <CASE>• <EMPLOYEE>• </EMPLOYEE>• <OCCUP>• </OCCUP>• <REVIEW>• <REVIEW>• </CASE>• </COMPANY>

Page 7: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

Where does the data go?

• Each of the sub levels can have attributes or further sublevels.

• Each sublevel must be uniquely named or have a unique set of attributes.

• So for the case level there must be an attribute as there is more than 1 case.

Page 8: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

Example data

• <case id=1>• <employee>• <name>• John D Jones• </name>• <gender>• 1• </gender> • …. Etc• </employee>

Page 9: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

An alternative

• <case id=1>

• <employee name=“John D Jones” gender=“1” … >

• </employee>

Page 10: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

An alternative

• <case id=1>

• <employee name=“John D Jones” gender=“1” … / >

• if there is no data between tags, the opening tag can be closed with a /> instead

Page 11: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

What use is it?

• It is an advancement on other data interchange methods as there are no problems associated with parsing it. With comma delimited there are problems with commas and quotes in the data and also with missing columns.

Page 12: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

What use is it?

• Due to the syntax the only problems can be with < > & ‘ and “

• These are replaced in data with &gt; &lt; &amp; &apos; and &quot;

• All data is treated as text.

Page 13: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

What use is it?

Given the scope of the syntax there are more and more tools becoming available to use XML. So it becomes a natural means for exporting and importing data between programs. As we shall see even between SIR and the web browser and plugins in the web browser.

Page 14: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

What use is it?

• To use it effectively there needs to be something to read it and manipulate it.

• One such application is XSL (eXtensible Style Language)

• Another is SVG (Scalable Vector Graphics)

Page 15: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

What use is it?

• See

http://www.soton.ac.uk/~sug/conf2002/xsldemo.html

• Some of the content is an example from Microsoft ™ of varying the style for the same content.

Page 16: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

How do I generate it?

• To generate XML you basically just write text to a file.

• However there is the need for some extra XML to state that the content is XML.

• In PQL there is the added problem of XML looking like global variables.

Page 17: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

How do I generate it?

• A simple way to generate it in PQL is to write the start and end of the tag separately

• Write ‘<employee’ ‘>’

• Or

• write [‘<employee’+’>’]

Page 18: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

What is SVG ?

• SVG is Scalable Vector Graphics.

• It is an xml document that contains data that is a set of drawing instructions. When viewed with an svgviewer plugin it produces scalable drawings.

• These can be text, graphs or diagrams.

Page 19: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

What is SVG?

• It can also be used with CSS or cascading style sheets to control aspects of the display.

• See http://www.soton.ac.uk/~sug/conf2002/svgdemo.html

• Get the SVG plugin from http://www.adobe.com/svg/viewer/install/main.html

Page 20: XML and SVG from PQL By Dave Doulton Computing Services University of Southampton

Conclusion

• XML and SVG are relatively easy to use.

• They allow useful data display and/or transfer capabilities.

• Well worth investigating.