|
Subject:
|
Tags closing problem
|
|
Posted By:
|
igna36
|
Post Date:
|
5/14/2008 6:22:45 AM
|
i have this piece code in xsl file that i use in browser
<xsl:element name="div"> <xsl:attribute name="id"><xsl:value-of select="cg_descripcion" /></xsl:attribute> <xsl:call-template name="foodcomposition"> <xsl:with-param name="comptype" select="componentgroup_id" /> <xsl:with-param name="title" select="cg_descripcion" /> <xsl:with-param name="conversion" select="$factorc" /> </xsl:call-template> </xsl:element>
The output is:
<div id="Proximates"></div>
*** Output from template ***
But I want this:
<div id="Proximates">
*** Output from template ***
</div>
Why XSLT is closing the div tag before calling the template?
Thanks
|
|
Reply By:
|
Martin Honnen
|
Reply Date:
|
5/14/2008 6:28:55 AM
|
Which XSLT processor do you use? How do you check the result if you are using a browser as the XSLT processor?
-- Martin Honnen Microsoft MVP - XML
|
|
Reply By:
|
mhkay
|
Reply Date:
|
5/14/2008 6:31:27 AM
|
There's nothing obviously wrong with the code you've shown us.
This usually means there's something wrong with the code you haven't shown us.
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
Reply By:
|
igna36
|
Reply Date:
|
5/14/2008 6:32:24 AM
|
I use XSLT 1.0 that is included in Mozilla/Gecko or IE (cross-browser) using Javascript
I check it by viewing the output HTML in Firefox.
|
|
Reply By:
|
igna36
|
Reply Date:
|
5/14/2008 6:35:55 AM
|
This is the extended piece of code
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="factorc" />
<xsl:template match="/">
<h2 align="center">Información detallada del Alimento</h2> <p align="right"><a target="_blank"><xsl:attribute name="href">https://www.bedca.net:8443/cocoon/pdf/response<xsl:value-of select="foodresponse/food/f_id[1]" />.pdf</xsl:attribute><img src="./img/pdf_icon.gif" /></a></p>
<xsl:call-template name="foodinfo" />
<xsl:call-template name="foodgraphic"/> <br /> <h4 align="center" style="background:#9EC9F8">Información de composición (por <xsl:value-of select='format-number($factorc,"#")' /> g de porción comestible)</h4> <br /> <br /> <p align="center"><b>Cálculo de valores de composición para otras medidas</b></p> <p align="center"><input type="text" style="width:13%" id="edipor" /> gramos </p> <p align="center"><a href="javascript:void(0)" onclick="calccomp(document.getElementById('edipor').value)"> Calcular </a></p> <br /> <br /> <TABLE align="center"> <TR> <TH>Componente</TH> <TH>Valor</TH> <TH>Unidad</TH> <TH>Tipo de Valor</TH> <TH>Método</TH> <TH>Referencia</TH> </TR>
<xsl:for-each select="foodresponse/food/foodvalue">
<xsl:if test="not(./componentgroup_id = preceding::foodvalue/componentgroup_id)"> <TR> <TD style="color:#FFFFFF; background-color:#666600"><a style="color:#FFFFFF" href="javascript:void(0)"><xsl:attribute name="onclick">if (document.getElementById('<xsl:value-of select="cg_descripcion" />').display == 'none') document.getElementById('<xsl:value-of select="cg_descripcion" />').display = 'block'; else document.getElementById('<xsl:value-of select="cg_descripcion" />').display = 'none';</xsl:attribute><xsl:value-of select="cg_descripcion" /></a></TD> <TD style="color:#FFFFFF; background-color:#666600" /><TD style="color:#FFFFFF; background-color:#666600" /><TD style="color:#FFFFFF; background-color:#666600" /><TD style="color:#FFFFFF; background-color:#666600" /><TD style="color:#FFFFFF; background-color:#666600" /> </TR> <xsl:element name="div"> <xsl:attribute name="id"><xsl:value-of select="cg_descripcion" /></xsl:attribute> <xsl:call-template name="foodcomposition"> <xsl:with-param name="comptype" select="componentgroup_id" /> <xsl:with-param name="title" select="cg_descripcion" /> <xsl:with-param name="conversion" select="$factorc" /> </xsl:call-template> </xsl:element> </xsl:if>
</xsl:for-each>
................ And now the template I am calling ..........
<xsl:template name="foodcomposition"> <xsl:param name="comptype" /> <xsl:param name="title" /> <xsl:param name="conversion" /> <xsl:for-each select="../foodvalue"> <xsl:if test="componentgroup_id = $comptype"> <TR> <xsl:attribute name="class"> <xsl:if test="position() mod 2 = 1">row-a</xsl:if> <xsl:if test="position() mod 2 = 0">row-b</xsl:if> </xsl:attribute> <TD> <b><xsl:value-of select="c_ori_name" /></b> </TD> <xsl:choose> <xsl:when test="eur_name = 'ENERC'"> <xsl:choose> <xsl:when test="string(best_location) != ''"> <TD align="center"> <xsl:value-of select='format-number(0.01 * $conversion * best_location,"#")' /> (<xsl:value-of select='format-number(0.01 * $conversion * 0.24 * best_location,"#")' />) </TD> </xsl:when> <xsl:otherwise> <TD align="center"> </TD> </xsl:otherwise> </xsl:choose> <TD align="center"><xsl:value-of select="v_unit" /> (kcal)</TD> </xsl:when> <xsl:otherwise> <TD align="center"><xsl:value-of select='format-number(0.01 * $conversion * best_location,"#.##")' /></TD> <TD align="center"><xsl:value-of select="v_unit" /></TD> </xsl:otherwise> </xsl:choose> <TD align="center" style="cursor:help"><xsl:attribute name="title"><xsl:value-of select="vt_descripcion" /></xsl:attribute> <xsl:value-of select="value_type" /> </TD> <TD align="center"> <a href="javascript:void(0)"><xsl:attribute name="onclick">methodquery('<xsl:value-of select="method_id" />',document.getElementById('origen').innerHTML)</xsl:attribute><xsl:value-of select="method_id" /></a> </TD> <TD align="center"> <a href="javascript:void(0)"><xsl:attribute name="onclick">popUp(document.getElementById('refdet<xsl:value-of select="ref_id" />').innerHTML)</xsl:attribute><xsl:value-of select="ref_id" /></a> </TD> <div style="display:none"><xsl:attribute name="id">refdet<xsl:value-of select="ref_id"/></xsl:attribute> <B>Tipo de adquisición: </B> <xsl:value-of select="at_descripcion"/><br /> <B>Tipo de publicación: </B> <xsl:value-of select="pt_descripcion"/><br /> <B>Fecha de publicación: </B> <xsl:value-of select="pub_date"/><br /> <B>Autores: </B> <xsl:value-of select="authors"/><br /> <xsl:if test="pub_type = 'B'"> <B>ISBN: </B><xsl:value-of select="isbn"/><br /> <B>Número de edición: </B><xsl:value-of select="ednr"/><br /> <B>Fecha de la 1ª Edición: </B><xsl:value-of select="fed_dat"/><br /> <B>Número de páginas: </B><xsl:value-of select="n_pages"/><br /> </xsl:if> <xsl:if test="pub_type = 'AB'"><br /> <B>ISBN: </B><xsl:value-of select="isbn"/><br /> <B>Título del libro: </B><xsl:value-of select="bk_title"/><br /> <B>Editores: </B><xsl:value-of select="editors"/><br /> <B>Páginas: </B><xsl:value-of select="pages"/><br /> </xsl:if> <xsl:if test="pub_type = 'JI'"> <B>ISSN: </B><xsl:value-of select="issn"/><br /> <B>Volumen: </B><xsl:value-of select="volume"/><br /> <B>Número: </B><xsl:value-of select="issue"/><br /> <B>Nombre abreviado de la revista: </B><xsl:value-of select="abjr_name"/><br /> <B>Nombre completo de la revista: </B><xsl:value-of select="lgjr_name"/><br /> </xsl:if> <xsl:if test="pub_type = 'R'"> <B>ISBN: </B><xsl:value-of select="isbn"/><br /> <B>Nombre de la serie: </B><xsl:value-of select="seri_name"/><br /> <B>Número de la serie: </B><xsl:value-of select="seri_num"/><br /> </xsl:if> <xsl:if test="pub_type = 'AR'"> <B>Editores: </B><xsl:value-of select="editors"/><br /> <B>ISBN: </B><xsl:value-of select="isbn"/><br /> <B>Título del informe: </B><xsl:value-of select="rpr_title"/><br /> <B>Nombre de la serie: </B><xsl:value-of select="seri_name"/><br /> <B>Número de la serie: </B><xsl:value-of select="seri_num"/><br /> <B>Páginas: </B><xsl:value-of select="pages"/><br /> </xsl:if> <xsl:if test="pub_type = 'F'"> <B>Formato de archivo: </B><xsl:value-of select="file_frmt"/><br /> <B>URL: </B><xsl:value-of select="url"/><br /> </xsl:if> <xsl:if test="pub_type = 'SW'"> <B>Sistema operativo: </B><xsl:value-of select="op_system"/><br /> </xsl:if> <xsl:if test="pub_type = 'WW'"> <B>URL: </B><xsl:value-of select="url"/><br /> </xsl:if> <xsl:if test="pub_type = 'L'"> <B>Comentarios en español: </B><xsl:value-of select="com_esp"/><br /> <B>Comentarios en inglés: </B><xsl:value-of select="com_ing"/><br /> </xsl:if> <xsl:if test="pub_type = 'AJ'"> <B>ISSN: </B><xsl:value-of select="issn"/><br /> <B>Volumen: </B><xsl:value-of select="volume"/><br /> <B>Número: </B><xsl:value-of select="issue"/><br /> <B>Nombre abreviado de la revista: </B><xsl:value-of select="abjr_name"/><br /> <B>Nombre completo de la revista: </B><xsl:value-of select="lgjr_name"/><br /> <B>Páginas: </B><xsl:value-of select="pages"/><br /> </xsl:if> </div> </TR> </xsl:if> </xsl:for-each>
</xsl:template>
I don't now if the use of xsl:for-each or xsl:if is the reason why tag closes unexpectly
|
|
Reply By:
|
mhkay
|
Reply Date:
|
5/14/2008 7:02:47 AM
|
Can't see any obvious bug, I'm afraid. Try and trim it down to the bare essentials, and repost with a minimal source document, showing the desired output and the actual output.
Note that running in the browser is the worst imaginable development environment for XSLT debugging.
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|