Post on 01-Jan-2016
description
XML
Programación web
• XML stands for eXtensible Markup Language.• XML is designed to transport and store data.• XML is important to know, and very easy to
learn.
Qué es XML?
• Archivos Planos• Archivos Separados por
caracteres especiales Pipes (|), comas (,), etc.
Transferencia de Archivos
• web.xml• faces-config.xml• hibernate.xml• applicationContext.xml• Ant (Automatización de • pruebas)
Archivos de configuración
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<display-name>Servlet de ejemplo</display-name> <description> Hola Mundo Servlet </description>
<!-- Publicamos nuestro servlet aqui -->
<servlet> <servlet-name>HWServlet</servlet-name> <servlet-class>com.softtek.servlet.ejemplos.HelloWorldServlet</servlet-class> </servlet>
<servlet-mapping> <servlet-name>HWServlet</servlet-name> <url-pattern>/HelloWorldServlet</url-pattern> </servlet-mapping>
<!-- Fin de la publicacion de servlets -->
</web-app>
Web.xml J2EE JspServlets Project
Web Services
Intercambio de datos entre diferentes plataformas
XML
<?xml version="1.0" encoding="UTF-8"?><note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body></note>
Ejemplo 1. Nota.
<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>
Ejemplo 2. Bookstore
• <bookstore> <book-category="COOKING">
<book> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price>
• </book>
<book> <title lang="en">Everyday Spanish Food</title> <author>Giada De Laurentiis</author> <year>2012</year> <price>60.00</price>
• </book>– </book-cateogory>
• </bookstore>
Ejemplo 3.- Bookstore 2 (multiples elementos).
• An XML document with correct syntax is called "Well Formed".
• An XML document validated against a DTD is "Well Formed" and "Valid".
Note.dtd
<!DOCTYPE note
[
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
XML DTD