For example:
//person[@id=\'abc123\']/@haircolor|/@weight\"
PS. there are lots of \"person\" records
Are you wanting to search for person nodes based on the value of multiple attributes. If that's the question then you can just use ands e.g.
//person[@id='abc123' and @haircolor='blue' and @weight='...']
If you want to search on a single attribute, but return the values of the other attributes, I would do something like this:
<xsl:template match="person[@id='abc123']">
<xsl:value-of select="@haircolor"/>
<xsl:value-of select="@weight"/>
</xsl:template>
Try this:
//person[@id='abc123']/@*[name()='weight' or name()='haircolor']
If you're using an XPath 2.0 processor, you may also use a prettier option:
//person[@id='abc123']/(@haircolor|@weight)`
Sample XML:
<X>
<Y ATTRIB1=attrib1_value ATTRIB2=attrib2_value/>
</X>
string xPath="/" + X + "/" + Y +
"[@" + ATTRIB1 + "='" + attrib1_value + "']" +
"[@" + ATTRIB2 + "='" + attrib2_value + "']"
XPath Testbed: http://www.whitebeam.org/library/guide/TechNotes/xpathtestbed.rhtm
If you are trying to get the values of the specified attributes I would suggest introducing a variable for the requested person.
<xsl:variable name="person" select="//person[@id = 'abc123']" />
After that you can get any attribute from the requested person by using the specified variable.
<xsl:value-of select="$person/@haircolor" />
<xsl:value-of select="$person/@weight" />