XML - Estoy en blanco

 
Vista:
sin imagen de perfil

Estoy en blanco

Publicado por Victor (3 intervenciones) el 08/07/2017 09:37:34
Buenos dias.

Estoy haciendo un cursete,es un libro asi que no hay nadie que resuelva las dudas del curso.
La practica es: creación de un documento XML, su correspondiente XML Schema y transformaciones con XSL-T

Tengo 4 ficheros.
El xsd(tengo claro que es el esquema):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
	elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xs:element name="Alojamientos">
		<xs:annotation>
			<xs:documentation>Informacion hoteles</xs:documentation>
		</xs:annotation>
		<xs:complexType>
			<xs:all>
				<xs:element name="Hoteles">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="Hotel" maxOccurs="unbounded">
								<xs:complexType>
									<xs:all>
										<xs:element name="Nombre" type="xs:string" />
										<xs:element name="Localizacion" type="LocalizacionType" />
										<xs:element name="Habitaciones">
											<xs:complexType>
												<xs:all>
													<xs:element name="Dobles">
														<xs:complexType>
															<xs:sequence>
																<xs:element name="Numero" type="xs:int" />
																<xs:element name="Precio" type="xs:float" />
															</xs:sequence>
														</xs:complexType>
													</xs:element>
													<xs:element name="Simples">
														<xs:complexType>
															<xs:sequence>
																<xs:element name="Numero" type="xs:int" />
																<xs:element name="Precio" type="xs:float" />
															</xs:sequence>
														</xs:complexType>
													</xs:element>
												</xs:all>
											</xs:complexType>
										</xs:element>
										<xs:element name="Piscina" type="xs:boolean" />
										<xs:element name="Categoria" type="xs:int" />
									</xs:all>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<xs:element name="Cadenas" minOccurs="0">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="Cadena" maxOccurs="unbounded">
								<xs:complexType>
									<xs:sequence>
										<xs:element name="Nombre" />
										<xs:element name="Localizacion" type="LocalizacionType" />
									</xs:sequence>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
			</xs:all>
		</xs:complexType>
	</xs:element>
	<xs:complexType name="LocalizacionType">
		<xs:all>
			<xs:element name="Pais" />
			<xs:element name="Ciudad" />
			<xs:element name="Region" minOccurs="0" />
		</xs:all>
	</xs:complexType>
</xs:schema>

Un documento con datos de prueba:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="hotelesLibro.xsl"?>
<Alojamientos xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:noNamespaceSchemaLocation="hotelesLibro.xsd">
	<Hoteles>
		<Hotel>
			<Nombre>Hotel Port Aventura</Nombre>
			<Localizacion>
				<Pais>España</Pais>
				<Ciudad>Salou</Ciudad>
				<Region>Costa Dorada</Region>
			</Localizacion>
			<Habitaciones>
				<Dobles>
					<Numero>50</Numero>
					<Precio>133</Precio>
				</Dobles>
				<Simples>
					<Numero>10</Numero>
					<Precio>61</Precio>
				</Simples>
			</Habitaciones>
			<Piscina>false</Piscina>
			<Categoria>3</Categoria>
		</Hotel>
		<Hotel>
			<Nombre>Hotel Arts</Nombre>
			<Localizacion>
				<Pais>España</Pais>
				<Ciudad>Barcelona</Ciudad>
			</Localizacion>
			<Habitaciones>
				<Dobles>
					<Numero>250</Numero>
					<Precio>750</Precio>
				</Dobles>
				<Simples>
					<Numero>50</Numero>
					<Precio>310</Precio>
				</Simples>
			</Habitaciones>
			<Piscina>true</Piscina>
			<Categoria>5</Categoria>
		</Hotel>
		<Hotel>
			<Nombre>Parador Seu d’Urgell</Nombre>
			<Localizacion>
				<Pais>España</Pais>
				<Ciudad>Seu d’Urgell</Ciudad>
				<Region>Pirineo</Region>
			</Localizacion>
			<Habitaciones>
				<Dobles>
					<Numero>40</Numero>
					<Precio>91.5</Precio>
				</Dobles>
				<Simples>
					<Numero>2</Numero>
					<Precio>44.4</Precio>
				</Simples>
			</Habitaciones>
			<Piscina>true</Piscina>
			<Categoria>4</Categoria>
		</Hotel>
	</Hoteles>
	<Cadenas>
		<Cadena>
			<Nombre>HUSA</Nombre>
			<Localizacion>
				<Pais>España</Pais>
				<Ciudad>Barcelona</Ciudad>
			</Localizacion>
		</Cadena>
		<Cadena>
			<Nombre>NH Hoteles</Nombre>
			<Localizacion>
				<Pais>España</Pais>
				<Ciudad>Pamplona</Ciudad>
			</Localizacion>
		</Cadena>
		<Cadena>
			<Nombre>Paradores de Turismo</Nombre>
			<Localizacion>
				<Pais>España</Pais>
				<Ciudad>Madrid</Ciudad>
			</Localizacion>
		</Cadena>
	</Cadenas>
</Alojamientos>

