Jump to content

Displaying children tags


DanielShillock
 Share

Recommended Posts

Hi everyone, I currently have a simple markup which mostly presents 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

Link to comment
Share on other sites

  • 2 weeks later...

Consider passing both the string and the node-set to your mark-up template. (XSLT 2 only) If you need to use XSLT 1.0, you can use the exsl:node-set function.

<xsl:template name="List" match="li"> <xsl:variable name="lnodes">  <li><xsl:copy-of select="node()"/></li></xsl:variable> 		  <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:with-param name="nodes" select="$lnodes"/>			</xsl:call-template>  </xsl:template> 

Now in your markup template you have the variable $text with the string "Make this bold" to compare for keywords and the nodes to print out when time. <xsl:apply-templates select="$lnodes"/> I hope that makes sense.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...