XML Prev
XML Prev
<catalog>
<MotorBike>
<make> Bajaj </make>
<model> Pulsar 180 </model>
<year>3</year>
<color>Black</color>
<engine>
<engine-number>456</engine-number>
<cylinders-number>20</cylinders-number>
<fuel-type> premium</fuel-type>
</engine>
<chasis-number>34324</chasis-number>
<accessories disc-brake=yes auto-start=yes radio=no/>
<motorbike>
</catalog>
Differences between SAX and DOM parsers
SAX
1)import javax.xml.parsers.*;
Import org.xml.sax.*;
Import
org.xml.sax.helpers.*;
2)Parses node by node
DOM
1)import javax.xml.parsers.*;
Import org.w3c.dom.*;
2)Stores the entire XML
document into memory
before processing
3)Occupies more memory
ii.
iii.
iv.
XML schema use basic XML syntax XML schemas are created by using
XML syntax whereas DTDs use separate syntax. The creation and learning
time of DTD syntax is more compared to XML schema .Some XML
technologies such as Extensible Stylesheet Language
Transformations(XSLT ) are used with XML schemas, whereas XSLTs are not
allowed to work with DTDs.
XML schema support namespace XML schemas support namespace
functionality, but DTDs doesnt support this functionality completely.XML
schema helps in defining the vocabularies that use namespace
declarations. They also allow the usage of multiple namespaces in XML
documents with less rigidity. For example, while designing an XML schema
the prefixes of namespace are not required since the end-user to decide it.
But, in DTDs the namespace prefixes are essential to be specified.
XML schema allow the validation of text elements based on
datatypes XML schemas specify the type of textual data that can be used
within attributes and elements. This is done by the simple type
declarations .For example, by the usage of these types , one can specify
that an element may include only data values, positive number or certain
range of numbers. Hence XML schemas can control the documents more
rigidly. The most important feature of XML schemas is that , it include the
commonly used simple types
XML schema allows the creation of complex and reusable content
models easily In a DTD , content model can be reused only when the
utilization of parameter entities is allowed . But , this may lead to some
situations where the parts of DTD are difficult to be reusable. XML
schemas provide a wide variety of mechanisms to reuse the content
models and also model some complex programming concepts easily.