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!

last stupid question of the day (saved ! :-)

Status
Not open for further replies.

tyris

Programmer
Nov 2, 2000
311
FR
hi all
i do have a xml structure this way :


Code:
<results dbname=&quot;Sales & Marketings&quot;>
	<searchview name=&quot;AllDocs&quot;>
		<result>
			<url>[URL unfurl="true"]http://etc</url>[/URL]
			<icon>150</icon>
			<icon>171</icon>
			<description>abcdef</description>
		</result>
		<result>
			<url>[URL unfurl="true"]http://etc</url>[/URL]
			<icon></icon>
			<icon>172</icon>
			<description>jaehdeg</description>
		</result>
		<result>
			<url>[URL unfurl="true"]http://etc</url>[/URL]
			<icon></icon>
			<icon></icon>
			<description>adhthsdgz</description>
		</result>		
	</searchview>
</results>

what i want is :
if in a the icon tag is empty, put the description in bold, else do not put the description in bold and put the icon url.
well in fact i just want to know how could i expres this :
&quot;if icon tag is empty do this, else do this&quot; in xslt ?

my namespace is (MS XSL 3)

sorry for my english, i'm french Best regards X-),
Elise
 
sorry some precisions :
the test i'd like to do is :

&quot;if ALL icon tag are empty do this, else do this&quot; Best regards X-),
Elise
 
i have found how to test an empty tag :
Code:
<xsl:for-each select=&quot;icon&quot;>
	<xsl:choose>
		 <xsl:when test='. != &quot;&quot;'>
	       	    <img src=&quot;[URL unfurl="true"]http://10.2.75.100/icons/vwicn{.}.gif&quot;/>[/URL]
	       </xsl:when>
		<xsl:otherwise>
		</xsl:otherwise>
	</xsl:choose>				
</xsl:for-each>
now for the test : &quot;if ALL icon tag are empty do this&quot; i think that i should do something like :
Code:
<xsl:for-each select=&quot;result&quot;>
	if ... count(icon!=&quot;&quot;) = 2 then ... 
</xsl:for-each>
(because i will never have more than 2 icon tags)

but how to do this ? i tryed this :
Code:
<xsl:for-each select=&quot;result&quot;>
	<xsl:value-of select='count(icon!=&quot;&quot;)'/>
</xsl:for-each>
and i do get this error : Expression does not return a DOM node. -->count(icon!=&quot;&quot;)<--

so here is a first problem. second question : how to use the count result in a test like what i wrote above ( if count = 2 then..)

any help would be appreciated

Best regards X-),
Elise
 
i do have a bagin of solution but...

well i tryed this :
Code:
<xsl:for-each select=&quot;result&quot;>
	<xsl:choose>
	<xsl:when test='count(result[icon=&quot;&quot;]) = 2'>
		here i put in bold
	</xsl:when>
	<xsl:otherwise>
		blah
	</xsl:otherwise>			
	</xsl:choose>
</xsl:for-each>
the problem is that count(result[icon=&quot;&quot;]) always returns me 0. i guess there is a syntax problem, but where ?
Best regards X-),
Elise
 
i found what i wanted to do :

<xsl:when test='(&quot;&quot; != icon) = false'>
Best regards X-),
Elise
 
Elise -

Thanks for posting all the replies (to yourself!).

I don't really know XSL, but could you have done a count of icon elements that have a non-empty value? If the count > 0, then you know that one or more have a value.

Chip H.
 
yep that's what i wanted to do but this solution is simplier :
this compares a string ('') to a nodeset (icon).

The comparison of string to a nodeset is true if the comparison is true for
at least one of the nodes of the nodeset.
Best regards X-),
Elise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top