Diferencia entre revisiones de «XSLT con escenario de ciclos de FP»

De MediaWiki
Ir a la navegación Ir a la búsqueda
 
(No se muestran 8 ediciones intermedias del mismo usuario)
Línea 3: Línea 3:
  
 
= Enunciado =
 
= Enunciado =
−
<div class="toccolours mw-collapsible mw-collapsed" style="width:700px; overflow:auto;">
+
<div class="toccolours mw-collapsible" style="width:700px; overflow:auto;">
 
<syntaxhighlight lang="xml">
 
<syntaxhighlight lang="xml">
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
Línea 35: Línea 35:
 
= A) Sen etiquetas =
 
= A) Sen etiquetas =
  
−
Reultado agardado:
+
Resultado agardado:
 
<syntaxhighlight lang="xml">
 
<syntaxhighlight lang="xml">
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
Línea 45: Línea 45:
  
 
Folla de estilo XSLT:
 
Folla de estilo XSLT:
−
<div class="toccolours mw-collapsible mw-collapsed" style="width:400px; overflow:auto;">
+
<div class="toccolours mw-collapsible mw-collapsed" style="width:700px; overflow:auto;">
 +
<syntaxhighlight lang="xslt">
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
−
<syntaxhighlight lang="xslt">
 
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  
Línea 60: Línea 60:
 
= B) Parágrafos =
 
= B) Parágrafos =
  
−
Reultado agardado:
+
Resultado agardado:
 
<syntaxhighlight lang="html">
 
<syntaxhighlight lang="html">
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
Línea 72: Línea 72:
  
 
Folla de estilo XSLT:
 
Folla de estilo XSLT:
−
<div class="toccolours mw-collapsible mw-collapsed" style="width:400px; overflow:auto;">
+
<div class="toccolours mw-collapsible mw-collapsed" style="width:700px; overflow:auto;">
 +
<syntaxhighlight lang="xslt">
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
Línea 83: Línea 84:
  
 
   <xsl:template match="ciclo">
 
   <xsl:template match="ciclo">
−
     <p><xsl:value-of select="nombre"/></p>
+
     <p><xsl:value-of select="nome"/></p>
 
   </xsl:template>
 
   </xsl:template>
  
 
</xsl:stylesheet>
 
</xsl:stylesheet>
 +
</syntaxhighlight>
 
</div>
 
</div>
  
 
= C) Listaxe =
 
= C) Listaxe =
  
−
Reultado agardado:
+
Resultado agardado:
 
<syntaxhighlight lang="html">
 
<syntaxhighlight lang="html">
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
Línea 105: Línea 107:
  
 
Folla de estilo XSLT:
 
Folla de estilo XSLT:
−
<div class="toccolours mw-collapsible mw-collapsed" style="width:400px; overflow:auto;">
+
<div class="toccolours mw-collapsible mw-collapsed" style="width:700px; overflow:auto;">
 +
<syntaxhighlight lang="xslt">
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
Línea 118: Línea 121:
  
 
   <xsl:template match="ciclo">
 
   <xsl:template match="ciclo">
−
     <li><xsl:value-of select="nombre"/></li>
+
     <li><xsl:value-of select="nome"/></li>
 
   </xsl:template>
 
   </xsl:template>
  
 
</xsl:stylesheet>
 
</xsl:stylesheet>
 +
</syntaxhighlight>
 
</div>
 
</div>
  
Línea 148: Línea 152:
  
 
Folla de estilo XSLT:
 
Folla de estilo XSLT:
−
<div class="toccolours mw-collapsible mw-collapsed" style="width:400px; overflow:auto;">
+
<div class="toccolours mw-collapsible mw-collapsed" style="width:700px; overflow:auto;">
 +
<syntaxhighlight lang="xslt">
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
Línea 163: Línea 168:
 
   <xsl:template match="ciclo">
 
   <xsl:template match="ciclo">
 
     <tr>
 
     <tr>
−
       <td><xsl:value-of select="nombre"/></td>
+
       <td><xsl:value-of select="nome"/></td>
 
     </tr>
 
     </tr>
 
   </xsl:template>
 
   </xsl:template>
  
 
</xsl:stylesheet>
 
</xsl:stylesheet>
 +
</syntaxhighlight>
 
</div>
 
</div>
  
Línea 180: Línea 186:
 
   <table border="1">
 
   <table border="1">
 
   <tr>
 
   <tr>
