After making the XML valid it might look like this:
<xml>
<header>
<personDesc>
<person id="1234" sex="m" />
<person id="3456" sex="f" />
<person id="7890" sex="u" />
</personDesc>
</header>
<stext>
<u who="1234">
<s>
<w>Stuff I want</w>
<w>to select</w>
</s>
</u>
<u who="3456">
<s>
<w>Stuff I want</w>
<w>to select</w>
</s>
</u>
<u who="7890">
<s>
<w>stuff i don’t want</w>
<w>to select</w>
</s>
</u>
</stext>
</xml>
The XPath you might want to use in your XSL transformation is
/xml/stext/u[@who=/xml/header/personDesc/person[@sex!='u']/@id]/s
It means:
- give me all nodes
/xml/stext/u/s
- which have the
u/@who
attribute set to ... - the
person/@id
attribute which ... - is on persons having
@sex
attribute not equal tou
The transformation could look like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xml:space="default" exclude-result-prefixes="" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="no" indent="yes" />
<xsl:template match="/xml/stext/u[@who=/xml/header/personDesc/person[@sex!='u']/@id]">
id <xsl:value-of select="@who" /> <xsl:for-each select=".//text()"><xsl:value-of select="." /> </xsl:for-each></xsl:template>
<xsl:template match="text()">
</xsl:template>
</xsl:stylesheet>