This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: compare 2 node set???


> 	How can run through 2 different set of nodes & compare 
> whether set 1 exists within set 2 ???

I shall assume that you regard two nodes as matching if they have the
same string-value. Then you test is "is it true that for every node in
set 1 there is a node in set 2 that is equal to it?"

In XPath 2.0 this is:

every $x in $set1 satisfies
   some $y in $set2 satisfies
      $x eq $y

In XPath 1.0 you have to be a bit more inventive, but it's still
possible:

not($set1[not(.=$set2)])

Read that as "there is no node in $set1 that satisfies the condition
that there is no node in $set2 that is equal to it."

Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com 



> 	i.e do a recursive search.... I am able to process in 
> case the node is present in both sets but how do I go ahead 
> in case it is not. i.e how can I keep track in case the node 
> does not exist in the other set... Following is the code...
> 
> <xsl:stylesheet version="1.0"
>       xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>       xmlns:ms="urn:schemas-microsoft-com:xslt">
> 
> 	
> 	<xsl:param name="file1" 
> select="document('d:/aruniima/CompareXml/Validator_Response.xm
> l')" /> <xsl:template match="/"> <html> <body>
> 	<table>
> 		<xsl:for-each select="$file1//SrcData/*">
> 		<td><xsl:variable name="node_1" select="name()"/></td>
> 			<xsl:value-of select="$node_1"/>
> 			<tr>
> 				<xsl:call-template name="search">
> 					<xsl:with-param name="node_res"
> select="$node_1"/>
> 				</xsl:call-template>
> 			</tr>	
> 		</xsl:for-each>
> 	</table>
> </body>
> </html>
> </xsl:template>
> <xsl:template name="search">
> <xsl:param name="node_res"/>
> 	<xsl:for-each select="//SrcData/*">
> 			<xsl:variable name="node_2" select="name()"/>	
> 			<xsl:call-template name="compare">
> 				<xsl:with-param name="node_response"
> select="$node_res"/>		
> 				<xsl:with-param name="node_request"
> select="$node_2"/>
> 			</xsl:call-template>
> 	</xsl:for-each>			
> </xsl:template> 
> <xsl:template name="compare">
> <xsl:param name="node_response"/>	
> <xsl:param name="node_request"/>
> 		<xsl:if
> test="ms:string-compare($node_response,$node_request) = 0">
> 			<xsl:call-template name="display">
> 				<xsl:with-param name="status"
> select="'Present'"/>		
> 				<xsl:with-param name="in_request"
> select="$node_response"/>
> 			</xsl:call-template>
> 		</xsl:if>
> </xsl:template>
> <xsl:template name="display">
> <xsl:param name="status"/>	
> <xsl:param name="in_request"/>
> 	<td><xsl:value-of select="$in_request"/></td>
> 	<td><xsl:value-of select="$status"/></td>
> </xsl:template>
> </xsl:stylesheet>
> 
> Regards,
> aruniima
> 
> 
> --------------------------------------------------------------
> --------------
> 
> This message contains privileged and confidential information 
> and is intended only for the individual named. If you are not 
> the intended recepient you should not disseminate, 
> distribute, store, print, copy or deliver this message. 
> Please notify the sender immediately by e-mail if you have 
> received this e-mail by mistake and immediately delete this 
> e-mail from your system.
> 
> 
> E-mail transmission cannot be guaranteed to be secure or 
> error-free as information could be intercepted, corrupted, 
> lost, destroyed, arrive late or incomplete, or contain 
> viruses. The sender therefore does not accept liability for 
> any errors or omissions in the contents of this message which 
> arise as a result of e-mail transmission.  If verification is 
> required please request a hard-copy version.
> 
> 
> --------------------------------------------------------------
> ------------
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]