Click to See Complete Forum and Search --> : XSLT : XML transform Sort/Choose?


aprema
08-10-2008, 08:44 AM
Hi

I have an XSLT that transfroms some XML however I only need those records that have either the following Key attribute values, I would also like these grouped togther. Can someone help - thx. (XML /XSLT att in zip file)

Indexes/Index/ReportEvent/@Key = 'licensing agreement' ">
Indexes/Index/ReportEvent/@Key = 'licensing offer' ">
Indexes/Index/ReportEvent/@Key = 'pc launch' ">

Kostas Zotos
08-12-2008, 02:45 PM
Hi,

There was also a space here (before the http) in your file and caused failure..:
xmlns:xsl=" http://www.w3.org/1999/XSL/Transform"

If I understood well may try something like this in your .xsl file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" indent="yes"/>

<xsl:variable name="Key1">licensing agreement</xsl:variable> <!-- Define a variable with our search value -->
<xsl:variable name="Key2">licensing offer</xsl:variable>
<xsl:variable name="Key3">pc launch</xsl:variable>

<xsl:template match="DrugNews">
<html>
<b>Summary of newly reported drugs in IMS Knowledge Link: </b> <br/>
<img src="DNImg.jpg"/>
<xsl:apply-templates select="Report"/>
</html>
</xsl:template>


<xsl:template match="Report">

<xsl:if test="Indexes/Index/ReportEvent[@Key=$Key1 or @Key=$Key2 or @Key=$Key3]">
<!-- use the boolean "or" to include more cases -->
<b>Headline (Title): </b>
<xsl:value-of select="Title"/>
<br/>
</xsl:if>

</xsl:template>

</xsl:stylesheet>

Cheers!

Kostas