TechnoBuzz

A Techno Blog, mainly about Java

XML and Java

An XSD refresher:
XMLSchema

Definition (XSD)
– industry standard, platform independent XML Schema Language.

Namespaces

Default Schema Namespace: states that all the elements used within the schema belong to that particular namespace
<schema xmlns=”http://www.w3.org/2001/XMLSchema”&gt;

However, usually in form with a a default prefix:
<xsd:schema xmlns:xs=”http://www.w3.org/2001/XMLSchema”&gt;

More than one namespace may be declared. One may be declared as the default namespace, another as a namespace that will be associated with certain elements :

xmlns:prefix=URI

The targetNamespace attribute defines the namespace for the document instance (the XML document.)

By default only globally declared (top-Level) elements are associated with the targetNamespace attribute. These are elements that are directly descended from the RootElement.

If the targetNamespace attribute is added to the schema element, then the prefix DOES NEED to be added to each and every component of the schema.
To add locally declared attributes to the targetNamespace, add the attributeFormDefault attribute to the schema element and use the value of “qualified.”

Stating form=”unqualified” within an schema’s element declaration will unqualify that element from the namespace.

SAX

SAX Project (old URL)
SAX is the Simple API for
XML. SAX has recently switched over to the SourceForge project infrastructure.
It is a standard for XML parsers. It reads the XML document and sends an event
for each element it encounters. Provides “sequential access” into the xml
document. It is fast, requires little memory. Sax works by callbacks. You call
the parser, its calls the methods that you supply.
– SAXParserFactory factory
= SAXParserFactory factory.newInstance();
– SAXParser saxParser =
factory.NewSAXParser();
– XMLReader parser = saxParser.getXMLReader();

[slides]





DOM

DOM

standard for XML parsers. It reads the entire XML document into memory and

stores it into a tree data structure. Provides “random access” into the xml

document. It is slow, requires huge amounts of memory.

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = factory.newDocumentBuilder();
– Document document
builder.parse(file.xml);
[slides]



XERCES
(named after the Xerces Blue butterfly)

Xerces2 – next generation
of high performance, fully compliant XML parsers in the Apache Xerces family.



[slides] [devshed]






JAXB (Java API for XML Binding)

Generate XML Mapping Code
with JAXB
: “It rapidly generates XML mapping code for you, saving time and
effort, and reducing both costs and risks.



XML
ADVISOR: JAXB: A Foundation for Web Services
:Learn all about the Java Architecture for XML Data Binding and implement
lightweight XML-processing applications using the reference implementation



[slides

Advertisements

July 27, 2004 - Posted by | XML

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: