Guest johnclive Posted February 23, 2007 Share Posted February 23, 2007 Hi everyone. I'm newbie with XML and XSLT and I have this problem.My XML file is in this format<?xml version="1.0"?><?xml-stylesheet type='text/xsl' href='ll.xslt'?><DocumentContent><VUSTAG Site="AON" Lat="Right"><VASMEAS AG="CCA" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="80" Unit="cm/s"/><VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="88" Unit="cm/s"/><VASMEAS AG="CCA" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="84" Unit="cm/s" DE="Mean"/><VASMEAS AG="CCU" TM="PR" VBr="ME" CP="ES" EP="PP" Name="PSV" NumericValue="80" Unit="cm/s"/><VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="88" Unit="cm/s"/><VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="84" Unit="cm/s" DE="Mean"/></VUSTAG><VUSTAG Site="AON" Lat="Left"><VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="80" Unit="cm/s"/><VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="88" Unit="cm/s"/><VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="84" Unit="cm/s" DE="Mean"/><VASMEAS AG="CCA" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="80" Unit="cm/s"/><VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="88" Unit="cm/s"/><VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="84" Unit="cm/s" DE="Mean"/></VUSTAG></DocumentContent>My xslt file is<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/><xsl:key name="VASMEASByAG" match="VASMEAS" use="concat(ancestor::Site, ancestor::Lat,@AG)"></xsl:key><xsl:template match="/"><html>_<xsl:apply-templates select="//VUSTAG"/>__</html>_</xsl:template><xsl:template match="//VUSTAG"><table width = "100%" border="1"><colgroup span="2" width ="50%" valign = "top" ><tr><xsl:choose><xsl:when test="@Site != ''"><td align ="left"><b><xsl:value-of select="@Site"/></b></td></xsl:when><xsl:otherwise> <td > </td></xsl:otherwise></xsl:choose><xsl:choose><xsl:when test="@Lat != ''"><td align ="left"><b><xsl:value-of select="@Lat"/></b></td></xsl:when><xsl:otherwise> <td > </td></xsl:otherwise></xsl:choose></tr></colgroup> </table><xsl:for-each select="VASMEAS[count(. | key('VASMEASByAG', concat(ancestor::Site, ancestor::Lat,@AG))[1]) = 1]"><b><xsl:value-of select="@AG"/></b><xsl:for-each select="key('VASMEASByAG', concat(ancestor::Site, ancestor::Lat,@AG))"><table width = "100%" border = "1"><colgroup align ="left" valign = "top"><tr><xsl:choose><xsl:when test="@Name != ''"><td width ="30%"> <xsl:value-of select="@Name"/>_</td></xsl:when><xsl:otherwise> <td width ="30%"> </td> </xsl:otherwise></xsl:choose><xsl:choose><xsl:when test="@DE != ''"><td width ="10%"> <xsl:value-of select="@DE"/>_</td></xsl:when><xsl:otherwise> <td width ="10%"> </td> </xsl:otherwise></xsl:choose><xsl:choose><xsl:when test="@NumericValue != ''"><td width = "15%"> <xsl:value-of select="@NumericValue"/>_<xsl:choose><xsl:when test="@Unit != ''"> :<xsl:value-of select="@Unit"/>_</xsl:when></xsl:choose></td></xsl:when><xsl:otherwise> <td width = "15%"> </td> </xsl:otherwise></xsl:choose></tr></colgroup> </table></xsl:for-each></xsl:for-each></xsl:template> </xsl:stylesheet>Unlikely it does'nt work because it groups ALL 12 rows under AON-Right group.That I would obtain is AON RightCAAPR ME ES ...PR ME ES ... (2 times)CCUPR ME ES ... (4 times) AON LeftCAA PR ME ES ... (1 times)CCU 5 timesPR ME ES ... (5 times)that is, before a group by VUSTAG.Site and VUSTAG.Lat "together" and then a group by VASMEAS.AG, without repetition of values.Or perhaps there is a most simple way to do it?Many thanks (i hope you excuse my very little english).Gianni Link to comment Share on other sites More sharing options...
boen_robot Posted February 23, 2007 Share Posted February 23, 2007 If you mean you're trying to remove the duplicates, use the Muenchian method. Read this article for details. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now