Help with Jscript and xsl!!!! pleaseee!!!
Hello!!!
I´m working with xsl,svg and JavaScript to create a chart.
The xsl(votos5.xsl) calls a template(template_Barras_.xslt) where
I´ve added a script, when the debugger starts next message appears:
"Function not in namespaceError in XPath expression, Function not in namespace"
¿Any Help???
Thanks in advance.
Belén
[u]the xml is :</u>
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="C:\Documents and Settings\Belen\Escritorio\pruebas\votos5.xslt"?>
<holacaracola pp="10" psoe="20" iu="30" uv="5" losverdes="20" enblanco="10" abstenciones="5"/>
[u]the xsl is votos5.xsl:</u>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href = "template_Barras_.xsl" />
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/holacaracola">
<html xmlns:svg="http://www.w3.org/2000/svg">
<object id="AdobeSVG" CLASSID="clsid:78156a80-c6a1-4bbf-8e6a-3cd390eeb4e2"></object>
<xsl:copy><?import namespace="svg" implementation="#AdobeSVG"?></xsl:copy>
<head>
<title>Informe x</title>
</head>
<body>
<xsl:call-template name="Votos"/>
<xsl:call-template name="Barras"/>
</body>
</html>
</xsl:template>
<xsl:template name="Votos">
<table>
<xsl:for-each select="@*">
<tr>
<td><xsl:value-of select="name()"/></td>
<td><xsl:value-of select="."/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
the template is template_Barras_.xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="http://mycompany.com/mynamespace"
xmlns:svg="http://www.w3.org/2000/svg">
<!-- El script
<msxsl:script language="JavaScript" implements-prefix="user">
function CalculaMaxInt(maximo) {
var n;
var oSup;
var oMin;
n= (Math.ceil(Math.log(maximo)div(Math.log(10))))-1;
oSup= (Math.ceil(maximo/(Math.log(10))))*Math.pow(10,n);
return oSup;
}
</msxsl:script>-->
<msxsl:script language="JScript" implements-prefix="user">
function CalculaIntervalo(Max) {
var n;
n = (Math.ceil(Math.log(Max)/(Math.log(10))))-1;
return Math.pow(10,n);
}
</msxsl:script>
<!-- Margenes entre la ventana y la gráfica
-->
<xsl:variable name="xVentana">500</xsl:variable>
<xsl:variable name="yVentana">400</xsl:variable>
<!-- Altura del gráfico
-->
<xsl:variable name="yMargenTop">50</xsl:variable>
<xsl:variable name="yMargenBottom">100</xsl:variable>
<xsl:variable name="xMarginLeft">50</xsl:variable>
<xsl:variable name="xMarginRight">50</xsl:variable>
<xsl:variable name="yGrafica">
<xsl:value-of select="$yVentana - $yMargenTop - $yMargenBottom"/>
</xsl:variable>
<xsl:variable name="posyGrafica">
<xsl:value-of select="$yVentana - $yMargenBottom"/>
</xsl:variable>
<xsl:variable name="xGrafica">
<xsl:value-of select="$xVentana - $xMarginLeft - $xMarginRight"/>
</xsl:variable>
<xsl:template name="Barras">
<xsl:variable name="valorMinimo">
<xsl:apply-templates select="@*">
<xsl:sort data-type="number" order="ascending" select="."/>
</xsl:apply-templates>
</xsl:variable>
<xsl:variable name="valorMaximo">
<xsl:apply-templates select="@*">
<xsl:sort data-type="number" order="descending" select="."/>
</xsl:apply-templates>
</xsl:variable>
<xsl:variable name="numColumnas">
<xsl:value-of select="count(@*)"/>
</xsl:variable>
<xsl:variable name="xEspacio">
<xsl:value-of select="$xGrafica div ($numColumnas*2 + 1)"/>
</xsl:variable>
<xsl:variable name="valorIntervalo">
<xsl:value-of select="user:CalculaIntervalo($valorMaximo)"/>
</xsl:variable>
<!--<xsl:variable name="valorIntervalo">
<xsl:value-of select="@*[last()]"/>
</xsl:variable>-->
<xsl:variable name="numLineas">
<xsl:value-of select="$valorMaximo div $valorIntervalo"/>
</xsl:variable>
<xsl:variable name="espLineas">
<xsl:value-of select="$yGrafica div $numLineas"/>
</xsl:variable>
<!-- <msxsl:script language="JavaScript" implements-prefix="mio">
function CalculaIntervalo(number,number) {
var n;
var oSup;
var oMin;
n= (Math.ceil(Math.log($valorMaximo)div(Math.log(10)) ))-1;
oInf= (Math.floor($valorMinimo/(Math.log(10))))*Math.pow(10,n);
return oInf;
}
</msxsl:script>-->
<!--
oSup= (Math.ceil($valorMaximo/(Math.log(10))))*Math.pow(10,n);
oinf= (Math.ceil($valorMaximo/(Math.log(10))))*Math.pow(10,n);-->
<svg:svg width="{$xVentana}" height="{$yVentana}">
<svg:rect x="{$xMarginLeft}" y="{$yMargenTop - 20}" width="{$xGrafica}" height="{$yGrafica + 20}" style="fill:#E3DFCC;"/>
<svg:line x1="{$xMarginLeft}" y1="{$yMargenTop - 20}" x2="{$xMarginLeft}" y2="{$posyGrafica}" style="stroke:#000000; stroke-width:0.1"/>
<xsl:for-each select="@*">
<xsl:call-template name="pintarRectangulo">
<xsl:with-param name="numColumna">
<xsl:value-of select="position()"/>
</xsl:with-param>
<xsl:with-param name="valorMaximo">
<xsl:value-of select="$valorMaximo"/>
</xsl:with-param>
<xsl:with-param name="xEspacio">
<xsl:value-of select="$xEspacio"/>
</xsl:with-param>
<xsl:with-param name="altRectangulo">
<xsl:value-of select="."/>
</xsl:with-param>
</xsl:call-template>
<g style="fill:#000000; font-size:12; font-family:Arial">
<xsl:call-template name="ptextox">
<xsl:with-param name="numColumna">
<xsl:value-of select="position()"/>
</xsl:with-param>
<xsl:with-param name="xEspacio">
<xsl:value-of select="$xEspacio"/>
</xsl:with-param>
</xsl:call-template>
</g>
</xsl:for-each>
<xsl:call-template name="plhorizontales1">
<xsl:with-param name="valorIntervalo">
<xsl:value-of select="$valorIntervalo"/>
</xsl:with-param>
<xsl:with-param name="valorMaximo">
<xsl:value-of select="$valorMaximo"/>
</xsl:with-param>
<xsl:with-param name="numLineas">
<xsl:value-of select="$valorMaximo div $valorIntervalo"/>
</xsl:with-param>
<xsl:with-param name="yGrafica">
<xsl:value-of select="$yGrafica"/>
</xsl:with-param>
<xsl:with-param name="espLineas">
<xsl:value-of select="$yGrafica div $numLineas"/>
</xsl:with-param>
</xsl:call-template>
<!-- Procesamos el elemento item para pintar las columnas
-->
</svg:svg>
</xsl:template>
<xsl:template match="@*">
<xsl:if test="position() = 1">
<xsl:value-of select="."/>
</xsl:if>
</xsl:template>
<xsl:template name="plhorizontales1">
<xsl:param name="valorIntervalo"/>
<xsl:param name="valorMaximo"/>
<xsl:param name="numLineas"/>
<xsl:param name="yGrafica"/>
<xsl:param name="espLineas"/>
<xsl:param name="conNumLineas">0</xsl:param>
<xsl:if test="($numLineas + 1)>$conNumLineas">
<svg:g style="fill:#000000; font-size:12; font-family:Arial">
<xsl:call-template name="ptextoy">
<xsl:with-param name="Texto">
<xsl:value-of select="$conNumLineas * $valorIntervalo"/>
</xsl:with-param>
<xsl:with-param name="yLinea">
<xsl:value-of select="$posyGrafica - ($espLineas * $conNumLineas)"/>
</xsl:with-param>
</xsl:call-template>
</svg:g>
<xsl:call-template name="plhorizontales2">
<xsl:with-param name="yLinea">
<xsl:value-of select="$posyGrafica - ($espLineas * $conNumLineas)"/>
</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="plhorizontales1">
<xsl:with-param name="valorIntervalo">
<xsl:value-of select="$valorIntervalo"/>
</xsl:with-param>
<xsl:with-param name="valorMaximo">
<xsl:value-of select="$valorMaximo"/>
</xsl:with-param>
<xsl:with-param name="numLineas">
<xsl:value-of select="$numLineas"/>
</xsl:with-param>
<xsl:with-param name="yGrafica">
<xsl:value-of select="$yGrafica"/>
</xsl:with-param>
<xsl:with-param name="espLineas">
<xsl:value-of select="$espLineas"/>
</xsl:with-param>
<xsl:with-param name="conNumLineas">
<xsl:value-of select="($conNumLineas + 1)"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="plhorizontales2">
<xsl:param name="yLinea"/>
<svg:line x1="{$xMarginLeft}" y1="{$yLinea}" x2="{$xMarginLeft + $xGrafica}" y2="{$yLinea}" style="stroke:#000000; stroke-width:0.1"/>
</xsl:template>
<xsl:template name="ptextoy">
<xsl:param name="Texto"/>
<xsl:param name="yLinea"/>
<svg:text x="{$xMarginLeft - 30}" y="{$yLinea}">
<xsl:value-of select="$Texto"/>
</svg:text>
</xsl:template>
<!--
************************************************** **********
En esta regla de construcción pintamos el texto que se
visualiza en el eje de las X. Fijaros como lo giramos 90
grados para que se visualize en vertical.
************************************************** ********** -->
<xsl:template name="ptextox">
<xsl:param name="numColumna"/>
<xsl:param name="xEspacio"/>
<xsl:variable name="xTexto">
<xsl:value-of select="$xMarginLeft + $xEspacio +($xEspacio * 2 *($numColumna - 1))"/>
</xsl:variable>
<xsl:variable name="yTexto">
<xsl:value-of select="$yGrafica + 60"/>
</xsl:variable>
<svg:text x="{$xTexto}" y="{$yTexto}" transform="translate({$xTexto},{$yTexto}) rotate(90) translate(-{$xTexto},-{$yTexto})">
<xsl:value-of select="name()"/>
</svg:text>
</xsl:template>
<xsl:template name="pintarRectangulo">
<xsl:param name="numColumna"/>
<xsl:param name="valorMaximo"/>
<xsl:param name="xEspacio"/>
<xsl:param name="altRectangulo"/>
<xsl:variable name="altRectanguloG">
<xsl:value-of select="($altRectangulo * $yGrafica) div $valorMaximo"/>
</xsl:variable>
<svg:rect x="{$xMarginLeft + $xEspacio +($xEspacio * 2 *($numColumna - 1))}" y="{$posyGrafica - $altRectanguloG}" style="fill:red; stroke:black; stroke-width:0.5" width="{$xEspacio}" height="{$altRectanguloG}"/>
</xsl:template>
</xsl:stylesheet>
|