0 Replies - 491 Views - Last Post: 02 December 2009 - 06:44 AM

#1 Celledor   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 03-October 08

XSL for-each Contains

Posted 02 December 2009 - 06:44 AM

Hey,

I'm trying to filter a document using contains().

Example XML (the real one is more complex):
<?xml version="1.0" encoding="utf-8"?>
<Root>
  <CSearch>
	253
  </CSearch >
  <Object>
	<A ID="86">
	  <Stuff>Something</Stuff>
	</A>
	<B ID="13">
	  <Stuff>Something</Stuff>
	</B>
	<CNodes>
	  <C ID="135">
		<Stuff>Something</Stuff>
	  </C>
	  <C ID="253">
		<Stuff>Something</Stuff>
	  </C>
	</CNodes>
  </Object>
  <Object>
	<A/>
	<B/>
	<CNodes>
	  <C ID="632">
		<Stuff>Something</Stuff>
	  </C>
	  <C ID="253">
		<Stuff>Something</Stuff>
	  </C>
	</CNodes>
  </Object>
</Root>




What I want to do is: only do stuff to the Objects that has a C with the ID in CSearch.

<xsl:for-each select="//Root/Object
[contains(CNodes/C/@ID, //Root/CSearch)]>
Do stuff...
</xsl:for-each>

The real one has lots more things between the [] that uses contains and works fine but it seems that the contains only looks in the first <C> tag and not the rest. So in the the example it will never find the C with ID 253.

Any way to solve this?

This post has been edited by Celledor: 02 December 2009 - 06:49 AM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1