[19. June 2013] Soundcloud® available now | [7. June 2013] Youporn available now | [11 Jan. 2013] Customize your A-400 Home Screen

Firmware: A-400 [13 May 2013] | C-300 [30 Nov. 2012] | A-300 [30 Nov. 2012] | C-200 RC1 [13 June 2013] | A-200/A-210 RC1 [13 June 2013]

Just got your NMT | WIKI has the answers | Search the forum | Forum Rules/Policy | Firmware & Official NMT News | Popcornhour manuals



User(s) browsing this thread: 1 Guest(s)
Thread Closed 
[MLMJ] XSL scripting question
04-10-2010, 02:35 AM
Post: #1
[MLMJ] XSL scripting question
I am playing with some skin changes for MLMJ. When trying to execute the scripts from MoC (via the Export to HTML menu item) my script generates the error message:

Invalid element name: "

Not being a very experienced XSL or javascript developer I am having trouble trying to find this error in the code - and this error message is not overly descriptive :-)

Can anyone give me some ideas on what might be creating this kind of error message? That might help me try to locate it.

One thought that came to mind was this error message may occur when " are used within another set of " (e.g. - <xsl:if test="$Show103="true" and $enable103='true'">) My thinking is that the use of " around the first "true" might cause such an error message. Is this the case?

Are there other error conditions that would cause such a message?

Thanks for any help.
Find all posts by this user
04-10-2010, 02:49 AM
Post: #2
RE: [MLMJ] XSL scripting question
Yes, "test this="true" " (ex) will not work, try using single quotes when double quote is already used.
--> 'test this="true" '
Find all posts by this user
04-11-2010, 02:15 AM
Post: #3
RE: [MLMJ] XSL scripting question
Thanks Garp. I am starting to make some headway (albeit slowly). My latest challenge is passing a parameter value through a couple of template calls. The situation is as follows:

- Template 1 is called from the main body of the code
- Template 1 makes iterative calls to Template 2
- I want to call Template 1 (and hence Template 2) twice but have Template 2 behave differently depending why I am calling it - either to generate an array or to generate an index table of movie covers. My solution was to pass it a parameter (through Template 1) that would trigger different behaviour.

See the example code below:
Code:
<<snip>>

<!-- the main template -->
<xsl:template match="/">

    <HEAD>

<<snip>>

<!-- Call Template 1 the first time with parameter = "datalist"  to generate a variable array -->

    <xsl:apply-templates select="movieinfo/movielist">
        <xsl:with-param name="type">datalist</xsl:with-param>
    </xsl:apply-templates>
    
<<snip>>
    
    </HEAD>
    
    <BODY>            

<<snip>>

<!-- Call Template 1 the second time with parameter = "table" to generate an index table of movie covers -->
                <xsl:apply-templates select="movieinfo/movielist">
                    <xsl:with-param name="type">table</xsl:with-param>
                </xsl:apply-templates>

<<snip>>

    </BODY>
        
</xsl:template>


<!-- TEMPLATE 1 -->
<xsl:template match="movielist">
    <xsl:param name="type" />

    <xsl:variable name="listtype" select="$type" />

    
    <xsl:variable name="nummovies"><xsl:value-of select="count(//movie)"/></xsl:variable>
    <xsl:choose>
        <xsl:when test="$indextablecols = 1"> -->
            <xsl:for-each select="movie">
                <tr>

<!-- Call Template 2 with parameter value as was received -->
                    <xsl:apply-templates select=". | following-sibling::movie[position() &lt; $indextablecols]">
                        <xsl:with-param name="passType" select="$listtype" />
                    </xsl:apply-templates>
                </tr>
            </xsl:for-each>
        </xsl:when>
            
        <xsl:otherwise>
            <xsl:for-each select="movie[position() mod $indextablecols = 1]">
                <tr>

                    <xsl:apply-templates select=". | following-sibling::movie[position() &lt; $indextablecols]">
                        <xsl:with-param name="passType" select="$listtype" />
                    </xsl:apply-templates>
                </tr>
            </xsl:for-each>    
        </xsl:otherwise>            
    </xsl:choose> -->
