xslt 1.0 - Need to group xsl:for-each-group with Muenchian method -
i not able retrieve unique list applying muenchian method. trying group based on "series title" attribute
sample input xml: <?xml version="1.0" encoding="utf-8" standalone="yes"?> <distribution> <manifestheader> <assets> <asset> <id>23341528</id> <createdate>2008-01-14t17:02:01z</createdate> <metadatas> <metadata name="psa.orig.source.showtitle">green home 2008</metadata> <metadata name="displayruntime">00:01</metadata> <metadata name="series title">desperate landscapes</metadata> </metadatas> </asset> <asset> <id>23341529</id> <createdate>2010-08-23t15:44:58z</createdate> <metadatas> <metadata name="psa.orig.source.showtitle">urban oasis 2010</metadata> <metadata name="displayruntime">00:02</metadata> <metadata name="series title">toy hunter</metadata> </metadatas> </asset> <asset> <id>23377202</id> <createdate>2007-05-18t07:40:25z</createdate> <metadatas> <metadata name="webseries"/> <metadata name="psa.orig.source.showtitle">cool tools</metadata> <metadata name="displayruntime">00:20</metadata> <metadata name="series title">desperate landscapes</metadata> </metadatas> </asset> </assets> </manifestheader> </distribution>
xlst:
<xsl:key name="keyseriesname" match="metadata[@name='series title']" use="text()" /> <xsl:for-each select="metadata[@name='series title'][generate-id() = generate-id(key('keyseriesname', text())[1])]"> tried: <xsl:for-each select="metadata[@name='series title'][count(. | key('keyseriesname',text())[1]) = 1]">
anyhelp appreciated
thanks in advance
since <metadata>
elements children of <metadata>
, trying search across entire collection of them within document, going need adjust xpath ensure addressing of them:
/distribution/manifestheader/assets/asset/metadatas/metadata [@name='series title'][generate-id() = generate-id(key('keyseriesname', text())[1])]
or use shorter, less efficient:
//metadata[@name='series title'][generate-id() = generate-id(key('keyseriesname', text())[1])]
Comments
Post a Comment