Copied to clipboard

Flag this post as spam?

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


  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Aug 18, 2010 @ 12:32
    Sebastiaan Janssen
    0

    Using an external XML file, why won't it work?

    So I'm trying show the results of a Twitter search through XSLT like this:

    <xsl:variable name="twitterSearch" select="umbraco.library:GetXmlDocumentByUrl('http://search.twitter.com/search.atom?lang=all&q=umbraco')"/>

    This results in some beautiful XML:

    <feed xmlns:google="http://base.google.com/ns/1.0" xml:lang="en-US" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom" xmlns:twitter="http://api.twitter.com/">
      <id>tag:search.twitter.com,2005:search/umbraco</id>
      <link type="text/html" href="http://search.twitter.com/search?q=umbraco" rel="alternate"/>
      <link type="application/atom+xml" href="http://search.twitter.com/search.atom?lang=all&amp;q=umbraco" rel="self"/>
      <title>umbraco - Twitter Search</title>
      <link type="application/opensearchdescription+xml" href="http://search.twitter.com/opensearch.xml" rel="search"/>
      <link type="application/atom+xml" href="http://search.twitter.com/search.atom?lang=all&amp;q=umbraco&amp;since_id=21479337184" rel="refresh"/>
      <twitter:warning>since_id removed for pagination.</twitter:warning>
      <updated>2010-08-18T10:22:13Z</updated>
      <openSearch:itemsPerPage>15</openSearch:itemsPerPage>
      <link type="application/atom+xml" href="http://search.twitter.com/search.atom?max_id=21479337184&amp;page=2&amp;q=umbraco" rel="next"/>
      <entry>
        <id>tag:search.twitter.com,2005:21479337184</id>
        <published>2010-08-18T10:22:13Z</published>
        <link type="text/html" href="http://twitter.com/undisclosedp/statuses/21479337184" rel="alternate"/>
        <title>Have an umbraco site on 4.0.3 are there any security issues that would make me to upgrade? Users are hesitant to let me just for features!</title>
        <content type="html">Have an &lt;b&gt;umbraco&lt;/b&gt; site on 4.0.3 are there any security issues that would make me to upgrade? Users are hesitant to let me just for features!</content>
        <updated>2010-08-18T10:22:13Z</updated>
        <link type="image/png" href="http://a2.twimg.com/profile_images/540081894/nom0001_normal.jpg" rel="image"/>
        <twitter:geo>
        </twitter:geo>
        <twitter:metadata>
          <twitter:result_type>recent</twitter:result_type>
        </twitter:metadata>
        <twitter:source>&lt;a href=&quot;http://www.realmacsoftware.com/socialite&quot; rel=&quot;nofollow&quot;&gt;Socialite.app&lt;/a&gt;</twitter:source>
        <twitter:lang>en</twitter:lang>
        <author>
          <name>undisclosedp (Michael)</name>
          <uri>http://twitter.com/undisclosedp</uri>;
        </author>
      </entry>
    </feed>

    But then I try to select something but I get no results, why? Examples:

    <xsl:copy-of select="$twitterSearch/feed" />
    <xsl:copy-of select="$twitterSearch//feed" />
    <xsl:copy-of select="$twitterSearch//entry" />

    None of these output anything.. what's going on?

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Aug 18, 2010 @ 12:38
    Thomas Höhler
    0

    try

    <xsl:copy-of select="$twitterSearch" />

    I think you are at the root

    Thomas

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Aug 18, 2010 @ 12:39
    Sebastiaan Janssen
    0

    @Thomas Yes, that works fine, that produces the XML that you see.. 

  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    Aug 18, 2010 @ 12:48
    Lee Kelleher
    4

    Sebastiaan, Sebastiaan, Sebastiaan... it's all about the namespaces! ;-)

    First try this...

    <xsl:copy-of select="$twitterSearch/atom:feed" />

    If that doesn't work, then try adding the namespaces to the top of your XSLT.

    <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:google="http://base.google.com/ns/1.0"
        xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/"
        xmlns:atom="http://www.w3.org/2005/Atom"
        xmlns:twitter="http://api.twitter.com/"
        exclude-result-prefixes="msxml umbraco.library google openSearch atom twitter">

    Namespaces have caught me out many many times! ;-)

    Cheers, Lee.

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Aug 18, 2010 @ 12:51
    Chriztian Steinmeier
    2

    Hi Sebastiaan,

    This is the good old namespace issue... Have a look at this: http://our.umbraco.org/forum/developers/xslt/8016-getXMLDocument-won't-display-any-content

    /Chriztian

    [EDIT] Arghhh... slain by the might Lee Kelleher :-)

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Aug 18, 2010 @ 13:58
    Sebastiaan Janssen
    0

    Thanks guys, that helps a lot!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies