Login Login
MORE

WIDGETS

Widgets

Wanted articles
Who is online?
Article tools

XML

From Aino Wiki

Jump to: navigation, search

Teoria

Da [w3schools]

DTD

DTD stà per Document Type Definition. Definisce la struttura e gli elementi ed attributi consentiti in un documento XML. Può essere definito internamente ad un XML oppure su un file esterno. XML:

<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>

Associato DTD (file note.dtd):

<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
  • PCDATA (parsed character data) is text that WILL be parsed by a parser. The text will be examined by the parser for entities and markup.
  • CDATA (character data) is text that will NOT be parsed by a parser.

XSD

Stà per XML Schema Definition, sostituisce il vecchio DTD.
www.liquid-technologies.com
Formalmente descrive cos'è richiesto che un documento XML possa contenere così come uno database schema fa con i dati che un database può contenere. XSD è simile al DTD e quindi definisce struttura degli elementi, tipi di dati contenuti, regole, vincoli etc.

Esempi

<?xml version="1.0" encoding="UTF-8"?>
<Email>
  <to>Sugo al ragu</to>
  <from>Pizzocchero</from>
  <intestazione>Reminder</intestazione>
  <body>Studiare latino</body>
</Email>

XML Tips

Testo speciale

Usando CDATA (Character DATA) per evitare la scansione del parser XML. Quindi il testo in sezioni marcate con CDATA saranno ignorate dal parser

Testo con caratteri come le parentesi angolari "<" oppure "&" sono illegali negli elementi XML, si potrebbero rappresentare con caratteri di Escape rendendo illegibile il testo. Una sezione CDATA inizia con "<![CDATA[" e finisce con "]]>":

Far riferimento a [[1]]

<?xml version="1.0"?>
<root>
   <![CDATA[
Within this Character Data block I can
use double dashes as much as I want (along with <, &, ', and ")
*and* %MyParamEntity; will be expanded to the text
"Has been expanded" ... however, I can't use
the CEND sequence. If I need to use CEND I must escape one of the
brackets or the greater-than sign using concatenated CDATA sections.
]]>
</root>

Mappa e Link


Linguaggi di MarkUp


HTML |


Parole chiave:

Author