0
votes

I am trying to have a template call another template that creates a simple XML node with a plain value. My real tasks is hard but I simplified to just get something working.

Note: I've seen some examples here but I don't get the same results, I can't see what I am doing wrong.

I want to end of with this:

<keyword>abc-company.com</keyword>
<keyword>test</keyword>
<keyword>ABC Company</keyword>

but I keep ending up with this:

<keyword>abc-company.com</keyword>
<keyword/>
<keyword>ABC Company</keyword>

I am purposely returning a plain string value, but eventually I want to pass in a value, change it and return a value for the elements but I simplified it for this example.

<xsl:template name="keywords">
    <xsl:param name="metas_branding"/>
    <xsl:param name="metas_keywords"/>
    <xsl:param name="ad_branding"/>
    <keyword><xsl:value-of select="$metas_branding"/></keyword>
     <xsl:call-template name="csvToNodes">
             <xsl:with-param name="csvString" select="$metas_keywords"/>
    </xsl:call-template>
    <keyword><xsl:value-of select="$ad_branding"/></keyword>
</xsl:template>

<xsl:template name="csvToNodes">
    <xsl:param name="csvString"/>
    <xsl:element name="'keyword'">
            <xsl:value-of select="test"/>
    </xsl:element>
</xsl:template>
1
Please always post a reproducible example - see minimal reproducible example.michael.hor257k
In particular, we need to see the input document.Michael Kay
I have rolled your question back to what it was when I answered it. Please start a new question with your radically different requirements. Make sure to include an example of your XML input and a complete stylesheet that can be executed as is - something you have failed to provide here, despite being asked several times.michael.hor257k

1 Answers

0
votes
<xsl:value-of select="test"/>

is looking for a an element name test, child of the current element. I guess your XML does not have such element (or perhaps it does, but it's empty), so the returned value is an empty string.

You probably meant to write:

<xsl:value-of select="'test'"/>