Un documento xsl,aunque en el libro dice que tiene que ser xslt,eclipse PHP no reconoce dicho formato
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8"
		indent="yes" />
	<xsl:template match="Localizacion">
		<xsl:value-of select="Ciudad" />
		,
		<xsl:value-of select="Pais" />
		<xsl:if test="Region ">
			<i>
				(
				<xsl:value-of select="Region" />
				)
			</i>
		</xsl:if>
	</xsl:template>
	<xsl:template match="Hoteles">
		<h1>Lista de Hoteles</h1>
		<xsl:for-each select=".">
			<xsl:apply-templates select="Hotel" />
		</xsl:for-each>
	</xsl:template>
	<xsl:template match="Piscina">
		<xsl:choose>
			<xsl:when test="node() = 'true'">
				<b>Si</b>
			</xsl:when>
			<xsl:otherwise>
				<b>No</b>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="Hotel">
		<h2>Hotel</h2>
		Nombre:
		<xsl:value-of select="Nombre" />
		(Estrellas:
		<xsl:value-of select="Categoria" />
		)
		<br />
		Ubicación:
		<xsl:apply-templates select="Localizacion" />
		<br />
		Piscina:
		<xsl:apply-templates select="Piscina" />
		<br />
		<br />
		<h3>Habitaciones</h3>
		<table>
			<tbody>
				<tr>
					<th>Tipo</th>
					<th>Número</th>
					<th>Precio</th>
				</tr>
				<tr>
					<td>Simples</td>
					<td>
						<xsl:value-of select="Habitaciones/Simples/Numero" />
					</td>
					<td>
						<xsl:value-of select="Habitaciones/Simples/Precio" />
					</td>
				</tr>
				<tr>
					<td>Dobles</td>
					<td>
						<xsl:value-of select="Habitaciones/Dobles/Numero" />
					</td>
					<td>
						<xsl:value-of select="Habitaciones/Dobles/Precio" />
					</td>
				</tr>
			</tbody>
		</table>
	</xsl:template>
	<xsl:template match="Cadena">
		<h2>Cadena</h2>
		Nombre:
		<xsl:value-of select="Nombre" />
		<br />
		Ubicación:
		<xsl:apply-templates select="Localizacion" />
		<br />
	</xsl:template>
	<xsl:template match="Cadenas">
		<h1>Lista de Cadenas hoteleras</h1>
		<xsl:for-each select=".">
			<xsl:apply-templates select="Cadena" />
		</xsl:for-each>
	</xsl:template>
	<xsl:template match="/">
		<html>
			<head>
				<title>Información hotelera</title>
			</head>
			<body>
				<xsl:apply-templates />
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>

Y por ultimo un un listado en xml:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?xml version="1.0" encoding="UTF-8"?>
<html>
	<head>
		<title>Información hotelera</title>
	</head>
	<body>
		<h1>Lista de Hoteles</h1>
		<h2>Hotel</h2>
		Nombre: Hotel Port Aventura (Estrellas: 3)
		<br />
		Ubicación: Salou,
		España
		<i> (Costa Dorada)</i>
		<br />
		Piscina:
		<b>No</b>
		<br />
		<br />
		<h3>Habitaciones</h3>
		<table>
			<tbody>
				<tr>
					<th>Tipo</th>
					<th>Número</th>
					<th>Precio</th>
				</tr>
				<tr>
					<td>Simples</td>
					<td>10</td>
					<td>61</td>
				</tr>
				<tr>
					<td>Dobles</td>
					<td>50</td>
					<td>133</td>
				</tr>
			</tbody>
		</table>
		<h2>Hotel</h2>
		Nombre: Hotel Arts (Estrellas: 5)
		<br />
		Ubicación: Barcelona,
		España
		<br />
		Piscina:
		<b>Si</b>
		<br />
		<br />
		<h3>Habitaciones</h3>
		<table>
			<tbody>
				<tr>
					<th>Tipo</th>
					<th>Número</th>
					<th>Precio</th>
				</tr>
				<tr>
					<td>Simples</td>
					<td>50</td>
					<td>310</td>
				</tr>
				<tr>
					<td>Dobles</td>
					<td>250</td>
					<td>750</td>
				</tr>
			</tbody>
		</table>
		<h2>Hotel</h2>
		Nombre: Parador Seu d’Urgell (Estrellas: 4)
		<br />
		Ubicación: Seu d’Urgell,
		España
		<i> (Pirineo)</i>
		<br />
		Piscina:
		<b>Si</b>
		<br />
		<br />
		<h3>Habitaciones</h3>
		<table>
			<tbody>
				<tr>
					<th>Tipo</th>
					<th>Número</th>
					<th>Precio</th>
				</tr>
				<tr>
					<td>Simples</td>
					<td>2</td>
					<td>44.4</td>
				</tr>
				<tr>
					<td>Dobles</td>
					<td>40</td>
					<td>91.5</td>
				</tr>
			</tbody>
		</table>
		<h1>Lista de Cadenas hoteleras</h1>
		<h2>Cadena</h2>
		Nombre: HUSA
		<br />
		Ubicación: Barcelona,
		España
		<br />
		<h2>Cadena</h2>
		Nombre: NH Hoteles
		<br />
		Ubicación: Pamplona,
		España
		<br />
		<h2>Cadena</h2>
		Nombre: Paradores de Turismo
		<br />
		Ubicación: Madrid,
		España
		<br />
	</body>
</html>

Creo que los ficheros anteriores tienen que hacer efecto en este ultimo,pero no se como.
Alguna idea?
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder