I currently have a simple markup which mostly represents HTML.
Below is a snippet of that
<li>Make this <b>Bold</b></li>
I can of course use <xsl:copy-of> to ensure that the <b> tag is passed through and is automatically displayed as bold, however I have a problem.
I am using another XSL which checks the markup against a repository of keywords or phrases and if they exist, links are created.
Below is my XSL
<xsl:template name="List" match="li">
<li>
<xsl:call-template name="markup">
<xsl:with-param name="text" select="."/>
<xsl:with-param name="phrases" select="document('../../documents/main/keywords.xml')/keywords/keyword"/>
<xsl:with-param name="first-only" select="false()"/>
</xsl:call-template>
</li>
</xsl:template>
This method prevents any child tags being passed through, however I am unsure as to how I can get around this.
Any help is greatly appreciated!
Dan
The problem is that your link-creating template does the wrong thing.
The right thing to do is using the identity template and creating a dedicated template for text node descendants of
<li>elements.Try this:
The identity template is the key to successfully solving problems like this one. It handles copying the
<li>and the<b>transparently.<xsl:template name="List">. This is “push style” XSLT, i.e. it’s imperative and often leads to pretty clumsy results.<xsl:template match="li//text()">pulls nodes out of the stream and does something more complex than just copying them. This is “pull style” XSLT, i.e. template matching. It usually is easier to handle and produces cleaner XSLT code.<li>elements, of course. Just change the match expression to affect other nodes.Say you want to turn all
<b>nodes into<strong>without disrupting any other templates. With pull style, this is as easy as this:Also note that the current node does not change when you do
<xsl:call-template>. Therefore there is no need to pass in the current node to a called template.