October 23rd, 2002, 11:54 PM
Applying template to marked up PCDATA
Say I have element definitions like so:
An example would be,
<!ELEMENT root (#PCDATA|markup1|markup2)*>
<!ELEMENT markup1 (#PCDATA)>
<!ELEMENT markup2 (#PCDATA)>
And the xsl templates may be something like:
This is some<markup1>text</markup1>.
Some of the words are <markup2>important</markup2>.
I can't figure out how to apply the templates in their node's position relative to the parsed character data. Using an apply-templates directive only returns applied child nodes, and a value-of directive on the root element doesn't apply the child node templates. How do you do it?
<!-- Parsed content should go here. -->
<span color="green"><xsl:value-of select="." /></span>
<span color="blue"><xsl:value-of select="." /></span>
October 24th, 2002, 12:27 AM
You need a template rule to match text nodes. Then you can use apply-templates.
<xsl:value-of select="." />
October 24th, 2002, 12:31 AM
Well, yeah, that's what I thought.
It's working now. I still have no clue why it wasn't earlier. I swear I did that, I even said that it didn't work because I tried it. I must have had a typo, weird though that it still validated...