xslt send variable to another template -
i have xml example this:
<p class="exer_header" style="display: none;"> <image-input size="5" value="val1" /> </p> <p class="exer_header" style="display: none;"> <image-input size="5" value="val2" /> </p> <answers-img> <answer-img class="imagednd_answer1" value="val1"/> <answer-img class="imagednd_answer2" value="val2"/> </answers-img> and xslt ex. here:
<xsl:template match="image-input"> <xsl:variable name="id" select="generate-id(.)"/> <xsl:element name="input"> <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute> <xsl:attribute name="class">exer_input</xsl:attribute> </xsl:element> </xsl:template> <xsl:template match="answers-img"> <xsl:for-each select="//image-input"> <xsl:element name="div"> <xsl:element name="input"> <xsl:attribute name="class">ans_img_input</xsl:attribute> <xsl:attribute name="type">hidden</xsl:attribute> <xsl:attribute name="value">***{id}***</xsl:attribute> </xsl:element> <xsl:apply-templates select="//answers-img/answer-img"/> </xsl:element> </xsl:for-each> </xsl:template> question next, how can send variable id "input" template "answers-img" template , change {id}?
upd: in "answer-img" need same id's generates in "input-img". first xslt generate code "input-img"(twice) , when somewhere templates, not in "input-img", call template "answer-img". maybe can create global array variable?
use xsl:with-param
i don't know want call template can done this:
<xsl:call-template name="answers-img"><xsl:with-param name="id" select="$id" /></xsl:call-template> you must add calling template:
<xsl:param name="id" />
Comments
Post a Comment