Introducción al XMLDR. H. MANDIROLA
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 1
Agenda XmleXtensible 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
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
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
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
<?xml version=“1.0” ?>
<raíz>
<elemento>
…
</elemento>
</raíz>
<!DOCTYPE raíz[
…
]>
Declaración de XML
Declaración deTipo DTD (data type dictionary)
Opcional
Documento
3 XML formato Estructura básica
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 6
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>
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
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
3 XML formato Estructura básica
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 10
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’
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>
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
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
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>
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>
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
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"?>
5 XML VisualizacionDTD 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
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
5 XML y diccionarios de datos1. 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
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 BrieuxEmail [email protected]
22
ReferenciasIntroducció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
Referenciashttps://msdn.microsoft.com/es-es/library/ms256152%28v=vs.110%29.aspx
https://www.youtube.com/watch?v=FjT453d9_tQ
https://www.youtube.com/watch?v=yuoTCiChzNM
https://www.youtube.com/watch?v=rZAmLBgcUTQ
http://www.xml.com/pub/a/2000/11/29/schemas/part1.html
http://www.hl7.org/documentcenter/public_temp_ABEE86EF-1C23-BA17-0CEEB9D8AD2D181E/wg/ca/asig-cda-tutorial-0304-rishel.pdf
http://xml.coverpages.org/CDA-20040830v3.pdf
http://hl7book.net/index.php?title=CDA
06/04/2015 INTRODUCCIÓN AL XML Y CDA ING. F PORTILLA Y DR. MANDIROLA 24