Wednesday, 15 February 2012

xpath 1.0 : subset matches an attribute list? -



xpath 1.0 : subset matches an attribute list? -

in xml have elements attribute contains list of categories illustration : cat="a b c d"

is there possibility xpath 1.0 (i'm using xslt in firefox) homecoming elements subset of categories matches list?

for illustration :

subset(a c) cat(a b c) true

subset(d) cat(a c) false

subset(a c) cat(a b) false

thanks help.

here's code should want. xslt wrapper set variables.

<xsl:variable name="subset" select="a c" /> <xsl:variable name="matches" select="//*[translate($subset, concat(@cat, ' '), '') = '']" />

of course, may need tweak //* depending on kinds of elements you're trying match.

concatenating space @cat necessary if may have subset strings 'd' contain no spaces.

this code assumes category names single letters. if that's not case, allow me know.

xpath

No comments:

Post a Comment