Posts

Showing posts with the label XML

Methods for reading XML in Java

Image
DOM (Document Object Model) - object - reads XML, recreating it in memory in the form of an object structure, while the XML document is represented as a set of tags - nodes. Each node can have an unlimited number of child nodes. Each child can also contain several levels of descendants or none at all. Thus, the result is a kind of tree. Pluses: Easy to program. If there are many objects in XML with cross-references to each other, it is enough to go through the document twice: first time create objects without references and fill in the name-object dictionary, the second time - restore links. If an error occurs in XML, a half-created XML structure remains in memory, which will be automatically destroyed. Suitable for both reading and writing. Minuses: Low speed. Wastes a lot of memory. SAX (Simple API for XML) - event-driven - reads an XML document, responding to emerging events (opening or closing tag, string, attribute) by calling the event handlers provided by the appl...

XSD

Image
XSD, XML Schema Definition, XML Schema - a language for describing the structure of an XML document. In particular, XML Schema describes: dictionary - names of elements and attributes; content model - the relationship between elements and attributes, as well as their structure of the document; used data types. The advantages of XSD over DTD are as follows: DTD, unlike XSD, is not XML and has its own syntax. As a result, various problems with encoding and verifying XML documents can arise. When using XSD, the XML parser can check not only the syntax of an XML document, but also its structure, content model, and data types. In XML DTD, there is only one data type - a string, and if, for example, there is text in a numeric field, then the document will still be able to pass verification, since the XML DTD will not be able to check the data type. You cannot map more than one DTD to one XML document. Therefore, a document can be verified with only one DTD description. XSD is exte...

XML, well-formed XML and valid XML

Image
XML, the eXtensible Markup Language, is a language with a simple formal syntax, well suited for creating and manipulating documents with programs, and at the same time easy to read and create documents by humans. XML is extensible, it does not fix the markup used in documents, and the developer is free to create markup in accordance with the needs of a particular area, being limited only by the syntax rules of the language. DTD A DTD, Document Type Definition, is a predefined set of rules that defines the relationships between elements and attributes. For example, the DTD for HTML says that the DIV tag must be inside the BODY tag and can appear multiple times, TITLE - in HEAD and only once, and SCRIPT - both there and there as many times as you want. A DTD is usually described directly in the document as a formulation line starting with <!DOCTYPE ... > or in a separate file. Difference between well-formed XML and valid XML Depending on the level of compliance, the document...