I have a section called Products
where every product is defined by Text Input
and Multilingual Text Box
. I have created over 100 products with custom description. At some point I need to place current year in Multilingual Text Box
:
Lorem ipsum dolor <xsl:value-of select="$this-year" /> ipsum <a href="{$root}">Link to root</a>
which gives:
'Long Description' contains invalid XML. The following error was returned: loadXML(): Namespace prefix xsl on value-of is not defined in Entity
or I want to print data from Data Source:
Lorem ipsum
<xsl:variable name="products" select="/data/products" />
<xsl:for-each select="$products">
//... do other XSL stuff in XML
</xsl:for-each>
which of course will cause error too.
Please take in account that I am total beginner in Symphony/XSLT and some of conceptions are still not well understood by me.
Symphony community helped me with this subject, so let me just quote jonmifsud:
The easiest way to do that would be using what’s called the XSLT ninja technique. Simplest way (...) would be to create html tags which are to be replaced. For example we can ask him to input
<this-year/>
in the text where you want this year variable to appear which means when you output text you are using<xsl:apply-template select=‘your-text’ mode=‘html'/>
. Now the trick with the XSLT would be the following: you will need to match the new “tag” you created for your variable and replace it with the values you want
Example
<xsl:template match="this-year" mode="html">
<xsl:value-of select="/data/params/this-year">
</xsl:template>
<xsl:template match="*" mode="html">
<xsl:element name="{name()}">
<xsl:apply-templates select="* | @* | text()" mode="html"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*" mode="html">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
This approach is nearly limitless.