User: Myself # Profiles% of OwnedOwned416100%Unwatched72%Watched Once13833%Watched Twice16239%Watched 3+10926%
<?xml version="1.0" encoding="UTF-8"?><!-- Copyright (c) 2009 Matthias Wolf, Germany AKA goodguy--><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/><xsl:key name="keyUser" match="/Collection/DVD[CollectionType='Owned']/Events/Event[EventType='Watched']/User" use="concat(@FirstName, '|', @LastName)"/><xsl:param name="gTotalCount" select="count(/Collection/DVD[CollectionType='Owned'])"/><xsl:template match="/"> <html> <head> <title>Watched Stats</title> </head> <body> <h1>Watched Statistics</h1> <p><b>Copyright (c) 2009 Matthias Wolf, Germany AKA goodguy</b></p> <p>Please note: These stats are strictly profile-based. If you have made heavy use of boxsets and child profiles, results may be off.</p> <xsl:apply-templates select="/Collection/DVD[CollectionType='Owned']/Events/Event[EventType='Watched']/User" /> </body> </html></xsl:template><xsl:template match="User"> <xsl:if test="generate-id() = generate-id(key('keyUser', concat(@FirstName, '|', @LastName))[1])"> <h2><xsl:value-of select="concat('User: ', @FirstName, ' ', @LastName)"/></h2> <table border="1" cellpadding="5"> <colgroup><col align="left" /><col align="right" /><col align="right" /></colgroup> <tr> <th> </th> <th># Profiles</th> <th>% of Owned</th> </tr> <tr> <td>Owned</td> <td><xsl:value-of select="$gTotalCount" /></td> <td>100%</td> </tr> <xsl:call-template name="doCount"> <xsl:with-param name="pUserFN" select="@FirstName"/> <xsl:with-param name="pUserLN" select="@LastName"/> <xsl:with-param name="pDisplay" select="'Unwatched'"/> <xsl:with-param name="pMin" select="0"/> <xsl:with-param name="pMax" select="0"/> </xsl:call-template> <xsl:call-template name="doCount"> <xsl:with-param name="pUserFN" select="@FirstName"/> <xsl:with-param name="pUserLN" select="@LastName"/> <xsl:with-param name="pDisplay" select="'Watched Once'"/> <xsl:with-param name="pMin" select="1"/> <xsl:with-param name="pMax" select="1"/> </xsl:call-template> <xsl:call-template name="doCount"> <xsl:with-param name="pUserFN" select="@FirstName"/> <xsl:with-param name="pUserLN" select="@LastName"/> <xsl:with-param name="pDisplay" select="'Watched Twice'"/> <xsl:with-param name="pMin" select="2"/> <xsl:with-param name="pMax" select="2"/> </xsl:call-template> <xsl:call-template name="doCount"> <xsl:with-param name="pUserFN" select="@FirstName"/> <xsl:with-param name="pUserLN" select="@LastName"/> <xsl:with-param name="pDisplay" select="'Watched 3+'"/> <xsl:with-param name="pMin" select="3"/> <xsl:with-param name="pMax" select="999999"/> </xsl:call-template> </table> </xsl:if></xsl:template><xsl:template name="doCount"> <xsl:param name="pUserFN"/> <xsl:param name="pUserLN"/> <xsl:param name="pDisplay"/> <xsl:param name="pMin"/> <xsl:param name="pMax"/> <xsl:variable name="n" select=" count(/Collection/DVD[CollectionType='Owned' and count(Events/Event[EventType='Watched' and User/@FirstName=$pUserFN and User/@LastName=$pUserLN]) >= $pMin and count(Events/Event[EventType='Watched' and User/@FirstName=$pUserFN and User/@LastName=$pUserLN]) <=$pMax]) "/> <tr> <td><xsl:value-of select="$pDisplay" /></td> <td><xsl:value-of select="$n" /></td> <td><xsl:value-of select="round($n div $gTotalCount * 100)" />%</td> </tr></xsl:template></xsl:stylesheet>
<?xml-stylesheet type="text/xsl" href="C:\Sample\WatchedStats.xslt"?>
Can you explain "and insert a <xml-stylesheet> tag referring WatchedStats.xslt"I got lost at that point
<?xml version="1.0" encoding="windows-1252"?><!--DVD Profiler Collection Export--><?xml-stylesheet type="text/xsl" href="C:\Sample\WatchedStats.xslt"?><Collection>
Works great! Thank you!
XML always scares me a bit, so I used Mark's "Database Query" plugin instead...
Yes, I do think I should have rented more and purchased less
Code: [Select]<?xml version="1.0" encoding="UTF-8"?><!-- Copyright (c) 2009 Matthias Wolf, Germany AKA goodguy--><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/><xsl:key name="keyUser" match="/Collection/DVD[CollectionType='Owned']/Events/Event[EventType='Watched']/User" use="concat(@FirstName, '|', @LastName)"/><xsl:param name="gTotalCount" select="count(/Collection/DVD[CollectionType='Owned'])"/><xsl:template match="/"> <html> <head> <title>Watched Stats</title> </head> <body> <h1>Watched Statistics</h1> <p><b>Copyright (c) 2009 Matthias Wolf, Germany AKA goodguy</b></p> <p>Please note: These stats are strictly profile-based. If you have made heavy use of boxsets and child profiles, results may be off.</p> <xsl:apply-templates select="/Collection/DVD[CollectionType='Owned']/Events/Event[EventType='Watched']/User" /> </body> </html></xsl:template><xsl:template match="User"> <xsl:if test="generate-id() = generate-id(key('keyUser', concat(@FirstName, '|', @LastName))[1])"> <h2><xsl:value-of select="concat('User: ', @FirstName, ' ', @LastName)"/></h2> <table border="1" cellpadding="5"> <colgroup><col align="left" /><col align="right" /><col align="right" /></colgroup> <tr> <th> </th> <th># Profiles</th> <th>% of Owned</th> </tr> <tr> <td>Owned</td> <td><xsl:value-of select="$gTotalCount" /></td> <td>100%</td> </tr> <xsl:call-template name="doCount"> <xsl:with-param name="pUserFN" select="@FirstName"/> <xsl:with-param name="pUserLN" select="@LastName"/> <xsl:with-param name="pDisplay" select="'Unwatched'"/> <xsl:with-param name="pMin" select="0"/> <xsl:with-param name="pMax" select="0"/> </xsl:call-template> <xsl:call-template name="doCount"> <xsl:with-param name="pUserFN" select="@FirstName"/> <xsl:with-param name="pUserLN" select="@LastName"/> <xsl:with-param name="pDisplay" select="'Watched Once'"/> <xsl:with-param name="pMin" select="1"/> <xsl:with-param name="pMax" select="1"/> </xsl:call-template> <xsl:call-template name="doCount"> <xsl:with-param name="pUserFN" select="@FirstName"/> <xsl:with-param name="pUserLN" select="@LastName"/> <xsl:with-param name="pDisplay" select="'Watched Twice'"/> <xsl:with-param name="pMin" select="2"/> <xsl:with-param name="pMax" select="2"/> </xsl:call-template> <xsl:call-template name="doCount"> <xsl:with-param name="pUserFN" select="@FirstName"/> <xsl:with-param name="pUserLN" select="@LastName"/> <xsl:with-param name="pDisplay" select="'Watched 3+'"/> <xsl:with-param name="pMin" select="3"/> <xsl:with-param name="pMax" select="999999"/> </xsl:call-template> </table> </xsl:if></xsl:template><xsl:template name="doCount"> <xsl:param name="pUserFN"/> <xsl:param name="pUserLN"/> <xsl:param name="pDisplay"/> <xsl:param name="pMin"/> <xsl:param name="pMax"/> <xsl:variable name="n" select=" count(/Collection/DVD[CollectionType='Owned' and count(Events/Event[EventType='Watched' and User/@FirstName=$pUserFN and User/@LastName=$pUserLN]) >= $pMin and count(Events/Event[EventType='Watched' and User/@FirstName=$pUserFN and User/@LastName=$pUserLN]) <=$pMax]) "/> <tr> <td><xsl:value-of select="$pDisplay" /></td> <td><xsl:value-of select="$n" /></td> <td><xsl:value-of select="round($n div $gTotalCount * 100)" />%</td> </tr></xsl:template></xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?><!-- Copyright (c) 2009 Matthias Wolf, Germany AKA goodguy--><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/><xsl:key name="keyUser" match="/Collection/DVD[CollectionType='Owned']/Events/Event[EventType='Watched']/User" use="concat(@FirstName, '|', @LastName)"/><xsl:param name="gTotalCount" select="count(/Collection/DVD[CollectionType='Owned'])"/><xsl:template match="/"> <html> <head> <title>Watched Stats</title> </head> <body> <h1>Watched Statistics</h1> <p><b>Copyright (c) 2009 Matthias Wolf, Germany AKA goodguy</b></p> <p>Please note: These stats are strictly profile-based. If you have made heavy use of boxsets and child profiles, results may be off.</p> <xsl:apply-templates select="/Collection/DVD[CollectionType='Owned']/Events/Event[EventType='Watched']/User" /> </body> </html></xsl:template><xsl:template match="User"> <xsl:if test="generate-id() = generate-id(key('keyUser', concat(@FirstName, '|', @LastName))[1])"> <h2><xsl:value-of select="concat('User: ', @FirstName, ' ', @LastName)"/></h2> [table] <colgroup><col align="left" /><col align="right" /><col align="right" /></colgroup> [tr] [td][b] [/b][/td] [td][b]# Profiles[/b][/td] [td][b]% of Owned[/b][/td] [/tr] [tr] [td]Owned[/td] [td]<xsl:value-of select="$gTotalCount" />[/td] [td]100%[/td] [/tr] <xsl:call-template name="doCount"> <xsl:with-param name="pUserFN" select="@FirstName"/> <xsl:with-param name="pUserLN" select="@LastName"/> <xsl:with-param name="pDisplay" select="'Unwatched'"/> <xsl:with-param name="pMin" select="0"/> <xsl:with-param name="pMax" select="0"/> </xsl:call-template> <xsl:call-template name="doCount"> <xsl:with-param name="pUserFN" select="@FirstName"/> <xsl:with-param name="pUserLN" select="@LastName"/> <xsl:with-param name="pDisplay" select="'Watched Once'"/> <xsl:with-param name="pMin" select="1"/> <xsl:with-param name="pMax" select="1"/> </xsl:call-template> <xsl:call-template name="doCount"> <xsl:with-param name="pUserFN" select="@FirstName"/> <xsl:with-param name="pUserLN" select="@LastName"/> <xsl:with-param name="pDisplay" select="'Watched Twice'"/> <xsl:with-param name="pMin" select="2"/> <xsl:with-param name="pMax" select="2"/> </xsl:call-template> <xsl:call-template name="doCount"> <xsl:with-param name="pUserFN" select="@FirstName"/> <xsl:with-param name="pUserLN" select="@LastName"/> <xsl:with-param name="pDisplay" select="'Watched 3+'"/> <xsl:with-param name="pMin" select="3"/> <xsl:with-param name="pMax" select="999999"/> </xsl:call-template> [/table] </xsl:if></xsl:template><xsl:template name="doCount"> <xsl:param name="pUserFN"/> <xsl:param name="pUserLN"/> <xsl:param name="pDisplay"/> <xsl:param name="pMin"/> <xsl:param name="pMax"/> <xsl:variable name="n" select=" count(/Collection/DVD[CollectionType='Owned' and count(Events/Event[EventType='Watched' and User/@FirstName=$pUserFN and User/@LastName=$pUserLN]) >= $pMin and count(Events/Event[EventType='Watched' and User/@FirstName=$pUserFN and User/@LastName=$pUserLN]) <=$pMax]) "/> [tr] [td]<xsl:value-of select="$pDisplay" />[/td] [td]<xsl:value-of select="$n" />[/td] [td]<xsl:value-of select="round($n div $gTotalCount * 100)" />%[/td] [/tr]</xsl:template></xsl:stylesheet>