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

Post on 05-Jan-2016

213 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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.

Outline

• What is XML?

• What use is it?

• How do I generate it?

• What is SVG?

• How do I generate it?

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

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

Example XML

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

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.

Example data

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

An alternative

• <case id=1>

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

• </employee>

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

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.

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.

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.

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)

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.

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.

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’+’>’]

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.

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

Conclusion

• XML and SVG are relatively easy to use.

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

• Well worth investigating.

top related