−
     <th>Nombre del ciclo</th>
+
     <th>Nome do ciclo</th>
−
     <th>Grado</th>
+
     <th>Grao</th>
−
     <th>Año del título</th>
+
     <th>Ano do título</th>
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
Línea 209: Línea 215:
  
 
Folla de estilo XSLT:
 
Folla de estilo XSLT:
−
<div class="toccolours mw-collapsible mw-collapsed" style="width:400px; overflow:auto;">
+
<div class="toccolours mw-collapsible mw-collapsed" style="width:700px; overflow:auto;">
 +
<syntaxhighlight lang="xslt">
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 
   <xsl:strip-space elements="*" />
 
   <xsl:strip-space elements="*" />
  
−
   <xsl:template match="ciclos">
+
   <xsl:template match="cifp">
 
     <html>
 
     <html>
−
    <table border="1">
+
      <h1><xsl:value-of select="@nome" /></h1>
−
      <xsl:apply-templates />
+
      <p>Página web: <a >
−
    </table>
+
        <xsl:attribute name="href">
 +
          <xsl:value-of select="@web" />
 +
        </xsl:attribute>
 +
        <xsl:value-of select="@web" /></a></p>
 +
      <table border="1">
 +
        <tr>
 +
          <th>Nome do ciclo</th>
 +
          <th>Grao</th>
 +
          <th>Ano do título</th>
 +
        </tr>
 +
        <xsl:apply-templates />
 +
      </table>
 
     </html>
 
     </html>
 
   </xsl:template>
 
   </xsl:template>
Línea 224: Línea 242:
 
   <xsl:template match="ciclo">
 
   <xsl:template match="ciclo">
 
     <tr>
 
     <tr>
−
       <td><xsl:value-of select="nombre"/></td>
+
       <td><xsl:value-of select="nome"/></td>
 +
      <td><xsl:value-of select="grao"/></td>
 +
      <td><xsl:value-of select="decretoTitulo/@ano"/></td>
 
     </tr>
 
     </tr>
 
   </xsl:template>
 
   </xsl:template>
  
 
</xsl:stylesheet>
 
</xsl:stylesheet>
 +
</syntaxhighlight>
 
</div>
 
</div>
  
Línea 234: Línea 255:
  
 
= Referencias =
 
= Referencias =
 +
* [https://www.mclibre.org/consultar/xml/ejercicios/xslt-1.html Exercicios] parte do curso [https://www.mclibre.org/consultar/xml/ XML: Lenguaje de marcas]. [https://www.mclibre.org/ Bartolomé Sintes Marco]. Licencia Creative Commons Reconocimiento-CompartirIgual 4.0 Internacional (CC BY-SA 4.0).

Revisión actual del 10:02 14 feb 2023

Dado o siguiente documento XML, escriba as follas de estilo XSLT que devolvan a resposta desexada.

Enunciado

<?xml version="1.0" encoding="UTF-8"?>
<cifp nome="Rodolfo Ucha" web="https://www.cifprodolfoucha.es/" >
  <ciclos>
    <ciclo id="ASIR">
      <nome>Administración de Sistemas Informáticos en Rede</nome>
      <grao>Superior</grao>
      <decretoTitulo ano="2009" />
    </ciclo>
    <ciclo id="DAW">
      <nome>Desenvolvemento de Aplicacións Web</nome>
      <grao>Superior</grao>
      <decretoTitulo ano="2010" />
    </ciclo>
    <ciclo id="DAM">
      <nome>Desenvolvemento de Aplicacións Multiplataforma</nome>
      <grao>Medio</grao>
      <decretoTitulo ano="2010" />
    </ciclo>
    <ciclo id="SMR">
      <nome>Sistemas Microinformáticos e Redes</nome>
      <grao>Medio</grao>
      <decretoTitulo ano="2008" />
    </ciclo>
  </ciclos>
</cifp>

A) Sen etiquetas

Resultado agardado:

<?xml version="1.0" encoding="UTF-8"?>
    Administración de Sistemas Informáticos en Rede
    Desenvolvemento de Aplicacións Web
    Desenvolvemento de Aplicacións Multiplataforma
    Sistemas Microinformáticos e Redes

Folla de estilo XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:template match="ciclo">
     <xsl:value-of select="nome"/>
  </xsl:template>

</xsl:stylesheet>

