Reputation: 138
I have inherited a static site built by java/xalan from xml pages.
The html tags in the head of each html doc are all the same included when the site is built. I would like to add a tag in individual xml pages that into which I can insert a tag for the head of that html page. In this case a canonical link tag to indicate duplicate content.
In my XML content page, I have added this:
<insertGoodness>link rel="canonical" href="path" /</insertGoodness>Note the absence of the greater than or less than characters.
In my XSL template, the node grabs the data from the xml page and outputs the link tag.
<xsl:variable name="insert_Goodness" select="$content/insertGoodness" />
<xsl:template match="insertGoodness">
<xsl:text disable-output-escaping="yes"><![CDATA[<]]></xsl:text>
<xsl:value-of select="$insert_Goodness/node()" />
<xsl:text disable-output-escaping="yes"><![CDATA[>]]>
</xsl:text>
</xsl:template>
And in my HTML template, I have inserted this in the head section where it should end up.
<insertGoodness />
Finally, on the html page, I get the output.
<link rel="canonical" href="path" />
As you can see, I have escaped the greater & less than charaters in the XSL template. Can I do this (put the entire link tag) in my xml content page though as I may want to insert more than one custon tag in the html head section?
I have tried all the escape tricks I can find (http://www.fileformat.info/info/unicode/char/003e/index.htm) with no luck. Is there a way?
Upvotes: 0
Views: 1473
Reputation: 138
I don't know if this is the best way, but it works and it's only temporary.
In my xsl template file
<xsl:template match="insertGoodness">
<xsl:variable name="tagContent1" select="$content/insertGoodness/node()" />
<xsl:value-of select="$tagContent1" disable-output-escaping="yes" />
</xsl:template>
And then in the xml page
<insertGoodness>
<![CDATA[<]]>link rel="canonical" href="path" /<![CDATA[>]]>
</insertGoodness>
Upvotes: 0