1"use strict";(self.webpackChunkacceso_datos=self.webpackChunkacceso_datos||[]).push([[27039],{60655:(e,n,a)=>{a.r(n),a.d(n,{assets:()=>d,contentTitle:()=>l,default:()=>u,frontMatter:()=>o,metadata:()=>c,toc:()=>i});var t=a(74848),s=a(28453);const o={title:"514"},l="Ejercicio 514",c={id:"unidades/05/ejercicios/514",title:"514",description:"Consideremos el siguiente documento XML:",source:"@site/docs/unidades/05/02-ejercicios/514.md",sourceDirName:"unidades/05/02-ejercicios",slug:"/unidades/05/ejercicios/514",permalink:"/docs/unidades/05/ejercicios/514",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{title:"514"},sidebar:"Unidad5",previous:{title:"513",permalink:"/docs/unidades/05/ejercicios/513"},next:{title:"515",permalink:"/docs/unidades/05/ejercicios/515"}},d={},i=[];function r(e){const n={code:"code",h1:"h1",header:"header",p:"p",pre:"pre",strong:"strong",...(0,s.R)(),...e.components},{Details:a}=n;return a||function(e,n){throw new Error("Expected "+(n?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}("Details",!0),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"ejercicio-514",children:"Ejercicio 514"})}),"\n",(0,t.jsx)(n.p,{children:"Consideremos el siguiente documento XML:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-xml",children:'<?xml version="1.0" encoding="UTF-8"?>\n<listado>\n <cuenta>\n <titular dni="5671001D">Ramon Perez</titular>\n <saldoactual moneda="euros">12000</saldoactual>\n <fechacreacion>13-abril-2012</fechacreacion>\n </cuenta>\n <fondo>\n <cuentaasociada>20-A</cuentaasociada>\n <datos>\n <cantidaddepositada>20000</cantidaddepositada>\n <moneda>Euros</moneda>\n </datos>\n </fondo>\n <fondo>\n <cuentaasociada>21-DX</cuentaasociada>\n <datos>\n <cantidaddepositada>4800</cantidaddepositada>\n <moneda>Dolares</moneda>\n </datos>\n </fondo>\n <cuenta>\n <titular dni="39812341C">Carmen Diaz</titular>\n <saldoactual moneda="euros">1900</saldoactual>\n <fechacreacion>15-febrero-2011</fechacreacion>\n </cuenta>\n</listado>\n'})}),"\n",(0,t.jsxs)(n.p,{children:["Dise\xf1a un ",(0,t.jsx)(n.strong,{children:"documento XSLT"})," que permita transformar el fichero anterior en el siguiente ",(0,t.jsx)(n.strong,{children:"fichero XML"}),":"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-xml",children:'<datos>\n <cuentas>\n <cuenta dnititular="5671001D">\n <creacion>13-abril-2012</creacion>\n <titular>Ramon Perez</titular>\n <saldoactual>12000 euros</saldoactual>\n </cuenta>\n <cuenta dnititular="39812341C">\n <creacion>15-febrero-2011</creacion>\n <titular>Carmen Diaz</titular>\n <saldoactual>1900 euros</saldoactual>\n </cuenta>\n </cuentas>\n <fondos>\n <fondo cuentaasociada="20-A">\n <cantidaddepositada>20000</cantidaddepositada>\n <moneda>Euros</moneda>\n </fondo>\n <fondo cuentaasociada="21-DX">\n <cantidaddepositada>4800</cantidaddepositada>\n <moneda>Dolares</moneda>\n </fondo>\n </fondos>\n</datos>\n'})}),"\n",(0,t.jsxs)(a,{children:[(0,t.jsx)("summary",{children:"Soluci\xf3n"}),(0,t.jsxs)(n.p,{children:["Debemos a\xf1adir una cabecera al ",(0,t.jsx)(n.strong,{children:"documento XML"})," (suponiendo que el nombre del fichero XSLT es ",(0,t.jsx)(n.code,{children:"514.xsl"}),"):"]}),(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-xml",children:'<?xml-stylesheet type="text/xsl" href="514.xsl"?>\n'})}),(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"Hoja XSL"}),":"]}),(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-xml",children:'<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\n <xsl:output method="xml" encoding="utf-8" indent="yes"/>\n <xsl:template match="/">\n <datos>\n <cuentas>\n <xsl:for-each select="listado/cuenta">\n <cuenta>\n <xsl:attribute name="dnititular">\n <xsl:value-of select="titular/@dni"/>\n </xsl:attribute>\n <creacion>\n <xsl:value-of select="fechacreacion"/>\n </creacion>\n <titular>\n <xsl:value-of select="titular"/>\n </titular>\n <saldoactual>\n <xsl:value-of select="saldoactual"/>\n <xsl:value-of select="saldoactual/@moneda"/>\n </saldoactual>\n </cuenta>\n </xsl:for-each>\n </cuentas>\n <fondos>\n <xsl:for-each select="listado/fondo">\n <fondo>\n <xsl:attribute name="cuentaasociada">\n <xsl:value-of select="cuentaasociada"/>\n </xsl:attribute>\n <cantidaddepositada>\n <xsl:value-of select="datos/cantidaddepositada"/>\n </cantidaddepositada>\n <moneda>\n <xsl:value-of select="datos/moneda"/>\n </moneda>\n </fondo>\n </xsl:for-each>\n </fondos>\n </datos>\n </xsl:template> \n</xsl:stylesheet>\n'})}),(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"Hoja XSL"})," (alternativa utilizando ",(0,t.jsx)(n.code,{children:"call-template"}),"):"]}),(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-xml",children:'<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\n <xsl:output method="xml" encoding="utf-8" indent="yes"/>\n <xsl:template match="/">\n <datos>\n <cuentas>\n <xsl:for-each select="listado/cuenta">\n <xsl:call-template name="cuenta-template" />\n </xsl:for-each>\n </cuentas>\n <fondos>\n <xsl:for-each select="listado/fondo">\n <xsl:call-template name="fondo-template" />\n </xsl:for-each>\n </fondos>\n </datos>\n </xsl:template>\n \n <xsl:template name="cuenta-template">\n <cuenta>\n <xsl:attribute name="dnititular">\n <xsl:value-of select="titular/@dni"/>\n </xsl:attribute>\n <creacion>\n <xsl:value-of select="fechacreacion"/>\n </creacion>\n <titular>\n <xsl:value-of select="titular"/>\n </titular>\n <saldoactual>\n <xsl:value-of select="saldoactual"/>\n <xsl:value-of select="saldoactual/@moneda"/>\n </saldoactual>\n </cuenta>\n </xsl:template>\n \n <xsl:template name="fondo-template">\n <fondo>\n <xsl:attribute name="cuentaasociada">\n <xsl:value-of select="cuentaasociada"/>\n </xsl:attribute>\n <cantidaddepositada>\n <xsl:value-of select="datos/cantidaddepositada"/>\n </cantidaddepositada>\n <moneda>\n <xsl:value-of select="datos/moneda"/>\n </moneda>\n </fondo>\n </xsl:template>\n</xsl:stylesheet>\n'})}),(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"Hoja XSL"})," (alternativa utilizando ",(0,t.jsx)(n.code,{children:"apply-templates"}),"):"]}),(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-xml",children:'<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\n <xsl:output method="xml" encoding="utf-8" indent="yes"/>\n <xsl:template match="/">\n <datos>\n <cuentas>\n <xsl:apply-templates select="listado/cuenta" />\n </cuentas>\n <fondos>\n <xsl:apply-templates select="listado/fondo" />\n </fondos>\n </datos>\n </xsl:template>\n \n <xsl:template match="listado/cuenta">\n <cuenta>\n <xsl:attribute name="dnititular">\n <xsl:value-of select="titular/@dni"/>\n </xsl:attribute>\n <creacion>\n <xsl:value-of select="fechacreacion"/>\n </creacion>\n <titular>\n <xsl:value-of select="titular"/>\n </titular>\n <saldoactual>\n <xsl:value-of select="saldoactual"/>\n <xsl:value-of select="saldoactual/@moneda"/>\n </saldoactual>\n </cuenta>\n </xsl:template>\n \n <xsl:template match="listado/fondo">\n <fondo>\n <xsl:attribute name="cuentaasociada">\n <xsl:value-of select="cuentaasociada"/>\n </xsl:attribute>\n <cantidaddepositada>\n <xsl:value-of select="datos/cantidaddepositada"/>\n </cantidaddepositada>\n <moneda>\n <xsl:value-of select="datos/moneda"/>\n </moneda>\n </fondo>\n </xsl:template>\n</xsl:stylesheet>\n'})})]})]})}function u(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(r,{...e})}):r(e)}},28453:(e,n,a)=>{a.d(n,{R:()=>l,x:()=>c});var t=a(96540);const s={},o=t.createContext(s);function l(e){const n=t.useContext(o);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),t.createElement(o.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.