Foros del Web » Programación para mayores de 30 ;) » Programación General »

Problemas con MSXSL.EXE

Estas en el tema de Problemas con MSXSL.EXE en el foro de Programación General en Foros del Web. Hola grupo: Me he creado un XSL que usa el elemento <msxsl:script... Cuando enlazo un XML a un XSL, y ejecuto dicho XML, el resultado ...
  #1 (permalink)  
Antiguo 01/07/2003, 01:15
 
Fecha de Ingreso: julio-2003
Mensajes: 2
Antigüedad: 20 años, 10 meses
Puntos: 0
Problemas con MSXSL.EXE

Hola grupo:

Me he creado un XSL que usa el elemento <msxsl:script... Cuando enlazo un
XML a un XSL, y ejecuto dicho XML, el resultado es correcto. No obstante si
intento generar el HTML en un fichero, usando el programa de línea de
comandos MSXSL.EXE, el HTML que me genera no es correcto.
El problema es el siguiente: Desde el script quiero moverme por los nodos
usando DOM, en el momento que estoy en un nodo con hijos, si aplico
.firstChild, no se me situa correctamente en el nodo hijo, siendo imposible
rescatar ningún valor del nodo. Estoy usando el Parser MSXML 4.0, también he
probado con el 3.0, y la salida es también incorrecta.
Os pongo el XML, el XSL y las dos salidas, a ver si me podéis ayudar.
Muchas gracias,
Juan Torres. (jto_star[at]yahoo.es)

XML:
<!--
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="script.xsl" ?>
<CUSTOMERS>
<CUSTOMER>
<NAME>John Smith</NAME>
<ADDRESS>123 Elm St.</ADDRESS>
<PHONE>(123) 456-7890</PHONE>
</CUSTOMER>
<CUSTOMER>
<NAME>Mary Jones</NAME>
<ADDRESS>456 Oak Ave.</ADDRESS>
<PHONE>(156) 789-0123</PHONE>
</CUSTOMER>
<CUSTOMER>
<NAME>Juan</NAME>
<ADDRESS>Armengual Mota</ADDRESS>
<PHONE>(111) 111-1111</PHONE>
</CUSTOMER>
<CUSTOMER>
<NAME>Maria</NAME>
<ADDRESS>El Parque</ADDRESS>
<PHONE>(222) 222-2222</PHONE>
</CUSTOMER>
<CUSTOMER>
<NAME>Pepe</NAME>
<ADDRESS>c.Alfonso</ADDRESS>
<PHONE>(333) 333-3333</PHONE>
</CUSTOMER>
</CUSTOMERS>
-->

XSL:
<!--
<?xml version='1.0'?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts">

<xsl:template match="/">
<html>
<head>
<title>Ejemplo msxsl:script</title>
</head>
<body bgcolor="#ddddff">
<xsl:apply-templates />
</body>
</html>
</xsl:template>

<xsl:template match="CUSTOMERS">
<xsl:for-each select="CUSTOMER">
<hr/>
<xsl:apply-templates />
<xsl:call-template name="PREVIOUS"/>
<xsl:call-template name="NEXT"/>
<hr/>
<br/>
</xsl:for-each>
</xsl:template>

<xsl:template match="NAME|ADDRESS|PHONE">
<xsl:value-of select="user:Get_Name(.)"/>: 
<xsl:value-of select="user:Get_Text(.)"/>
<br/>
</xsl:template>

<xsl:template name="PREVIOUS">
Previous Name: <xsl:value-of
select="user:Get_Previous_Sibling_Name(.)"/><br/>
</xsl:template>

<xsl:template name="NEXT">
Next Name: <xsl:value-of
select="user:Get_Next_Sibling_Name(.)"/><br/>
</xsl:template>

<xsl:template match="text()">
<xsl:value-of select="."/>
</xsl:template>

<msxsl:script language="JScript" implements-prefix="user">
<![CDATA[

function Get_Text(a_obj_nodelist) {
var l_obj_node = a_obj_nodelist.item(0);

if ( (l_obj_node + "") != "null"){
return (l_obj_node.text);
}
else{
return ("It have not!");
}
}

function Get_Name(a_obj_nodelist) {
var l_obj_node = a_obj_nodelist.item(0);

if ( (l_obj_node + "") != "null"){
return (l_obj_node.nodeName);
}
else{
return ("It have not!");
}
}

function Get_Previous_Sibling_Name(a_obj_nodelist) {
var l_obj_node = a_obj_nodelist.item(0);

l_obj_node = l_obj_node.previousSibling;

if ( (l_obj_node + "") == "null"){
return ("It have not!");
}
else{
l_obj_node = l_obj_node.firstChild;
if ( (l_obj_node + "") == "null"){
return ("It have not!");
}
else{
return (l_obj_node.text);
}
}
}

function Get_Next_Sibling_Name(a_obj_nodelist) {
var l_obj_node = a_obj_nodelist.item(0);

l_obj_node = l_obj_node.nextSibling;

if ( (l_obj_node + "") == "null"){
return ("It have not!");
}
else{
l_obj_node = l_obj_node.firstChild;
if ( (l_obj_node + "") == "null"){
return ("It have not!");
}
else{
return (l_obj_node.text);
}
}
}

]]>
</msxsl:script>

</xsl:stylesheet>
-->

Salida al ejecutar el XML:

----------------------------------------------------------------------------
----
NAME: John Smith
ADDRESS: 123 Elm St.
PHONE: (123) 456-7890
Previous Name: It have not!
Next Name: Mary Jones

----------------------------------------------------------------------------
----


----------------------------------------------------------------------------
----
NAME: Mary Jones
ADDRESS: 456 Oak Ave.
PHONE: (156) 789-0123
Previous Name: John Smith
Next Name: Juan

----------------------------------------------------------------------------
----


----------------------------------------------------------------------------
----
NAME: Juan
ADDRESS: Armengual Mota
PHONE: (111) 111-1111
Previous Name: Mary Jones
Next Name: Maria

----------------------------------------------------------------------------
----


----------------------------------------------------------------------------
----
NAME: Maria
ADDRESS: El Parque
PHONE: (222) 222-2222
Previous Name: Juan
Next Name: Pepe

----------------------------------------------------------------------------
----


Salida al ejecutar el HTML generado con MSXSL.EXE:

----------------------------------------------------------------------------
----
NAME: John Smith
ADDRESS: 123 Elm St.
PHONE: (123) 456-7890
Previous Name: It have not!
Next Name: It have not!

----------------------------------------------------------------------------
----


----------------------------------------------------------------------------
----
NAME: Mary Jones
ADDRESS: 456 Oak Ave.
PHONE: (156) 789-0123
Previous Name: It have not!
Next Name: It have not!

----------------------------------------------------------------------------
----


----------------------------------------------------------------------------
----
NAME: Juan
ADDRESS: Armengual Mota
PHONE: (111) 111-1111
Previous Name: It have not!
Next Name: It have not!

----------------------------------------------------------------------------
----


----------------------------------------------------------------------------
----
NAME: Maria
ADDRESS: El Parque
PHONE: (222) 222-2222
Previous Name: It have not!
Next Name: It have not!

----------------------------------------------------------------------------
----


----------------------------------------------------------------------------
----
NAME: Pepe
ADDRESS: c.Alfonso
PHONE: (333) 333-3333
Previous Name: It have not!
Next Name: It have not!

----------------------------------------------------------------------------
----


MUCHAS GRACIAS. Espero que me puedan ayudar.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:17.