Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Colaboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #11  
Antiguo 28-10-2024
antoine0 antoine0 is offline
Miembro
 
Registrado: oct 2021
Posts: 260
Poder: 5
antoine0 Va por buen camino
Cita:
Empezado por ermendalenda Ver Mensaje
Si alguno puede traducir donde se produce el cambio, a nivel del xml, se lo agradeceria, ya que yo genero los xlm a pelo y me cuesta muchisimo leer el xsd
Hago dos cosas a cada cambio de XSD:
  1. Comparo con la versión anterior; lo hago con la herramienta diff (de Unix) pero es solo por costumbre, cualquiera herramienta valga. Por ejemplo, ponerlos en un sistema de control de versión lo hace de manera automática.
  2. Paso el XSD por una transformación en formato HTML, que me resulta muchísimo más sencillo de leer

Hay que pasar todos los esquemas involucrados en un determinado WSDL, y dejar los HTML en el mismo repertorio.

La transformación que uso está derivada de una que encontró hace años (y tiene aún más años) y que creo es de uso libre.

Código:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Stylesheet for NHSiS Schemas - David Brazier 17/11/00
     Work in progress, free for use as-is.
     (C) Common Services Agency 2000
 Modifications (C) 2017-2024 Antoine Leca (free to use) -->
<xsl:stylesheet version="1.0"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsl:output encoding="UTF-8"/>
<xsl:strip-space elements="*"/>

	<xsl:template match="xsd:schema">
		<html>
			<head>
				<title>Schema: <xsl:value-of select="@targetNamespace"/>
				</title>
			</head>
			<style>
   table { border-collapse: collapse }
   td { vertical-align: top }
   </style>
			<!-- for testing:
   td { border: 1px solid blue; vertical-align: top }
-->
			<body>
				<h3>Schema: <xsl:value-of select="@targetNamespace"/></h3>
				<p>Version: <xsl:value-of select="@version"/>
				</p>
				<xsl:apply-templates/>
			</body>
		</html>
	</xsl:template>
	<xsl:template match="xsd:import">
		<hr/>
		<i>Import Schema <xsl:value-of select="@namespace"/> from 
		<a>
			<xsl:attribute name="href">
				<xsl:value-of select="@schemaLocation"/>.html
			</xsl:attribute>
			{<xsl:value-of select="@schemaLocation"/>}
		</a>
		</i>
	</xsl:template>

	<xsl:template match="xsd:element">
		<xsl:if test="..=/">
			<hr/>
		</xsl:if>
		<table>
			<tr>
				<td colspan="2">
					<b>
						<xsl:value-of select="@name"/>
					</b>
					 
					<xsl:if test="@type">
					: <a>
<!--
	<xsl:variable name="prefix" select="substring-before(name(), concat(':', local-name()) )"/>
 -->
						<xsl:variable name="prefix" select="substring-before(@type,':')"/>

						<xsl:variable name="ns" select="namespace::*[name()=$prefix]"/>
