Due to enormous amounts of spam, the forum has been set to read-only mode.



Reply to topic  [ 47 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
One for the XML pundits - playing a symphony 
Author Message
User avatar

Joined: Wed Oct 01, 2003 6:09 pm
Posts: 1142
Location: Location: Location:
Post Re: One for the XML pundits - playing a symphony

Tried... and failed. :(
I've honestly no idea how to go about that :?
Sorry

Ken


Thu Jun 30, 2011 10:00 pm
Profile
Site Admin
User avatar

Joined: Fri Nov 22, 2002 3:52 pm
Posts: 13748
Post Re: One for the XML pundits - playing a symphony

KAM wrote:
Tried... and failed. :(
I've honestly no idea how to go about that :?
Sorry

Ken

You can use the SUM function. If Custom 10 is checked for the "start of work", this code will calculate the total length of the "work":

Code:
<xsl:if test="custom10/@bool='True'">
  <xsl:variable name="custom01value"><xsl:value-of select="custom01"/></xsl:variable>   
  <xsl:variable name="totallengthmin"><xsl:value-of select="sum(//track[custom01=$custom01value]/length/@minutes) * 60"/></xsl:variable>
  <xsl:variable name="totallengthsec"><xsl:value-of select="sum(//track[custom01=$custom01value]/length/@seconds)"/></xsl:variable>
  <xsl:variable name="totallength"><xsl:value-of select="$totallengthmin + $totallengthsec"/></xsl:variable>
  <xsl:value-of select="floor($totallength div 60)"/><xsl:text>:</xsl:text><xsl:value-of select="format-number($totallength mod 60, '00')"/>
</xsl:if>

_________________
Fredrik Nordbakke
www.fnprg.com


Thu Jun 30, 2011 11:04 pm
Profile WWW
User avatar

Joined: Wed Oct 01, 2003 6:09 pm
Posts: 1142
Location: Location: Location:
Post Re: One for the XML pundits - playing a symphony

There you go, Litago!

There's some guy in Norway who seems to know more than we do about just about everything.
Fortunately for us, he's always willing to help.

Thanks, Fredrik. I've only just spotted this and trying it out will have to wait until a full working day has passed.

Regards

Ken


Fri Jul 01, 2011 8:02 am
Profile
User avatar

Joined: Wed Oct 01, 2003 6:09 pm
Posts: 1142
Location: Location: Location:
Post Re: One for the XML pundits - playing a symphony

Hi Fredrik

Just like to say thank you for the additional code. I had to make one slight modification - changing the "custom01" to "custom05" in my setup. Unfortunately I use 'custom01' in my database setup to hold the Opus No of a piece of music. This meant that when I tested your code I got results displayed but they weren't always consistent with what I expected. It might have been easier if I got no times displayed at all, or if they were always the wrong value, but this took me a little while to work out. I thought it was down to errors in my data - maybe an extra space here or a missing comma there - that made the names of works inconsistent. But then I realised what was happening. Everything works really well and better than I expected.

Thank you to Litago too for the idea of displaying the length. I hadn't realised how useful that would be.

Now I've just got one final tiny thing I can't resolve.
If a work is only one track long I can't get my code to display the prompt to play it. I've attached an image to indicate what I mean. This is consistent across all albums.
The code I'm using is -
Code:
<xsl:if test="custom05!='' and custom10/@bool='True'">      
      <TABLE CLASS="worktable">
         <TR>
         <TD >
            <TR CLASS="workrow">
               <TD CLASS="workname" >
                  <xsl:value-of select="/data/fld/track/custom05/@name"/>
               </TD>
               <TD CLASS="workvalue">
                  <A HREF="TrackList.xsl?Custom05={custom05}@xslparam:doctitle={/data/fld/track/custom05/@name}:{custom05}">
                  <xsl:value-of select="custom05"/>
                  </A>
               </TD>         
               <TD CLASS="workplay">
               
                     <xsl:if test="custom10/@bool='True'">
                        <xsl:variable name="custom01value"><xsl:value-of select="custom05"/></xsl:variable>   
                        <xsl:variable name="totallengthmin"><xsl:value-of select="sum(//track[custom05=$custom01value]/length/@minutes) * 60"/></xsl:variable>
                        <xsl:variable name="totallengthsec"><xsl:value-of select="sum(//track[custom05=$custom01value]/length/@seconds)"/></xsl:variable>
                        <xsl:variable name="totallength"><xsl:value-of select="$totallengthmin + $totallengthsec"/></xsl:variable>
                        <xsl:value-of select="floor($totallength div 60)"/><xsl:text>:</xsl:text><xsl:value-of select="format-number($totallength mod 60, '00')"/>
                     </xsl:if>
               </TD>
               <TD CLASS="workplay">
                  <A HREF="PLAYFILTER:Track.Custom05={custom05}@Track.AlbumID={albumid/@unformatted}@orderby=Track.Position@validate=yes,2">Play</A>
               </TD>
            </TR>
         </TD>
         </TR>
      </TABLE>
      <TABLE>
         <TR>
         </TR>
      </TABLE>
   </xsl:if>   

Custom05 is the field holding the Work name, and Custom10 is the field indicating the Start of a Work.

Any suggestions anyone?

Thank you and regards

Ken


You do not have the required permissions to view the files attached to this post.


Sat Jul 02, 2011 1:37 pm
Profile

Joined: Wed Sep 18, 2002 1:53 am
Posts: 462
Location: North Wales, UK
Post Re: One for the XML pundits - playing a symphony

Ken,

I don't have the answer to your question, but I'm very impressed with what you have so far.
Can you tell me exactly where to paste this additional code in "Album_Tracks.xsl"?

I can't seem to get it to work at all - and I have created the same custom track fields as you (i.e. Custom05 is the field holding the Work name, and Custom10 is the field indicating the Start of a Work)

Thanks, Les


Sat Jul 02, 2011 7:21 pm
Profile WWW
User avatar

Joined: Fri Nov 14, 2003 6:15 pm
Posts: 1425
Post Re: One for the XML pundits - playing a symphony

Hi Ken,
KAM wrote:
Now I've just got one final tiny thing I can't resolve.
If a work is only one track long I can't get my code to display the prompt to play it. I've attached an image to indicate what I mean. This is consistent across all albums.

I'm far away from my CATraxx computer so I cannot confirm the adjustment but I think it will work properly if you change the play link as follows:
<A HREF="PLAYFILTER:Track.Custom05={custom05}@Track.AlbumID={albumid/@unformatted}@orderby=Track.Position@validate=yes,1">Play</A>

_________________
Cheers,
Dave


Sat Jul 02, 2011 8:27 pm
Profile WWW
User avatar

Joined: Wed Oct 01, 2003 6:09 pm
Posts: 1142
Location: Location: Location:
Post Re: One for the XML pundits - playing a symphony

Grrrr - why do you have to be so helpful, Dave!

I'd just managed to work this out for myself and I rushed to the forum to tell the world.
Only to find that you've beaten me to it.
Oh well, I couldn't have it confirmed by a better source.

Thanks and regards

Ken


Sat Jul 02, 2011 9:10 pm
Profile
User avatar

Joined: Fri Nov 14, 2003 6:15 pm
Posts: 1425
Post Re: One for the XML pundits - playing a symphony

Hi Ken,

Very glad to hear you figured it out on your own!

_________________
Cheers,
Dave


Sun Jul 03, 2011 7:04 am
Profile WWW

Joined: Wed Jun 16, 2010 3:01 pm
Posts: 18
Post Re: One for the XML pundits - playing a symphony

Hi,

I must admit that I couldn’t get this to work first time around. After some headscratching I have come up with this.

Back up your file and in Album_Tracks.xsl replace this:
Code:
 
    <xsl:apply-templates select="/data/record/trackdata"/>
  </TABLE>
</xsl:template>

<xsl:template match="trackdata"> 
  <xsl:apply-templates select="item"/>
</xsl:template>

<xsl:template match="item">
  <xsl:variable name="itemno">
    <xsl:value-of select="itemno"/>
  </xsl:variable>
  <!-- If more than 1 item, display the item title -->
  <xsl:if test="../@items &gt; 1">
    <TR>
      <TD CLASS="albumdisctitle" COLSPAN="7">
        <xsl:value-of select="title"/>
        <!-- Add "play all" link -->
        <xsl:if test="@audioattached='True'">   
          <xsl:text> </xsl:text>
          <A HREF="PLAYALL:{/data/record/@id},{itemno}"><IMG SRC="PlayAlbum2.gif" BORDER="0"/></A>
        </xsl:if>         
      </TD>
    </TR>
  </xsl:if>
  <xsl:apply-templates select="side"/>
</xsl:template>

<xsl:template match="side">
  <xsl:if test="sideno='B'">
    <TR HEIGHT="3"><TD></TD></TR>
  </xsl:if>
  <xsl:apply-templates select="track"/>
</xsl:template>


by this:

Code:
    <xsl:apply-templates select="/data/record/trackdata" mode="toc"/> 
      <tr HEIGHT="13"> <td></td></tr>
    <xsl:apply-templates select="/data/record/trackdata"/>     
  </TABLE>
</xsl:template>

<xsl:template match="trackdata" mode="toc"> 
  <xsl:apply-templates select="item" mode="toc"/>
</xsl:template>

<xsl:template match="trackdata"> 
  <xsl:apply-templates select="item"/>
</xsl:template>

<xsl:template match="item" mode="toc">
  <xsl:variable name="itemno">
    <xsl:value-of select="itemno"/>
  </xsl:variable>
  <xsl:apply-templates select="side" mode="toc"/>
</xsl:template>


<xsl:template match="item">
  <xsl:variable name="itemno">
    <xsl:value-of select="itemno"/>
  </xsl:variable>
  <!-- If more than 1 item, display the item title -->
  <xsl:if test="../@items &gt; 1">
    <TR>
      <TD CLASS="albumdisctitle" COLSPAN="8">
        <xsl:value-of select="title"/>
        <!-- Add "play all" link -->
        <xsl:if test="@audioattached='True'">   
          <xsl:text> </xsl:text>
          <A HREF="PLAYALL:{/data/record/@id},{itemno}"><IMG SRC="PlayAlbum2.gif" BORDER="0"/></A>
        </xsl:if>         
      </TD>
    </TR>
  </xsl:if>
  <xsl:apply-templates select="side"/> 
</xsl:template>

<xsl:template match="side" mode="toc">
  <xsl:apply-templates select="track" mode="toc"/>
</xsl:template>

<xsl:template match="side">
  <xsl:if test="sideno='B'">
    <TR HEIGHT="3"><TD></TD></TR>
  </xsl:if>
  <xsl:apply-templates select="track"/> 
</xsl:template>



<xsl:template match="track" mode="toc">
    <xsl:if test="custom01!='' and custom10/@bool='True'">     
                <TR CLASS="tablerecordsrow">
                   <TD colspan="2" bgcolor="#BBFFBB" style="font-weight: bold; padding-left: 7px;">
                      <A HREF="PLAYFILTER:Track.custom01={custom01}@Track.AlbumID={albumid/@unformatted}@orderby=Track.Position@validate=yes,1"> <IMG SRC="Play_mp3.gif" BORDER="0"/> </A>
                   </TD>
                   <TD bgcolor="#BBFFBB" style="font-weight: bold;">
                      <A HREF="TrackList.xsl?custom01={custom01}@xslparam:doctitle={/data/fld/track/custom01/@name}:{custom01}">
                      <xsl:value-of select="custom01"/>
                      </A>
                   </TD>         
                   <TD bgcolor="#BBFFBB" ALIGN="RIGHT" style="font-weight: bold;">
                         <xsl:if test="custom10/@bool='True'">
                            <xsl:variable name="custom01value"><xsl:value-of select="custom01"/></xsl:variable>   
                            <xsl:variable name="totallengthmin"><xsl:value-of select="sum(//track[custom01=$custom01value]/length/@minutes) * 60"/></xsl:variable>
                            <xsl:variable name="totallengthsec"><xsl:value-of select="sum(//track[custom01=$custom01value]/length/@seconds)"/></xsl:variable>
                            <xsl:variable name="totallength"><xsl:value-of select="$totallengthmin + $totallengthsec"/></xsl:variable>
                            <xsl:value-of select="floor($totallength div 60)"/><xsl:text>:</xsl:text><xsl:value-of select="format-number($totallength mod 60, '00')"/>
                         </xsl:if>
                   </TD>
                </TR>
   </xsl:if> 
</xsl:template>


Note that I have used custom01 and custom10, (also colspans and colors may vary).


I first envisioned this to be done in TrackBrowse.xsl, but there I cannot get the sum function to work at all. I will look further into it, but anyone who have something working is welcome to give a hint.

Litago


Wed Jul 06, 2011 7:20 am
Profile
User avatar

Joined: Wed Oct 01, 2003 6:09 pm
Posts: 1142
Location: Location: Location:
Post Re: One for the XML pundits - playing a symphony

I'm not at my CATraxx PC at present, but when I get back later tonight I'll try to post the entire set of changes I've made. The code changes were within the xsl template, but you'll see I've also made reference to new entries in the style.css file (CLASS worktable, workrow and workname etc). I wasn't sure whether my end results would be compatible with the existing display layout, and I'd also hoped it would be transportable to other templates as well, hence the reason I created these new style definitions.

@Litago
I haven't yet attempted repeating this in other templates so I can't say what issues I will encounter.

@Les
I'm really sorry - I missed your earlier post somehow in the rush to get this working. Hopefully the attachments later will get you on the right track.

Ken


Wed Jul 06, 2011 10:17 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 47 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.