|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Applying template to marked up PCDATA
Say I have element definitions like so:
Code:
<!ELEMENT root (#PCDATA|markup1|markup2)*> <!ELEMENT markup1 (#PCDATA)> <!ELEMENT markup2 (#PCDATA)> An example would be, Code:
<root>
This is some<markup1>text</markup1>.
Some of the words are <markup2>important</markup2>.
</root>
And the xsl templates may be something like: Code:
<xsl:template match="/">
<html>
<body>
<!-- Parsed content should go here. -->
</body>
</html>
</xsl:template>
<xsl:template match="markup1">
<span color="green"><xsl:value-of select="." /></span>
</xsl:template>
<xsl:template match="markup2">
<span color="blue"><xsl:value-of select="." /></span>
</xsl:template>
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? |
|
#2
|
|||
|
|||
|
You need a template rule to match text nodes. Then you can use apply-templates.
<xsl:template match="text()"> <xsl:value-of select="." /> </xsl:template>
__________________
-james |
|
#3
|
|||
|
|||
|
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... Anyways, thanks! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Applying template to marked up PCDATA |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|