<!--
bug if name(.) contains a namespace... (= if #default namespace is NOT xsd)
Could check that namespace::*[name()=''] == "http://www.w3.org/2001/XMLSchema"
BUGBUG following does not work (double declaration?)
						<xsl:choose>
							<xsl:when test="contains(name(), ':')">
								<xsl:variable name="ns0" select="namespace::*[substring-after(name(.),':')=$prefix]"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:variable name="ns" select="namespace::*[name()=$prefix]"/>
							</xsl:otherwise>
						</xsl:choose>
 -->
						<xsl:choose>
							<xsl:when test="@type = 'string' or @type = 'double' ">
								<b><xsl:value-of select="@type"/></b>
							</xsl:when>
							<xsl:when test="not($prefix)">
								<xsl:attribute name="href">#<xsl:value-of select="@type"/></xsl:attribute>
								<b>!<xsl:value-of select="@type"/>!</b>
							</xsl:when>
							<xsl:when test="$ns=/xsd:schema/@targetNamespace">
								<xsl:attribute name="href">#<xsl:value-of select="substring-after(@type,':')"/></xsl:attribute>
							</xsl:when>
							<xsl:when test="/xsd:schema/xsd:import[@namespace=$ns]">
								<xsl:attribute name="href"><xsl:value-of select="/xsd:schema/xsd:import[@namespace=$ns]/@schemaLocation"/>.html#<xsl:value-of select="substring-after(@type,':')"/></xsl:attribute>
								{<xsl:value-of select="/xsd:schema/xsd:import[@namespace=$ns]/@schemaLocation"/>}
							</xsl:when>
						</xsl:choose>
						<xsl:value-of select="substring-after(@type,':')"/>
					</a>
					</xsl:if>
					(<xsl:choose>
						<xsl:when test="@minOccurs"><xsl:value-of select="@minOccurs"/></xsl:when>
						<xsl:otherwise>1</xsl:otherwise>
					</xsl:choose>-<xsl:choose>
						<xsl:when test="@maxOccurs"><xsl:value-of select="@maxOccurs"/></xsl:when>
						<xsl:otherwise>1</xsl:otherwise>
					</xsl:choose>)
				</td>
			</tr>
			<tr>
				<td width="25"/>
				<td>
					<xsl:apply-templates select="*"/>
				</td>
			</tr>
		</table>
	</xsl:template>

	<xsl:template match="xsd:simpleType">
		<xsl:if test="..=/">
			<hr/>
		</xsl:if>
		<table>
			<xsl:attribute name="id">
				<xsl:value-of select="@name"/>
			</xsl:attribute>
			<tr>
				<td colspan="2">
					<i>type </i><b>
						<xsl:value-of select="@name"/>
					</b>:
					 <xsl:value-of select="@type"/>
				</td>
			</tr>
			<tr>
				<td width="25"/>
				<td>
					<xsl:apply-templates select="*"/>
				</td>
			</tr>
		</table>
	</xsl:template>
	<xsl:template match="xsd:complexType">
		<xsl:if test="..=/">
			<hr/>
		</xsl:if>
		<table>
			<xsl:if test="@name">
			<xsl:attribute name="id">
				<xsl:value-of select="@name"/>
			</xsl:attribute>
			<tr>
				<td colspan="2">
					<i>type </i><b>
						<xsl:value-of select="@name"/>
					</b>:
					 <xsl:value-of select="@type"/>
				</td>
			</tr>
			</xsl:if><!-- test="@name" -->
			<tr>
				<td width="25"/>
				<td>
					<xsl:apply-templates select="*"/>
				</td>
			</tr>
		</table>
	</xsl:template>
	<xsl:template match="xsd:sequence">
		<xsl:if test="..=/">
			<hr/>
		</xsl:if>
		<table>
			<tr>
				<td width="25" style="border-right: 1px solid black"/>
				<td>
					<xsl:apply-templates select="*"/>
				</td>
			</tr>
		</table>
	</xsl:template>
	<xsl:template match="xsd:choice">
		<xsl:if test="..=/">
			<hr/>
		</xsl:if>
		<table>
			<tr>
				<td width="25" style="vertical-align: middle; border-right: double black">
				choice
				</td>
				<td>
					<xsl:apply-templates select="*"/>
				</td>
			</tr>
		</table>
	</xsl:template>
	<xsl:template match="xsd:extension">
		<i>extends </i> 
		<xsl:variable name="prefix" select="substring-before(@base,':')"/>
		<xsl:variable name="ns" select="namespace::*[name()=$prefix]"/>
		<a>
		<xsl:choose>
			<xsl:when test="@base = 'string' or @base = 'double' ">
			<!-- bug: missing @href; can we simply drop it? -->
				<b><xsl:value-of select="@base"/></b>
			</xsl:when>
			<xsl:when test="not($prefix)">
				<xsl:attribute name="href">#<xsl:value-of select="@base"/></xsl:attribute>
				<xsl:value-of select="@base"/>
			</xsl:when>
			<xsl:when test="$ns=/xsd:schema/@targetNamespace">
				<xsl:attribute name="href">#<xsl:value-of select="substring-after(@base,':')"/></xsl:attribute>
				<xsl:value-of select="substring-after(@base,':')"/>
			</xsl:when>
			<xsl:when test="/xsd:schema/xsd:import[@namespace=$ns]">
				<xsl:attribute name="href"><xsl:value-of select="/xsd:schema/xsd:import[@namespace=$ns]/@schemaLocation"/>.html#<xsl:value-of select="substring-after(@base,':')"/></xsl:attribute>
				{<xsl:value-of select="/xsd:schema/xsd:import[@namespace=$ns]/@schemaLocation"/>}
				<xsl:value-of select="substring-after(@base,':')"/>
			</xsl:when>
		</xsl:choose>
		</a>
		<xsl:apply-templates select="*"/>
	</xsl:template>

	<xsl:template match="xsd:restriction">
		<xsl:choose>
			<xsl:when test="contains(@base, ':')">
				<xsl:variable name="prefix" select="substring-before(@base,':')"/>
				<xsl:variable name="ns" select="namespace::*[name()=$prefix]"/>
		<i>is new </i> 
		<a>
				<xsl:choose>
					<xsl:when test="@base = 'string' or @base = 'double' ">
						<b><xsl:value-of select="@base"/></b>
					</xsl:when>
					<xsl:when test="not($prefix)">
						<xsl:attribute name="href">#<xsl:value-of select="@base"/></xsl:attribute>
						<xsl:value-of select="@base"/>
					</xsl:when>
					<xsl:when test="$ns=/xsd:schema/@targetNamespace">
						<xsl:attribute name="href">#<xsl:value-of select="substring-after(@base,':')"/></xsl:attribute>
						<xsl:value-of select="substring-after(@base,':')"/>
					</xsl:when>
					<xsl:when test="/xsd:schema/xsd:import[@namespace=$ns]">
						<xsl:attribute name="href"><xsl:value-of select="/xsd:schema/xsd:import[@namespace=$ns]/@schemaLocation"/>.html#<xsl:value-of select="substring-after(@base,':')"/></xsl:attribute>
						{<xsl:value-of select="/xsd:schema/xsd:import[@namespace=$ns]/@schemaLocation"/>}
						<xsl:value-of select="substring-after(@base,':')"/>
					</xsl:when>
				</xsl:choose>
		</a>  
			</xsl:when>
			<xsl:when test="./xsd:enumeration">
			<!-- nothing -->
			</xsl:when>
			<xsl:otherwise>
				<i>&lt;<xsl:value-of select="@base"/>&gt;</i>  
			</xsl:otherwise>
		</xsl:choose>
		<xsl:apply-templates select="*"/>
	</xsl:template>
	<xsl:template match="xsd:length">
		[<xsl:value-of select="@value"/>]
	</xsl:template>
	<xsl:template match="xsd:minLength">
		[<xsl:value-of select="@value"/> ..
	</xsl:template>
	<xsl:template match="xsd:maxLength">
		<!-- add [0.. if there are no minLength -->
		<xsl:if test="not(../xsd:minLength)">[0..</xsl:if>
		<xsl:value-of select="@value"/>]
	</xsl:template>
	<xsl:template match="xsd:enumeration">
		"<xsl:value-of select="@value"/>"
		<xsl:apply-templates select="*"/>
	</xsl:template>
	<xsl:template match="xsd:pattern">
		<i> like </i>/<xsl:value-of select="@value"/>/
		<xsl:apply-templates select="*"/>
	</xsl:template>
	<xsl:template match="xsd:annotation">
		<xsl:for-each select="xsd:documentation">
			<small>
				<xsl:value-of select="."/>
			</small>
			<br/>
		</xsl:for-each>
		<xsl:for-each select="xsd:appinfo">
			<small>
				<i>
					<xsl:value-of select="."/>
				</i>
			</small>
			<br/>
		</xsl:for-each>
	</xsl:template>
</xsl:stylesheet>
Si los moderadores lo consideran oportuno, se puede recortar el código, ponerlo análisis de sintaxis XML, o mover este post a otro hilo más adecuado.
Archivos Adjuntos
Tipo de Archivo: zip xsd2html.zip (1,8 KB, 17 visitas)
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Hijo de Informáticos gluglu Humor 3 13-03-2007 11:05:35
Adictos informaticos ... Trigger Humor 2 11-10-2004 12:18:32
Nosotros los Informáticos Trigger Humor 1 10-10-2004 14:58:09
Patrón de los Informáticos. obiwuan Varios 20 10-09-2003 14:44:54
Chistes Informaticos jhonny Humor 2 11-08-2003 21:59:09


La franja horaria es GMT +2. Ahora son las 23:32:44.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi