Re: AW: [xsl] two nodes (or attributes) matching each other

Subject: Re: AW: [xsl] two nodes (or attributes) matching each other
From: Jarkko.Moilanen@xxxxxx
Date: Mon, 28 Apr 2003 08:11:05 +0300
Lainaus "Zink, Juergen" <Juergen.Zink@xxxxxxxxxxxxxxxxxxxx>:

| Hi Jarkko,
| 
| my suggestion:
| 
|   <xsl:for-each
| select="/FINCCIS/User/Services/Service[.=/FINCCIS/Services/Service/@name]">
|     <p><xsl:value-of select="."/></p>
|   </xsl:for-each>
| 
| instead of all the other foreach loops. Just inside the html-tag.
| 

Ok, I chose this approach and it worked fine for matching the equal nodes. 
Then I tryed to do the same for the nodes that dont match each other:

 <xsl:for-each
 select="/FINCCIS/User/Services/Service[.!=/FINCCIS/Services/Service/@name]">
     <p><xsl:value-of select="."/></p>
 </xsl:for-each>


Now the problem is that when these two are combined in the template to be 
applied the list of collection is not exactly the one wanted. 

<xsl:for-each select="/XDoc/Editable/XDocUser/UserProfile/Services/Service
[.=/XDoc/Services/Service/@name]">
	<input type="checkbox" checked="checked"  name="service"
value="{.}"><xsl:value-of select="."/></input>
	<br/>
	</xsl:for-each>
	
<xsl:for-each select="/XDoc/Services/Service/@name
[.=/XDoc/Editable/XDocUser/UserProfile/Services/Service/node()='']">
	<input type="checkbox" name="service" value="{.}"><xsl:value-of
select="."/></input>
	<br/>
	</xsl:for-each>	

This would produce list of items were the list of similar values is correct,
Yes, so far so good. BUT in the latter part of my xslt code, the nodes (or
their values to be more exact) with similar are also included to the list. 

Aah, but then it came to my mind. I have to test whether the element to
compare with exists at all (or is empty). So since I saw the worth to write
this far, here is what was the answer:

<!-- To get the nodes that dont match -->
<xsl:for-each select="/XDoc/Services/Service/@name
[.=/XDoc/Editable/XDocUser/UserProfile/Services/Service/node()='']">
<input type="checkbox" name="service" value="{.}"><xsl:value-of
select="."/></input>
	<br/>
	</xsl:for-each>	

Other more simple solutions?

Cheers, 
Jarkko 


***************************************************
* Jarkko Moilanen                                 *
* Project Researcher, ITCM (www.itcm.org)         *
* Profound XML technology Expert                  *
* University of Tampere                           *
* Hypermedia Laboratory                           *
***************************************************

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


Current Thread