Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

question about CDATA

Status
Not open for further replies.

goneawol

Technical User
Apr 1, 2009
5
US
Hi, I am in a delimma that I cannot seem to figure out. I will explain the setup here. I have an XSL stylesheet , XML database that is constantly updated with information typed in from a java based program, it is then displayed on a public webpage. Now what I have on my XSL file to display is:
<for-each select="stuff/stuff/stuff"> then
<value-of select="stuff"></value-of> then i have output escaping disabled.
what I need to do , is get the CDATA from the xml database that is displayed as <stuff>
<![CDATA[<font color="green">TEXTHERE</font>]]>
</stuff>

My delimma is im trying to specify what displays on the webpage from particular strings such as.

<for-each select="stuff/stuff/stuff[tab='tabname']"> THAT works just fine, but I need to display the values in CDATA and I cannot figure out what to write :(, also, if I can display certain CDATA values that I specify, how do I do multiple values

Thanks!!
 
Not clear with all that pseudo abstraction. Maybe this.
[tt]
<xsl:for-each select="stuff_1/stuff_2/stuff_3">
<xsl:choose>
<xsl:when test="tab='tabname'">
<xsl:value-of select="stuff_4" disable-output-escaping="yes" />
</xsl:when>
<xsl:eek:therwise>
<xsl:value-of select="stuff_4" disable-output-escaping="no" />
</xsl:eek:therwise>
</xsl:choose>
</xsl:for-each>
[/tt]
 
HI, what I am trying to do, is this.
<for-each select="stuff/stuff[stuff='<![CDATA[<font color="green">TEXTHERE</font>]]>'" I want it to display a certain CDATA values, and I don't know how to do this, is this even possible? or can I do it like a value of select
im confused
thanks
 
What is stuff stuff? Do you report to your boss/tutor with stuff stuff?
 
><for-each select="stuff/stuff[stuff='<![CDATA[<font color="green">TEXTHERE</font>]]>'"
[tt]<for-each select="stuff/stuff[stuff='&lt;font color=&#x22;green&#x22;&gt;TEXTHERE&lt;/font&gt;'"[red]>[/red][/tt]
 
THANKS tsuji, you are the cure to all of my problems ;). Sorry about the unprofessional stuff/stuff I put on there , but it is classified as to what I am actually doing, but thank you!
 
Hi, is it possible to do multiple <for-each select> to specify multiple criteria? or is their an easier way of doing it, thanks
 
>multiple criteria
Depending on the exact need, sure, such as this.
[tt] <for-each select="stuff/stuff[stuff='&lt;font color=&#x22;green&#x22;&gt;TEXTHERE&lt;/font&gt;' and tab='tabname']">[/tt]
 
tsuji,
thanks for all of the help you have given me so far.
<for-each select="stuff/stuff[stuff='&lt;font color=&#x22;green&#x22;&gt;TEXTHERE&lt;/font&gt;' and tab='tabname']">

did not work so I need to try somthing else. I'm going to try and explain my situation here. I'm an air traffic controller in Iraq, and I am trying to develop an easy way for us to see active airspace. We get our info from one source, they type in active airspace/altitudes etc through a java based program and it posts into a data.xml file. what im searching is for certain grids. the formula to get the information in the CDATA worked awesome ...but only problem is the person who is 100 miles away typing in the 6 digit airspace tile has to write this verbatim. so If I tell it that I want 99aa24 and the person accidently adds 99aa24' with a comma at the end, its not going to pick it up. What my goal is , I wanna be able to search a range of values, that is in this .xml file and display say all of 99aa and 88aa. etc..is this possible or am I just going over my head? LOL I'm learning XML please bare with me, you have been great!
 
I can show you a little xsl document to demonstrate how you retrieve all those using multiple criteria in certain format before I am done with this thread. It uses quite a number of fine-grain controls that you may find as useful leads to become more agile in using xsl.
[tt]
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="[ignore][/ignore]">
<xsl:eek:utput method="xml" encoding="utf-8" indent="yes" />
<xsl:template match="/">
<root>
<xsl:for-each select="//*[count(*)=0 and (starts-with(normalize-space(.),'99aa') or starts-with(normalize-space(.),'88aa'))]">
<xsl:copy>
<xsl:value-of select="normalize-space(.)" />
</xsl:copy>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
[/tt]
In any case, you have a project and have something to get you started. I may not have the patience, no, I have not most of the time, to help every time one asks. My sympathy goes to all those who live in that troubled land---maybe you share that sentiment, maybe you don't---in any case, good luck to your project!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top