L
Leo
I would like to transfer my XML file into another XML which has a struct like this:
<catalog>
<media>
<cd>myCD</cd>
</media>
</catalog>
However using my XSLT I could only get:
<catalog>myCD</catalog>
Can you please point out where my problem is? Thanks very much in advance.
Leo
<xsl:template name="catalog">
<xsl:call-template name="mytemplate">
<xsl:with-param name="ename">catalog</xsl:with-param>
<xsl:with-param name="evalue">
<xsl:choose>
<xsl:when test="/myxpath">
<xsl:call-template name="mytemplate">
<xsl:with-param name="ename">media</xsl:with-param>
<xsl:with-param name="evalue">
<xsl:call-template name="mytemplate">
<xsl:with-param name="ename">cd</xsl:with-param>
<xsl:with-param name="evalue" select="/myxpath1"/>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
...
<xsl:template name="mytemplate">
<xslaram name="etext"/>
<xslaram name="ename"/>
<xslaram name="evalue"/>
<xsl:if test="($evalue!='') and ($evalue!='none')">
<xsl:element name="{$ename}">
<xsl:if test="($etext!='')">
<xsl:value-of select="$etext"/>
</xsl:if>
<xsl:value-of select="$evalue"/>
</xsl:element>
</xsl:if>
</xsl:template>
<catalog>
<media>
<cd>myCD</cd>
</media>
</catalog>
However using my XSLT I could only get:
<catalog>myCD</catalog>
Can you please point out where my problem is? Thanks very much in advance.
Leo
<xsl:template name="catalog">
<xsl:call-template name="mytemplate">
<xsl:with-param name="ename">catalog</xsl:with-param>
<xsl:with-param name="evalue">
<xsl:choose>
<xsl:when test="/myxpath">
<xsl:call-template name="mytemplate">
<xsl:with-param name="ename">media</xsl:with-param>
<xsl:with-param name="evalue">
<xsl:call-template name="mytemplate">
<xsl:with-param name="ename">cd</xsl:with-param>
<xsl:with-param name="evalue" select="/myxpath1"/>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
...
<xsl:template name="mytemplate">
<xslaram name="etext"/>
<xslaram name="ename"/>
<xslaram name="evalue"/>
<xsl:if test="($evalue!='') and ($evalue!='none')">
<xsl:element name="{$ename}">
<xsl:if test="($etext!='')">
<xsl:value-of select="$etext"/>
</xsl:if>
<xsl:value-of select="$evalue"/>
</xsl:element>
</xsl:if>
</xsl:template>