Monday, April 17, 2017

XML and JSON


How is XML different from HTML?

The eXtensible Markup Language (XML) describes the content in terms of what data is being described rather than how it’s to be displayed. Instead of being locked into standard tags and formats for data, users can build their own markup languages to accommodate particular data formats and needs.
For example, say you want to capture a credit card number.

In HTML, the paragraph tags (<p> and </p>) are used to define text and numeric elements. Almost any text or graphic can fall between these tags and be treated as a paragraph. The HTML code could appear as:

<p>1234567890123456</p>

The browser will interpret the data contained within the
<p> and </p> tags as a separate paragraph. However, the paragraph tags tell us nothing about the data contained within them. A better approach lies in creating tags that actually describe the data contained within them. Using XML we could create a “credit card number” tag that’s used exclusively for credit card data:
 <credit_card_number>1234567890123456
</credit_card_number>

In addition, HTML tags don’t provide any methodology for data validation. If we needed a tag for an age field, we know a person’s age can only be between 0 and 120, but any data may be inserted between <p> and </p> tags. How would we know if the age was valid? XML schema diagrams (XSDs) allows you to specify all kinds of data validation for a specific XML tag. An XSD schema definition that restricts age to be in the range 0, 120 would read:

<xs:simpleType name= “age”>
 <xs:restriction base=“xs:integer”>
 <xs:minInclusive value=“0”/>
 <xs:maxInclusive value=“120”/>
 </xs:restriction>
</xs:simpleType>

Key stretching - explicação

Você pode fazer uma chave fraca se tornar mais forte ao executar múltiplos processos para a mesma chave. Por exemplo, você pode ter uma se...