Re: [xml] XSLT question, regarding RSS



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John L. Clark wrote:
| Hey Colin,
|
| On Tue, Apr 27, 2004 at 01:24:54AM -0700, Colin Fox wrote:
|
|>I'm playing around with making an RSS aggregator. I've got an XSLT that
|>handles a number of news sites, but Slashdot's is stumping me.
|
|
| Well, there seem to be a few issues.  First of all, your XSLT script
| "successfully" executes on the sample RSS.  However, I don't know what
| sort of behaviour you expect it to exhibit; you aren't too clear on that
| point.

It doesn't actually "successfully" execute, since the "item" node is
unrecognized. All I want it to do is execute each appropriate template
as it encounters each element in the DOM. So, when there is an "item" in
the incoming XML file, I want my "item" template to get processed.
Pretty straightforward.

| Secondly, there are some obvious "problems" with the XSLT script.  For
| instance, in line 21 you try to match an "item" element in the empty
| namespace (that is, you don't specify a default namespace anywhere,
| hence this template will *only* match the item element that has *no*
| namespace).

I guess this is where I went wrong. I'm a little unclear on how the lack
of a namespace specifier works, then.

The full version of my xsl file (I only included a small piece) parses
the RSS output of some other sites perfectly, including Yahoo and eWeek.
The difference (I see now), is that the Slashdot RSS is specifying a
number of namespaces, one of which has no prefix, which I assume means
it becomes the default.

This default namespace doesn't have a name, so how am I supposed to
create an XSLT stanza that 'answers' to it, other than by not including
a namespace?

| I don't think this is the behaviour you want.  Look
| carefully at the sample RSS, and you will see that every element is in
| an explicit namespace, even those with no prefixes.  Almost all of your
| templates are like this.
How do you specify an explicit namespace without a prefix? By explicit
prefix you mean:

<rss:item>

where rss is the prefix, right? What is a prefix-less explicit namespace?

| I could make additional suggestions, but I believe it would be better if
| you made your intended behaviour clearer.

My intent is utterly simple - I want to be able to process a given XML
file via my XSL file. I've created what I thought were appropriate
templates to handle the processing, but I get no results, and I didn't
really understand why.

| Take care,
|
|     John L. Clark

Regards,
~  cf
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAkIT3oaQ1/feGlJoRAhB4AKCGEouErNFM43ZHOflr3MTt69m4LgCfW8H+
bnWLw+2P5Pp/6k687/wvsF4=
=V6Am
-----END PGP SIGNATURE-----



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]