Custom xml output Options
whogoeson
Posted: Sunday, November 19, 2006 9:02:16 PM
Rank: Devotee

Joined: 8/10/2006
Posts: 46
Hi

I am trying to implement some flash files (video and image), and therefore I need some xml output similar to this:

Code:

<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>
    <track>
        <title>Image title1</title>
        <creator>Kristjan</creator>
        <location>image1.jpg</location>
        <info>http://www.mysite.com</info>
    </track>

    <track>
        <title>Image title2</title>
        <creator>Kristjan</creator>
        <location>image2.jpg</location>
        <info>http://www.mysite.com</info>
    </track>
</trackList>
</playlist>


I was planning on using the Media Picker to choose a folder containing the images.

Is this an easy task and if so how is it done?

/ Kristjan
bootnumlock
Posted: Sunday, November 19, 2006 11:22:56 PM

Rank: Fanatic

Joined: 10/9/2006
Posts: 418
I would look into CPALM's flash package...http://www.cpalm.dk/blog/2006/06/04/flash-and-umbraco-package.aspx

bootnumlock - aka bob baty-barr [http://www.baty-barr.com]
Level 1 Certified!
howard
Posted: Monday, November 27, 2006 1:06:02 PM
Rank: Devotee

Joined: 8/22/2006
Posts: 72
Hi , have a look at another reply about formatting xspf with a flash player

http://forum.umbraco.org/6229#post-6229

good luck
pixelkind
Posted: Monday, November 27, 2006 2:42:42 PM
Rank: Newbie

Joined: 11/27/2006
Posts: 4
Code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library"
    exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="no" indent="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:variable name="nodeID" select="umbraco.library:RequestQueryString('nodeID')" />
<xsl:variable name="folder" select="umbraco.library:GetMedia($nodeID)"/>
    
<playlist version="1" xmlns="http://xspf.org/ns/0/">
    <trackList>
        <xsl:for-each select="$folder/node">
            <track>
                <title><xsl:value-of select="./@nodeName"></title>
                <creator><xsl:value-of select="./@creator"></creator>
                <location><xsl:value-of select="./data [@alias = 'umbracoFile']"></location>
                <info><xsl:value-of select="./data [@alias = 'yourVarName']"></info>
            </track>
        </xsl:for-each>
    </tracklist>
</playlist>

</xsl:template>
</xsl:stylesheet>


this should work for you...
you have to call it with the folderId als queryString...

greets
::pixelkind
pixelkind
Posted: Monday, November 27, 2006 2:45:16 PM
Rank: Newbie

Joined: 11/27/2006
Posts: 4
sorry that it looks like that...
i have put code around it...
copy it into your editor, than it should look better :)

:: pixelkind
whogoeson
Posted: Monday, November 27, 2006 11:51:56 PM
Rank: Devotee

Joined: 8/10/2006
Posts: 46
OK I am a little lost here..

1. I created a Documenttype called “xspf”
2. In there I made Tab called “xspf_list”
3. Added Media Picker to the tab
4. Created a xslt and a macro called “xpsf”
And used the following code:


Code:

<?xml version="1.0" encoding="UTF-8"?> 
 
<!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp " "> ]> 
 
<xsl:stylesheet
    version="1.0"   
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   
      xmlns:msxml="urn:schemas-microsoft-com:xslt" 
      xmlns:umbraco.library="urn:umbraco.library" 
      exclude-result-prefixes="msxml umbraco.library"> 
 
<xsl:output method="xml" omit-xml-declaration="no" indent="yes"/> 

<xsl:param name="currentPage"/> 
<xsl:template match="/"> 
<xsl:variable name="nodeID" select="umbraco.library:RequestQueryString('nodeID')" /> 
<xsl:variable name="folder" select="umbraco.library:GetMedia($nodeID)"/> 
 
 
<playlist version="1" xmlns="http://xspf.org/ns/0/"> 
    <trackList> 
        <xsl:for-each select="$folder/node"> 
            <track> 
                <title><xsl:value-of select="./@nodeName"></title> 
                <creator><xsl:value-of select="./@creator"></creator> 
                <location><xsl:value-of select="./data [@alias = 'umbracoFile']"></location> 
                <info><xsl:value-of select="./data [@alias = 'xspf_list']"></info> 
            </track> 
        </xsl:for-each> 
    </tracklist> 
</playlist> 
 
</xsl:template> 
</xsl:stylesheet> 



5. In the template “xspf” I used the following code:

Code:

