XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old October 23rd, 2002, 11:54 PM
MJEggertson MJEggertson is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Seattle WA
Posts: 863 MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 sec
Reputation Power: 8
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?

Reply With Quote
  #2  
Old October 24th, 2002, 12:27 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
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

Reply With Quote
  #3  
Old October 24th, 2002, 12:31 AM
MJEggertson MJEggertson is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Seattle WA
Posts: 863 MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 sec
Reputation Power: 8
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!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Applying template to marked up PCDATA


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway