1. Introducción al XML
DR. H. MANDIROLA
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 1
2. Agenda Xml
eXtensible markup language
◦ 1 ¿Qué es el XML?
◦ 2 ¿Cómo se usa XML?
◦ 3 XML formato básico
◦ 4 XML namespaces
◦ 5 XML y diccionarios de datos
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 2
3. 1 ¿Qué es el XML y para que sirve?
¿Qué es el XML?
XML = eXtensible Markup Language
HTML = Hypertext Markup Language
¿Para que sirve?
Para crear documentos estructurados
X ejemplo los CDA
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 3
4. 1 ¿Qué es el XML y para que sirve?
XML no es un reemplazo para HTML
XML es un complemento a HTML.
XML es una herramienta para organizar información.
XML facilita el intercambio y transporte de datos.
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 4
5. 2 ¿Cómo se usa XML?
Editores
ASCII
Editor Estructurado
Editor Especifico para XML
Editor dentro de los lenguajes de programación
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 5
7. Hojas
Ramas
Raiz
3 XML formato Estructura básica
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 7
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
8. 3 XML formato Estructura básica elemento
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 8
<elemento></elemento>
Los nombres de elementos son:
• case-sensitive
• Deben comenzar con una letra o un guión bajo
• No pueden empezar con las letras xml (or XML, or Xml, etc)
• Pueden contener letras, dígitos, guiones, guiones bajos y puntos
• No pueden contener espacios
9. 3 XML formato document básico
<?xml version="1.0" encoding='iso-8859-1' ?>
<micasa>
<habitacion id='comedor'>
<mueble>aparador</mueble>
<mueble>sofá</mueble>
<puerta a='balcón' />
</habitacion>
</micasa>
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 9
Tag o Etiqueta(elemento)
‘atributo’
Declaración
10. 3 XML formato Estructura básica
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 10
11. 3 XML formato Estructura básica
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 11
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
‘atributo’
12. 3 XML formato Estructura básica
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 12
INCORRECTO:
<note date=12/11/2007>
<to>Tove</to>
<from>Jani</from>
</note>
CORRECTO:
<note date="12/11/2007">
<to>Tove</to>
<from>Jani</from>
</note>
13. 4 Cada cosa en su sitio: XML Atributos
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 13
Dan informacion adicional a los elementos, siempre van entre comillas
<img src="computer.gif">
<a href="demo.asp">
<file type="gif">computer.gif</file>
Nombre del atributoelemento
Valor del atributo
14. 4 Cada cosa en su sitio: XML namespaces
<mc:micasa xmlns:mc='http://www.geneura.org/micasa'>
<mc:habitacion mc:id="comedor">
<mc:mueble>aparador</mc:mueble>
<mc:mueble>sofá "de época"</mc:mueble>
</mc:habitacion>
</mc:micasa>
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 14
15. 4 Cada cosa en su sitio: XML namespaces
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 15
Namespace h:
Namespace f:
<root>
<h:table xmlns:h="http://www.w3.org/TR/html4/">
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table xmlns:f="http://www.w3schools.com/furniture">
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
</root>
16. 4 Cada cosa en su sitio: XML namespaces
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 16
<root xmlns:h="http://www.w3.org/TR/html4/"
xmlns:f="http://www.w3schools.com/furniture">
<h:table>
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table>
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
</root>
17. 4 Caracteres Especiales Entidades
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 17
< <
> >
& &
' '
" "
<message>si el salario es < 1000
then</message>
Para evitar errors reemplazar "<" por
la entity reference:
<message>if salary < 1000
then</message>
Cambiar por
Error
18. 5 XML Unicode Transformation Format (UTF)
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 18
UTF-8 uses 1 byte (8-bits) usa un bit paa los caracteres latinos y 2,3 o 4 bits para el resto. ( Este
es el standar en internet).
UTF-16 uses 2 bytes (16 bits) usa 4 caractres para la mayoria.
La primera linea de un Xml se llama prolog:
<?xml version="1.0" encoding="UTF-8"?>
19. 5 XML Visualizacion
DTD is to define the structure of an XML document. It defines the structure with a list of legal
elements
CSS (Cascading Style Sheets)
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 19
20. 5 XML y diccionarios de datos
DTD Data Type Dictionnary
<!ELEMENT habitacion ( mueble+, puerta+ ) >
<!ATTLIST habitacion id NMTOKEN #REQUIRED >
<!ELEMENT micasa ( habitacion+ ) >
<!ELEMENT mueble ( #PCDATA ) >
<!ELEMENT puerta EMPTY >
<!ATTLIST puerta a NMTOKEN #REQUIRED >
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 20
21. 5 XML y diccionarios de datos
1. Schema describe la sintaxis
correcta de un documento XML.
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 21
22. Gracias por su atención
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA
Dr. Humberto Fernán Mandirola Brieux
Email hmandirola@biocom.com
22
23. Referencias
Introducción al lenguaje XML http://geneura.ugr.es/~jmerelo/xml/
http://www.w3schools.com/xml/default.asp
DTD Tutorial http://www.w3schools.com/dtd/dtd_attributes.asp
Stylesheet http://www.w3schools.com/xsl/default.asp
XML - Introducción Jose Emilio Labra Gayo http://www.slideshare.net/jelabra/2-xml
http://www.w3schools.com/
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 23