B) Parágrafos

Resultado agardado:

<?xml version="1.0" encoding="UTF-8"?>
<html>
  <p>Administración de Sistemas Informáticos en Rede</p>
  <p>Desenvolvmento de Aplicacións Web</p>
  <p>Desenvolvmento de Aplicacións Multiplataforma</p>
  <p>Sistemas Microinformáticos e Redes</p>
</html>

Folla de estilo XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:template match="ciclos">
    <html>
        <xsl:apply-templates />
    </html>
  </xsl:template>

  <xsl:template match="ciclo">
     <p><xsl:value-of select="nome"/></p>
  </xsl:template>

</xsl:stylesheet>

C) Listaxe

Resultado agardado:

<?xml version="1.0" encoding="UTF-8"?>
<html>
  <ul>
    <li>Administración de Sistemas Informáticos en Rede</li>
    <li>Desenvolvemento de Aplicacións Web</li>
    <li>Desenvolvmento de Aplicacións Multiplataforma</li>
    <li>Sistemas Microinformáticos e Redes</li>
  </ul>
</html>

Folla de estilo XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:template match="ciclos">
    <html>
    <ul>
        <xsl:apply-templates />
    </ul>
    </html>
  </xsl:template>

  <xsl:template match="ciclo">
     <li><xsl:value-of select="nome"/></li>
  </xsl:template>

</xsl:stylesheet>

D) Táboa

Resultado agardado:

<?xml version="1.0" encoding="UTF-8"?>
<html>
  <table border="1">
    <tr>
      <td>Administración de Sistemas Informáticos en Rede</td>
    </tr>
    <tr>
      <td>Desenvolvemento de Aplicacións Web</td>
    </tr>
    <tr>
      <td>Desenvolvemento de Aplicacións Multiplataforma</td>
    </tr>
    <tr>
      <td>Sistemas Microinformáticos e Redes</td>
    </tr>
  </table>
</html>

Folla de estilo XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:strip-space elements="*" />

  <xsl:template match="ciclos">
    <html>
    <table border="1">
      <xsl:apply-templates />
    </table>
    </html>
  </xsl:template>

  <xsl:template match="ciclo">
    <tr>
      <td><xsl:value-of select="nome"/></td>
    </tr>
  </xsl:template>

</xsl:stylesheet>

E) Táboa con información do centro, fila de encabezado e información dos módulos

Resultado agardado:

<?xml version="1.0" encoding="UTF-8"?>
<html>
  <h1>Rodolfo Ucha</h1>
  <p>Páxina web: <a href="https://www.cifprodolfoucha.es">https://www.cifprodolfoucha.es/</a></p>
  <table border="1">
  <tr>
     <th>Nome do ciclo</th>
     <th>Grao</th>
     <th>Ano do título</th>
  </tr>
   <tr>
     <td>Administración de Sistemas Informáticos en Rede</td>
     <td>Superior</td>
     <td>2009</td>
   </tr>
   <tr>
     <td>Desenvolvemento de Aplicacións Web</td>
     <td>Superior</td>
     <td>2010</td>
   </tr>
   <tr>
     <td>Desenvolvemento de Aplicacións Multiplataforma</td>
     <td>Superior</td>
     <td>2010</td>
   </tr>
   <tr>
     <td>Sistemas Microinformáticos e Redes</td>
     <td>Medio</td>
     <td>2008</td>
   </tr>
  </table>
</html>

Folla de estilo XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:strip-space elements="*" />

  <xsl:template match="cifp">
    <html>
      <h1><xsl:value-of select="@nome" /></h1>
      <p>Página web: <a >
        <xsl:attribute name="href">
          <xsl:value-of select="@web" />
        </xsl:attribute>
        <xsl:value-of select="@web" /></a></p>
      <table border="1">
        <tr>
          <th>Nome do ciclo</th>
          <th>Grao</th>
          <th>Ano do título</th>
        </tr>
        <xsl:apply-templates />
      </table>
    </html>
  </xsl:template>

  <xsl:template match="ciclo">
    <tr>
      <td><xsl:value-of select="nome"/></td>
      <td><xsl:value-of select="grao"/></td>
      <td><xsl:value-of select="decretoTitulo/@ano"/></td>
    </tr>
  </xsl:template>

</xsl:stylesheet>
Nota. Non é importante se no resultado se xeneran liñas en branco no documento.

Referencias