I'm having trouble with an if condition in my code. If I have two sets of nodes with similar subtrees and put an if not condition in my code then it fails the entries.
Over here I'm trying to show entries that don't have an entry containing "imp" or "Imp"
This is a simplified version of my actual code, but I'm having trouble with this
<xsl:stylesheet xmlns:xsl="http://ift.tt/tCZ8VR" version="2.0">
<xsl:strip-space elements="*"/>
<xsl:output method="xml" indent="yes" omit-xml-declaration="no" media-type="application/xml" standalone="yes"/>
<xsl:template match="/">
<xsl:if test="GSP/RES/R/MT[@N='fe'][@V='true'] and not(GSP/RES/R/MT[@N='sc'][contains(@V, 'imp') or contains(@V, 'Imp')])">
<menuSection>
<header>
<horizontalDivider alignment="center">
<title>Some Stuff </title>
</horizontalDivider>
</header>
<items>
<xsl:for-each select="GSP/RES/R">
<xsl:if test="GSP/RES/R/MT[@N='fe'][@V='true'] and not(GSP/RES/R/MT[@N='sc'][contains(@V, 'imp') or contains(@V, 'Imp')])">
--some stuff
</xsl:if>
</xsl:for-each>
</items>
</menuSection>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
and this is a simplified version of my xml
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<GSP VER="3.2">
<RES SN="1" EN="2">
<R N="1">
<MT N="fe" V="true"/>
<MT N="sc" V="low-pri"/>
</R>
<R N="2">
<MT N="fe" V="true"/>
<MT N="showcode" V="imp"/>
</R>
</RES>
</GSP>
if I remove the and condition on the first if
and not(GSP/RES/R/MT[@N='sc'][contains(@V, 'imp') or contains(@V, 'Imp')])
then the second if works correctly and shows me the entry for
<R N="1">
If I keep the first if as is then I don't get the "Some Stuff" header and the rest of it doesn't show either.
Aucun commentaire:
Enregistrer un commentaire