Link to home
Start Free TrialLog in
Avatar of Letterpart
LetterpartFlag for United Kingdom of Great Britain and Northern Ireland

asked on

XSLT to test "sameness" of parent and child attributes, and content of child

I would like to use XSLT to match if particular attribute values of a parent and child are the same, AND if the content of the child is a single space.

Given this simplified XML:
<data>
  <text aa="yes" bb="123.45" bc="maybe">
	  <subtext dd="no" ee="123.45" ff="yes"> </subtext>
  </text>
  <text aa="yes" bb="123.45" bc="maybe">
	  <subtext dd="no" ee="123.45" ff="yes">X</subtext>
  </text>
  <text aa="yes" bb="678.90" bc="maybe">
	  <subtext dd="no" ee="123.45" ff="yes"> </subtext>
  </text>
</data>

Open in new window



 
So, specifically using the test data shown above I am trying to match on these conditions:
  when the content of the subtext element only contains a single space
  AND
  the value of the ee attribute of the subtext element  matches the value of the bb attribute of the parent text element  
 
 
So, given the above XML, only the first subtext would match - the content is a single space and the value of the bb attribute of the text element matches the value of the ee attribute of the subtext element.


Can anyone help with this attribute testing and content testing puzzle?
ASKER CERTIFIED SOLUTION
Avatar of zc2
zc2
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Letterpart

ASKER

That's done the trick - thanks very much!
Thanks for your prompt assistance.
You are welcome!