[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

match and not match using If

Subject: match and not match using If
From: "Rahul Singh rahulsinghindia15@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 17 Sep 2016 15:44:22 -0000
 match and not match using If
I have created positive and negative XSLTs with below codes with match and
not match if, but not working:

*1. This was when $tranFile/objects/Contact[ID__c = $aN] then need all data
with corresponding <contactID> in each record:*

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/
1999/XSL/Transform">
    <xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
    <xsl:strip-space elements="*"/>
    <xsl:param name="tranFile" select="document('new5.xml')"/>
    <xsl:template match="Informations">
        <Informations>
            <xsl:for-each select="Information">
                <xsl:variable name="aN" select="no"/>
                <xsl:if test="$tranFile/objects/Contact[ID__c = $aN]">
                    <xsl:copy>
                        <contactID><xsl:value-of select="$tranFile/objects/
Contact/Id"/></contactID>
                        <xsl:apply-templates/>
                    </xsl:copy>
                </xsl:if>
            </xsl:for-each>
        </Informations>
    </xsl:template>
    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>


*2. And, same i have tested with negating code when *
$tranFile/objects/Contact[ID_c!= $aN] *:*


<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1
999/XSL/Transform">
    <xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
    <xsl:strip-space elements="*"/>
    <xsl:param name="tranFile" select="document('new5.xml')"/>
    <xsl:template match="Informations">
        <xsl:choose>
            <xsl:when test="$tranFile/objects = ''">
                <Informations>
                    <xsl:copy-of select="Information"/>
                </Informations>
            </xsl:when>
            <xsl:when test="$tranFile/objects! = ''">
                <Informations>
                    <xsl:for-each select="Information">
                        <xsl:variable name="aN" select="no"/>
                        <xsl:if test="not($tranFile/objects/Contact[ID_c=
$aN])">
                            <xsl:copy>
                                <xsl:apply-templates select="."/>
                            </xsl:copy>
                        </xsl:if>
                    </xsl:for-each>
                </Informations>
            </xsl:when>
        </xsl:choose>
    </xsl:template>
    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.