<?xml version="1.0" encoding="UTF-8"?> 
<playlist version="1" xmlns="http://xspf.org/ns/0/"> 
    <trackList> 
    <?UMBRACO_MACRO macroAlias="xspf" ></?UMBRACO_MACRO>
    </trackList> 
</playlist> 


But when I try to view the page using a link that’s looks like this www.mysite.com/xspf.aspx?folderId=1150 all I get is this

Code:

<?xml version="1.0" encoding="UTF-8" ?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
  <trackList>Error reading XSLT file: \xslt\xspf.xslt</trackList>
  </playlist>


What am I doing wrong? :hmm:

Regards,
Kristjan
hartvig
Posted: Tuesday, November 28, 2006 12:31:31 AM

Rank: Addict

Joined: 3/17/2008
Posts: 952
Location: Nyborg, Denmark
Kristjan hugosson wrote:

What am I doing wrong? :hmm:


If you add ?umbdebugshowtrace=true to your url, you can see a trace in the bottom. Scroll down until you see some red text with the xslt error message. That'll probably help you getting on the right track. If not then post it here :-)

Cheers,
Niels - the linebreaker

Jeeeez, did I really start this :-)
whogoeson
Posted: Tuesday, November 28, 2006 1:01:46 AM
Rank: Devotee

Joined: 8/10/2006
Posts: 46
I don't know how much of the code we need, but here is the red part:
Code:

umbracoMacro    
Error loading XSLT xspf.xslt
The 'xsl:value-of' start tag on line 24 does not match the end tag of 'title'. Line 24, position 61.
  at System.Xml.XmlTextReaderImpl.Throw(Exception e)
  at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
  at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag)
  at System.Xml.XmlTextReaderImpl.ParseEndElement()
  at System.Xml.XmlTextReaderImpl.ParseElementContent()
  at System.Xml.XmlTextReaderImpl.Read()
  at System.Xml.XmlTextReader.Read()
  at System.Xml.XmlValidatingReaderImpl.Read()
  at System.Xml.XmlValidatingReader.Read()
  at System.Xml.XPath.XPathDocument.LoadFromReader(XmlReader reader, XmlSpace space)
  at System.Xml.Xsl.XslTransform.Load(XmlReader stylesheet, XmlResolver resolver, Evidence evidence)
  at umbraco.macro.getXslt(String XsltFile) in C:\data\umbraco\umbraco2.1\umbraco\presentation\macro.cs:line 450
  at umbraco.macro.loadMacroXSLT(macro macro, Hashtable attributes, page umbPage) in C:\data\umbraco\umbraco2.1\umbraco\presentation\macro.cs:line 500


This is the same error I get, when I try to save the XSLT file.

Sorry but this doesn’t get me any closer to the path :roll:

/ Kristjan
hartvig
Posted: Tuesday, November 28, 2006 1:17:43 AM

Rank: Addict

Joined: 3/17/2008
Posts: 952
Location: Nyborg, Denmark
You need to close your value-of elements:
Code:
<title><xsl:value-of select="./@nodeName"></title>

should be
Code:
<title><xsl:value-of select="./@nodeName" /></title>


Notice the end "/" before the ">" in the xsl:value-of element. Go through the rest and it should work :-)

Jeeeez, did I really start this :-)
whogoeson
Posted: Tuesday, November 28, 2006 10:26:58 AM
Rank: Devotee

Joined: 8/10/2006
Posts: 46
Thanks Niels, that solved the problem, but this just resulted in another problem.

System.Xml.Xsl.XsltException: XSLT function 'GetMedia()' has the wrong number of arguments.

In this code
Code:
<xsl:variable name="folder" select="umbraco.library:GetMedia($nodeID)"/> 


So in my hunt for a solution, I looked at the following post

http://forum.umbraco.org/6229#post-6229

And using the code from this post, I get a very clean listing

Code:


<?xml version="1.0" encoding="UTF-8"?> 
<playlist version="1" xmlns="http://xspf.org/ns/0/"> 
    <trackList> 
    
    </trackList> 
</playlist> 



Now the pages show with out any errors, unfortunally without any track listing as well.
But this might just be me being stupid and not knowing what the difference between the Allias’ used in the code.

Code:


[@nodeTypeAlias = 'wwMusic']
[@alias = 'relDate']
[@alias ='audioFile']



I tried to use a common name for all my alias – xspf – but this still doesn’t help me much.

So am I totally lost here or is there a simple way back to the right path ;)

Regards,
Kristjan

pixelkind
Posted: Tuesday, November 28, 2006 11:55:44 AM
Rank: Newbie

Joined: 11/27/2006
Posts: 4
first, i am sorry for my mistake with not closing the tags.
i have just written it down in an editor in 5 minutes ;] so no error check...