</xsl:template>


<!-- TEMPLATE 2 -->
<xsl:template match="movie">
    <xsl:param name="passType" />

    <xsl:variable name="choice" select="$type" />
    
<!--If Parameter="table" - generate index table of movie covers-->
    <xsl:choose>
        <xsl:when test="$choice = 'table'">

    <xsl:variable name="the_href">details/<xsl:value-of select="id"/>.html</xsl:variable>        
    <xsl:variable name="the_img_src">images/<xsl:value-of select="id"/>t.jpg</xsl:variable>
    <xsl:variable name="counter"><xsl:value-of select="position()" /></xsl:variable>

    <td valign="top">
    <center>
    <div id="d{$counter}">
        
        <a href="{$the_href}" TVID="{$counter}" id="n{$counter}" onfocus="show({$counter})" onblur="hide({$counter})">
            <img src="{$the_img_src}" id="i{$counter}" height="{$indeximageheight}" onmouseover="show({$counter})" onmouseout="hide({$counter})" />
        </a>
            
    </div>
    </center>
    </td>

    <xsl:if test="(last() &gt; $indextablecols) and (last()=position()) and (position() mod $indextablecols &gt; 0)">
        <xsl:variable name="filledCells" select="position() mod $indextablecols"/>
        <td colspan="{$indextablecols - $filledCells}"> </td>
    </xsl:if>
    
    </xsl:when>

<!-- Otherwise - i.e. Parameter="datalist" - generate variable array -->
    <xsl:otherwise>
        movieTitle[<xsl:value-of select='position()'/>]="<xsl:value-of select='title'/>";
        movieInfo[<xsl:value-of select='position()'/>]="<xsl:value-of select="releasedate/year"/> | <xsl:value-of select="runtimeminutes"/> | <xsl:value-of select="mpaarating/displayname"/>";

    <xsl:if test="(last() &gt; $indextablecols) and (last()=position()) and (position() mod $indextablecols &gt; 0)">
        <xsl:variable name="filledCells" select="position() mod $indextablecols"/>
        <td colspan="{$indextablecols - $filledCells}"> </td>
    </xsl:if>
    </xsl:otherwise>
    </xsl:choose>
    
</xsl:template>

    
<<snip>>

</xsl:stylesheet>

The parameter values seem to be getting passed to Template 1 Ok, but I cannot figure out how to pass the values through to Template 2.

If I replace the line
Code:
<xsl:with-param name="passType" select="$listtype" />
with
Code:
<xsl:with-param name="passType">test</xsl:with-param>
then the value "test" gets passed to Template 2 fine.

I've tried a bunch of different combinations of variables, etc. - but am not having any luck.

Any help would be greatly appreciated.

Thanks.
Find all posts by this user
04-11-2010, 03:00 AM
Post: #4
RE: [MLMJ] XSL scripting question
It's really hard to diagnose/debug when looking at snippets of code in a small window.
I am willing to look over your skin and compile here myself to see where things go wrong
and then I can help to figure things out with you.
You can PM me your real email addr or PM me a link to download your skin (zipped).

Otherwise, I did a search of the existing skins I have available (most of them) and was able to
find some similar code in AEon skin's index.xsl and perhaps that can provide some clues...

Code:
<xsl:for-each select="library/movies/movie[position() mod $nbCols = 1]">
          <tr>
            <xsl:apply-templates
                 select=".|following-sibling::movie[position() &lt; $nbCols]">
              <xsl:with-param name="gap" select="(position() - 1) * $nbCols" />
              <xsl:with-param name="currentIndex" select="$currentIndex" />
              <xsl:with-param name="lastIndex" select="$lastIndex" />
              <xsl:with-param name="lastGap" select="($nbLines - 1) * $nbCols" />
            </xsl:apply-templates>
          </tr>
        </xsl:for-each>
