Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: How to do conditional formatting of output string(concatinate) >Thread Next - Re: How to do conditional formatting of output string(concatinate) Re: How to do conditional formatting of output string(concatinate)To: NULL Date: 3/6/2009 1:21:00 PM Zest4Quest wrote:
> Hi Martin
> The XML Input is given below
> - <Assessment>
> - <Respiratory>
>
> <Forced>false</Forced>
> <Irregular>false</Irregular>
> <Kussmal>true</Kussmal>
> <Labored>true</Labored>
> <NasalFlaring>true</NasalFlaring>
> <Normal>false</Normal>
> <Rapid>false</Rapid>
>
> </Respiratory>
> </Assessment>
>
> The Output should be the following (based on the value of true/false) as
> HTML..
>
> Respiratory condition: Kussmal condition,Labored condition, Nasal Flaring
Here is an example that simply processes those elements having the
contents 'true':
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<html>
<body>
<p>Respiratory condition:
<xsl:for-each select="Assessment/Respiratory/*[. = 'true']">
<xsl:value-of select="concat(name(), ' condition')"/>
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
When run against your XML input it outputs
<html>
<body>
<p>Respiratory condition:
Kussmal condition, Labored condition, NasalFlaring condition
</p>
</body>
</html>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