the media needs 2 arguments:
Code:
<xsl:variable name="folder" select="umbraco.library:GetMedia($nodeID, 'true')"/>


now it should work,
the other problem i don't really get...
sorry...
whogoeson
Posted: Wednesday, November 29, 2006 12:22:24 AM
Rank: Devotee

Joined: 8/10/2006
Posts: 46
Thanks Garrit

It works… :w00t:

If anyone else wants to try it out, I ended up using this code:
Code:

<?xml version="1.0" encoding="UTF-8"?> 
 
<!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp " "> ]> 
 
<xsl:stylesheet
    version="1.0"   
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   
      xmlns:msxml="urn:schemas-microsoft-com:xslt" 
      xmlns:umbraco.library="urn:umbraco.library" 
      exclude-result-prefixes="msxml umbraco.library"> 
 
<xsl:output method="xml" omit-xml-declaration="no" indent="yes"/> 

<xsl:param name="currentPage"/> 
<xsl:template match="/"> 
<xsl:variable name="nodeID" select="umbraco.library:RequestQueryString('nodeID')" /> 
<xsl:variable name="folder" select="umbraco.library:GetMedia($nodeID, 'true')"/>
 


<playlist version="1" xmlns="http://xspf.org/ns/0/"> 
    <trackList> 
        <xsl:for-each select="$folder/node"> 
            <track> 
                <title><xsl:value-of select="./@nodeName" /></title> 
                <creator><xsl:value-of select="./@creator" /></creator> 
                <location><xsl:value-of select="./data [@alias = 'umbracoFile']" /></location> 
                <info><xsl:value-of select="./data [@alias = 'xspf']" /></info> 
            </track>
        </xsl:for-each> 
    </trackList> 
</playlist> 

</xsl:template> 
</xsl:stylesheet> 


This code will ( combined with -> www.mysite/xspf.aspx?nodeID=the_folder_ID ) make a listing of the content I a media folder.

This can be user with players using xspf playlists.
I am using it with a Flash Player created by Jeroen Wijering - http://www.jeroenwijering.com/


I used this code for the Flash player Template:
Code:

<p id="player"></p>
    <script type="text/javascript">
        var FO = {     movie:"/media/imagerotator.swf",width:"600",height:"600",majorversion:"7",build:"0",bgcolor:"#000000", flashvars:"file=/xspf.aspx?nodeId=<?UMBRACO_GETITEM field="Media_Folder"/>&shownavigation=true&linkfromdisplay=false&transition=random" };
        UFO.create(FO, "player");
    </script>


Hope this makes any sense :)

Regards,
Kristján
mullog
Posted: Wednesday, November 29, 2006 8:57:19 PM

Rank: Devotee

Joined: 7/20/2006
Posts: 75
Location: Italy
pretty cool stuff.
However I have some problems.
I managed to get the xml xslt running but I am having problems running the media player.
the video does not start, I only get a loading animation. stripes in a circle.

I dont't think it has anything to do with your code, I even tried to upload the flvplayer.html to my server and I get the same. Any Ideas?

Can I also ask you where you are from Kristján?

Regards
Gísli

"We come from the land of the ice and snow, From the midnight sun where the hot springs blow"
whogoeson
Posted: Wednesday, November 29, 2006 11:34:37 PM
Rank: Devotee

Joined: 8/10/2006
Posts: 46
Sæl Gísli

Well I think the error you are getting, is because the path to the images is wrong – did you name your Media Picker “Media_Folder” like I did in the Dokumenttype?

Have you tried to look at the xml xslt with the querystring, in a browser to see if the path is right?

And well you guessed right, a part of me is from the dark north :) – but I am living in Denmark

/ Kristján
mullog
Posted: Thursday, November 30, 2006 2:47:53 AM

Rank: Devotee

Joined: 7/20/2006
Posts: 75
Location: Italy
Kristjan hugosson wrote:

Sæl Gísli

Well I think the error you are getting, is because the path to the images is wrong – did you name your Media Picker “Media_Folder” like I did in the Dokumenttype?

Have you tried to look at the xml xslt with the querystring, in a browser to see if the path is right?

And well you guessed right, a part of me is from the dark north :) – but I am living in Denmark

/ Kristján


Well my path was right, but you got me thinking, and I found out that IIS 6 (windows2003) does not support flv out of the box. I had to configure mime types, instructions where on the adobe site http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_19439 and it works.

so now everything works as a charm :)

"We come from the land of the ice and snow, From the midnight sun where the hot springs blow"
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.