Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 14th, 2008, 06:22 AM
Registered User
 
Join Date: May 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Tags closing problem

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

 
Old May 14th, 2008, 06:28 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

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
 
Old May 14th, 2008, 06:31 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
 
Old May 14th, 2008, 06:32 AM
Registered User
 
Join Date: May 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

 
Old May 14th, 2008, 06:35 AM
Registered User
 
Join Date: May 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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('refd et<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

 
Old May 14th, 2008, 07:02 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in closing the parent window from a popup rakesh.kashnia1 Javascript 4 July 9th, 2007 05:39 AM
problem with closing the child window swarnap Javascript How-To 4 November 16th, 2006 12:54 AM
Problem with closing popup fs22 Javascript 4 May 20th, 2004 09:37 AM
closing a project is a problem inside an addin... gbianchi Pro VB 6 2 September 1st, 2003 01:46 PM
Tomcat 5.0.7 custom tags problem acca JSP Basics 1 August 21st, 2003 04:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.