I have a pretty strange problem in one of my projects. I have created a node width a property called "title". This property is based on the "Simple editor"-data type.
When I want to render the content of the editor I usuallt use something like this:
The so-called "strong" tags were never actual elements - they are plain text (just as is the problem with Rich Text Editor content).
If you need to handle them as XML, you can use the uComponents Parse() extension function to convert the content into XML. (Yes, I'm actually writing about that at the moment... :-)
But neither of those are "real" XML and thus, xsl:apply-templates will effectively apply the built-in template for text() and output the text, while maintaining escaping of entities.
Only when you bypass the escaping (using disable-output-escaping on the xsl:value-of instruction) will you be able to "convert" the escaped tags to something that the browser will interpret as HTML tags. But the XSLT processor never actually "see" them as <strong> elements.
I actualy think that I've found the solution (before tryuing out your suggestions guys - sorry :) ).
In my "main"-xslt file I've imported some more xslt files just as I have imported the one I had the problem with above. And in one of those imported xslt files there was another template that matched "title" as well. And of course this template was in a file imported later in the "main"-xslt file. Meaning that the template I where actually hitting was the one in another file who didn't have the disable-output-escaping="yes". I tried setting a mode on my title-template above (shown below), and now everything works just as I wanted.
I didn't catch what you we're *actually* baffled about...
The mode parameter is a good way to solve conflicting template issues, because you can use your own mode names, and essentially explain to yourself (or future readers of the code) what's going on.
Weird problem using apply-templates
I have a pretty strange problem in one of my projects. I have created a node width a property called "title". This property is based on the "Simple editor"-data type.
When I want to render the content of the editor I usuallt use something like this:
The above code is placed in a xslt-file and imported in another xslt-file. So I'm calling the template from the "main"-xslt file like this:
The XML of the $itm/title looks like this:
But here's the weird part:
When using the apply-templates method the <strong>-thml elements are shown on the frontend.
But if I'm using a value-of like this:
The text is rendered the right way, with bold "Order".
What's going on here?
/Kim A
Hi Kim,
The so-called "strong" tags were never actual elements - they are plain text (just as is the problem with Rich Text Editor content).
If you need to handle them as XML, you can use the uComponents Parse() extension function to convert the content into XML. (Yes, I'm actually writing about that at the moment... :-)
/Chriztian
I would think it has something to do with the output type of the XSLT (method=html or method=xml).
Apply templates should work if you set the method to html, right ?
To clarify:
The XML content of the $itm/title actually looks like this:
or (which is exactly the same):
But neither of those are "real" XML and thus, xsl:apply-templates will effectively apply the built-in template for text() and output the text, while maintaining escaping of entities.
Only when you bypass the escaping (using disable-output-escaping on the xsl:value-of instruction) will you be able to "convert" the escaped tags to something that the browser will interpret as HTML tags. But the XSLT processor never actually "see" them as <strong> elements.
/Chriztian
Hmm....
I actualy think that I've found the solution (before tryuing out your suggestions guys - sorry :) ).
In my "main"-xslt file I've imported some more xslt files just as I have imported the one I had the problem with above. And in one of those imported xslt files there was another template that matched "title" as well. And of course this template was in a file imported later in the "main"-xslt file. Meaning that the template I where actually hitting was the one in another file who didn't have the disable-output-escaping="yes". I tried setting a mode on my title-template above (shown below), and now everything works just as I wanted.
Thanks for your suggestions anyway :)
/Kim A
Great Kim,
Sometimes we just try to fix the wrong problem :)
I didn't catch what you we're *actually* baffled about...
The mode parameter is a good way to solve conflicting template issues, because you can use your own mode names, and essentially explain to yourself (or future readers of the code) what's going on.
/Chriztian
Guess we were already digging to deep, still some lessons learned tho.
Glad you got it working!
is working on a reply...