Find all posts by this user
04-11-2010, 05:33 PM (This post was last modified: 04-11-2010 05:48 PM by gsbaker.)
Post: #5
RE: [MLMJ] XSL scripting question
(04-10-2010 02:35 AM)gsbaker Wrote:  I am playing with some skin changes for MLMJ. When trying to execute the scripts from MoC (via the Export to HTML menu item) my script generates the error message:

Invalid element name: "

One thought that came to mind was this error message may occur when " are used within another set of " (e.g. - <xsl:if test="$Show103="true" and $enable103='true'">) My thinking is that the use of " around the first "true" might cause such an error message. Is this the case?

Are there other error conditions that would cause such a message?

Thanks for any help.

While the quotes inside of quotes also caused problems, through a long process of trial and error I found another culprit. Some of the javascript code I wanted the XSL parser to include in the html output include the "&" character which caused the parser to hiccup.

I solved that problem by enclosing the javascript code in CDATA tags.

Now on to my next problem :-)
(04-11-2010 02:15 AM)gsbaker Wrote:  Thanks Garp. I am starting to make some headway (albeit slowly). My latest challenge is passing a parameter value through a couple of template calls. The situation is as follows:

- Template 1 is called from the main body of the code
- Template 1 makes iterative calls to Template 2
- I want to call Template 1 (and hence Template 2) twice but have Template 2 behave differently depending why I am calling it - either to generate an array or to generate an index table of movie covers. My solution was to pass it a parameter (through Template 1) that would trigger different behaviour.

The parameter values seem to be getting passed to Template 1 Ok, but I cannot figure out how to pass the values through to Template 2.

If I replace the line
Code:
<xsl:with-param name="passType" select="$listtype" />
with
Code:
<xsl:with-param name="passType">test</xsl:with-param>
then the value "test" gets passed to Template 2 fine.

I've tried a bunch of different combinations of variables, etc. - but am not having any luck.

While I have not "solved" this problem, I have found a work-around. Basically in Template 1 I test for the parameter value and created 2 branches depending on the value (since I am only concerned about 2 scenarios - parameter="data" and parameter="table"). By creating the two branches I could feed Template 2 with a hard coded value as in the code line above - with a different value from each branch.

This solved another problem as well as I needed different behaviours in Template 1 depending on the value received (in one case I need the results embedded within html tr tags and in the other case not.
Find all posts by this user
Thread Closed 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  MLMJ and Movie Collector 9 johnfromen6 7 1,133 Yesterday 02:03 AM
Last Post: gsbaker
  [MLMJ] DVD Empire Script broken gsbaker 3 616 05-02-2013 12:28 AM
Last Post: gsbaker
  [MLMJ] Script to convert from MLMJ to YAMJ Swannpin 9 2,013 02-16-2012 04:51 PM
Last Post: Swannpin
  Question about music information in Music Jukebox 8 Zolive 3 1,935 11-29-2011 03:39 AM
Last Post: wandidj
  [MLMJ] - Upgrading to Movie Collector 8??? gsbaker 4 2,887 11-21-2011 11:35 AM
Last Post: bigkid
  MLMJ and genre filters in MoC Penge58 1 1,477 08-28-2011 02:50 PM
Last Post: gsbaker
  MLMJ Irfanview not closing when done Penge58 0 1,129 08-25-2011 10:44 AM
Last Post: Penge58
  MLMJ - Stops at Initializing Variables bigkid 16 4,029 07-22-2011 03:45 AM
Last Post: bigkid
  [MLMJ] Is this project still active? charlesc 23 5,713 06-28-2011 11:39 PM
Last Post: michael1t
  MLMJ stuck with MoC version 7.1.6 Penge58 5 1,970 06-23-2011 05:47 PM
Last Post: gsbaker

Forum Jump: