Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Inx51 54 posts 107 karma points
    Mar 14, 2011 @ 12:30
    Inx51
    0

    Namespace problem? Youtube API

    Hi!

    Im trying to access some of the data from the youtube API by useing the following XSL

    <?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"
        xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon"
        xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes"
        xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath"
        xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions"
        xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings"
        xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" 
        xmlns:yt="gdata.youtube.com/feeds/api/videos/ADos_xW4_J0"
        exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets">

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>

    <xsl:template match="/">
      <!-- start writing XSLT -->
      <xsl:variable name="Feed" select="umbraco.library:GetXmlDocumentByUrl('http://gdata.youtube.com/feeds/api/videos/ADos_xW4_J0')" />
      
      <xsl:for-each select="$Feed/*[local-name()='entry']">
        <xsl:value-of select "*[local-name()='yt:location']" disable-output-escaping="yes" />
            <hr/>
        </xsl:for-each>

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


    The thing is that for some reason I can't get the value of yt:location..I whould guess its because of the namepsace..but Im not sure...so..anyway...how do I get the value of for instance in this case yt:location?

    And by the way..any suggestions of improvments to this xslt-file is appreciated :)

    Thanks in advance!

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Mar 14, 2011 @ 12:58
    Jeroen Breuer
    0

    Not sure if this will help, but you might want to have a look at uTube. It has some nice xslt samples: http://utube.codeplex.com/SourceControl/changeset/view/8325#196501

    Jeroen

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Mar 14, 2011 @ 13:37
    Chriztian Steinmeier
    0

    Hi Inx51,

    You've declared the namespace, so you should just be able to do:

    <xsl:value-of select="yt:location" disable-output-escaping="yes" />

    In fact - these should all work:

    <xsl:value-of select="yt:location" disable-output-escaping="yes" />
    
    <xsl:value-of select="*[name() = 'yt:location']" disable-output-escaping="yes" />
    
    <xsl:value-of select="*[local-name() = 'location']" disable-output-escaping="yes" />
    

    /Chriztian

  • Inx51 54 posts 107 karma points
    Mar 14, 2011 @ 13:38
    Inx51
    0

    Thanks :)..I did an ugly hack for it(atleast as I see it)..I simply added:

    xmlns:yt="http://gdata.youtube.com/feeds/api/videos/ADos_xW4_J0"

    To the

    And then also added the prefix "yt" to the exclude-result-prefixes attribute :) and then used <xsl:value-of select "*[local-name()='location']" disable-output-escaping="yes" /> 

    :)

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Mar 14, 2011 @ 20:32
    Chriztian Steinmeier
    0

    What I was trying to tell you was that because you have declared the prefix (with xmlns:yt="...") you can (and should) use the full qualified name (yt:location) to access the element. It's that simple, and exactly how you do namespace stuff in XSLT.

    /Chriztian 

Please Sign in or register to post replies

Write your reply to:

Draft