Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Development

xsl/xquery support in dashboard?

Author Message
xbhoff



Joined: 05 Feb 2005
Posts: 2

Posted: Sat Feb 05, 2005 - 10:52 am    Post subject: xsl/xquery support in dashboard? Reply with quote

can anyone tell me if dashboard has xslt support, or even xquery support in the manner that Sherlock does? or a built-in caching scheme like Sherlock?
View user's profile Send private message Send e-mail AIM Address Widgets
blurry
Quality Control


Joined: 03 Feb 2005
Posts: 33
Location: UK

Posted: Tue Feb 08, 2005 - 8:22 am    Post subject: Yes (and no) Reply with quote

This is a difficult one to answer. I, too, wanted to show styled XML in a widget, for reading RSS/RDF feeds. I tried ALL sorts. After a few days of fiddling around with various options and approaches, here's my findings:

Showing XML that you've got from an external source (RSS, or whatever) through XmlHttpRequest in a widget (or in Safari, for that matter) is not as easy as you'd like. You obviously need some JavaScript to go and get the XML, so you therefore also need an HTML page to call the JavaScript. You can go and get the XML easily, but if you dump it to the screen, it doesn't show nicely. If you try and put the XML into an IFrame, you hit the same problem. It tries to render it as HTML, but as it's not HTML, none of the tags are recognised, so it just renders the text it can.

This really annoyed me, because if you manually load an XML file that has a CSS stylesheet against it, it loads fine and looks real pretty (depending on your stylesheet, of course!). How to do this on the fly baffled me, so I took the approach I did my best to avoid taking, which was to generate HTML from the XML manually in JavaScript. I know, I know... I feel dirty.

XSLT is sort of supported in Safari. Take a look here: http://weblogs.mozillazine.org/hyatt/archives/2004_08.html#006219
It might be supported more in Safari 2.0 in Tiger, but you'll have to wait and see. Basic rule of thumb: If it works in Safari, the odds are good that it'll work in Dashboard. There are occasions when things don't work in Dashboard even though they work in Safari, but I haven't had any problems so far. Some people here have had problems with Flash in Dashboard, however.

I'm not sure about XQuery - try experimenting in Safari.

Hope this helps.

George.
_________________
If your only tool is a hammer, everything looks like a nail
View user's profile Send private message Send e-mail Widgets
Sembazuru



Joined: 30 Jan 2005
Posts: 6
Location: Canada

Posted: Tue Feb 08, 2005 - 8:28 pm    Post subject: Reply with quote

As you might have noticed, I have actually embedded an RSS feed in my Showcase widget. The trick is to not render it yourself - I used RSS Digest to generate an unordered list of feed items, which I embedded using JavaScript and styled.

I hope this helps, if only for RSS feeds. Smile
View user's profile Send private message Send e-mail Visit poster's website Widgets
blurry
Quality Control


Joined: 03 Feb 2005
Posts: 33
Location: UK

Posted: Tue Feb 08, 2005 - 9:11 pm    Post subject: Reply with quote

Sembazuru wrote:
The trick is to not render it yourself - I used RSS Digest to generate an unordered list of feed items, which I embedded using JavaScript and styled.


I looked at using that, but I took the approach of generating the HTML myself, purely for flexibility reasons. It's a nifty site, though.

Flashmanburgess had also done some fantastic art that I was dying to use, and I don't think I would have had all the control I wanted if I'd used RSS Digest.

George.
_________________
If your only tool is a hammer, everything looks like a nail
View user's profile Send private message Send e-mail Widgets
Chris



Joined: 27 Jan 2005
Posts: 344
Location: Durham, UK

Posted: Wed Feb 09, 2005 - 8:43 am    Post subject: Reply with quote

A couple of years ago I added smiley support to my blog (which no longer exists) using XML tags such as <grin />.

To do this, I declared my own (arbitrary) doctype (I never actually made the DTD - it wasn't necessary) and just styled the elements with CSS. So <grin /> had something like the following rule applied to it:

grin {
display: inline-block;
height: 15px;
width: 15px;
background: url(smileys/grin.png);
}

Quite a simple approach.

It only worked in Moz browsers though, and not Safari (at the time). I'll have to check if that works now, as it might be an easier solution.
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
blurry
Quality Control


Joined: 03 Feb 2005
Posts: 33
Location: UK

Posted: Wed Feb 09, 2005 - 9:00 am    Post subject: Reply with quote

Chris wrote:
It only worked in Moz browsers though, and not Safari (at the time). I'll have to check if that works now, as it might be an easier solution.


It's possible now - I was using CSS to style XML in Safari. This works fine when you have the XML file on the local computer, or you're viewing an XML file on a remote server. If you're fetching the XML from a webservice, or using JavaScript on an HTML page to find out the address to go to to get the XML and then fetching it into a var, how do you then tell the browser to render the XML as XML, instead of it trying to render it as HTML?

I tried getting my JavaScript on an HTML page to put the XML it got from the server into an IFrame, but it always rendered the XML as HTML.

Am I missing something? I can post some code of what I was trying if people want to have a look.

George.
_________________
If your only tool is a hammer, everything looks like a nail
View user's profile Send private message Send e-mail Widgets
Chris



Joined: 27 Jan 2005
Posts: 344
Location: Durham, UK

Posted: Wed Feb 09, 2005 - 11:56 am    Post subject: Reply with quote

Well, I've just spent the last hour playing around with this (I'm bored...) and found it more effort than it's worth.

Basically, I pulled in the dashboarddev RSS feed via XMLHttpRequest and then stripped out the unwanted tags using a regexp on the responseText and plugged it into a div using innerHTML.

While I can style the elements etc, it seems it would be much more flexible just doing it with the DOM on the responseXML (how I usually do this sort of thing). Also, Safari seems to have some serious issues with this still - for example, I needed to add in a dummy element before it would then render anything else.

Oh well, it was a nice wee experiment, although it took far longer than it should've because of the non standard characters used in the feed for Kelibo WebFrog messing up my regexps Razz
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
blurry
Quality Control


Joined: 03 Feb 2005
Posts: 33
Location: UK

Posted: Wed Feb 09, 2005 - 12:46 pm    Post subject: Reply with quote

Chris wrote:
Basically, I pulled in the dashboarddev RSS feed via XMLHttpRequest and then stripped out the unwanted tags using a regexp on the responseText and plugged it into a div using innerHTML.


Why did you use a regexp to remove unwanted tags? Are you trying to hide a whole element or just take the tags out? If you're hiding the whole element and are using CSS to style the XML, you can just surpress the tags you don't want. For example, if you didn't want to show the description element, just use something like:
Code:
item>description
{
    display: none;
}


I tried to style the XML by putting an XML stylesheet processing instruction into the XML text using a regexp, but it still doesn't render properly.

George.
_________________
If your only tool is a hammer, everything looks like a nail
View user's profile Send private message Send e-mail Widgets
Chris



Joined: 27 Jan 2005
Posts: 344
Location: Durham, UK

Posted: Wed Feb 09, 2005 - 12:55 pm    Post subject: Reply with quote

Well, duh. Razz

I was removing the <?xml and <rdf; tags, since they are unnecessary.
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
blurry
Quality Control


Joined: 03 Feb 2005
Posts: 33
Location: UK

Posted: Wed Feb 09, 2005 - 1:12 pm    Post subject: Reply with quote

Chris wrote:
I was removing the <?xml and <rdf; tags, since they are unnecessary.


I'm not sure if the XML declaration is unnecessary or not. While your file is valid XML without it (provided the rest of the XML is valid), it might help some browsers determine what sort of content the file has. This is when I gave up - how does the browser know that XML is XML?

It can't do it from the file extension, because a file which contains just XML doesn't have to have a .xml extension (PLIST files don't - yet they're valid XML files). It can't do it from the XML declaration, because I had that in my XML I was putting into the IFrame, yet it was not getting rendered as XML. Does it do it from the document type in the HTTP headers? What if the file is on disk so HTTP isn't used? I was opening the document with a MIME type of application/xml, yet still no workie.

Just ramblings and findings.

George.
_________________
If your only tool is a hammer, everything looks like a nail
View user's profile Send private message Send e-mail Widgets
Chris



Joined: 27 Jan 2005
Posts: 344
Location: Durham, UK

Posted: Wed Feb 09, 2005 - 1:31 pm    Post subject: Reply with quote

Well, for what i was doing I was just adding the parts of the RSS I wanted to an existing page, so having the declaration that it was an XML document embedded within the file is not desired.

So, I had an html document that used a transitional doctype (I probably shouldn't've, but...) and then had different namespaces applied: xmlns:xhtml and a custom one so I could add in arbitrary XML elements and it would be a valid document.

This is purely so I could use standard tags in the normal way, and pull in the non-HTML ones once the document had loaded. I mentioned in my first post how I did that. So that's why I didn't want the <?xml tag Smile
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
xbhoff



Joined: 05 Feb 2005
Posts: 2

Posted: Fri Feb 11, 2005 - 10:25 am    Post subject: Reply with quote

Yes thanks, I forgot about the XSLT support planned/announced for some later version of Safari, so that should be there for widgets as client-side JavaScript XSLT. And from what I've read, one can run a shell script from a widget, so there's always the option of doing an xsltproc from the Unix command line as well.

I guess I'm wondering/hoping that the XQeury implementation in Sherlock will live on somehow in Dashboard, and was curious about caching. I think there's some sort of JavaScript "refresh" function, from snooping through widget sample code, but was wondering if this is similar/same/different from the caching thing in Sherlock.

I think I'm also asking questions that might test NDA restrictions in a full response, so sorry if I am. It's just too late in the game for me to consider forking out $500 to find out, but I'm catching Dashboard developement fever in some form here.
View user's profile Send private message Send e-mail AIM Address Widgets
blurry
Quality Control


Joined: 03 Feb 2005
Posts: 33
Location: UK

Posted: Fri Feb 11, 2005 - 10:34 am    Post subject: Reply with quote

xbhoff wrote:
I think I'm also asking questions that might test NDA restrictions in a full response, so sorry if I am. It's just too late in the game for me to consider forking out $500 to find out, but I'm catching Dashboard developement fever in some form here.


Yes you are Wink

If I were you, I'd still consider signing up for an ADC Select membership, even though Tiger will be out first half of this year. It gets you so much. If you're planning on getting a new system in the next 12 months, it's worth signing up just for the hardware discount.

Ooh... and you get a cool T-Shirt when you sign up, too!

George.
_________________
If your only tool is a hammer, everything looks like a nail
View user's profile Send private message Send e-mail Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group