[Playlist] Announcement: JSPF Parser

Sebastian Pipping webmaster at hartwork.org
Tue Aug 7 21:58:58 UTC 2007


Chris Anderson wrote:
> I've put the finishing touches on my Javascript XSPF Parser. It's been
> tested on Firefox, Safari, and IE. The license is LGPL 3.0.
> 
> http://jchris.mfdz.com/static/jspf_parser/xspf_parser_runner.html
> 
> Please take a look and send me any suggestions. The output has been
> updated to the JSPF format as drafted on the Xiph wiki page linked
> from the release page.

-------------------------------------------------------------
Hey Chris, nice, nice!

Do I understand right your parser is intended to eat invalid
XSPF as well? It read <for_version_1/fail/track-badint-tracknum.xspf>
for me without complaining.

One thing I noticed is <trackNum> and <duration> values
are put in parentheses:

  "duration":"1"

I guess that's a bug?
-------------------------------------------------------------



> I'd like to put this in the Xiph svn, so hopefully after we've put it
> through its paces I will.
> 
> Especially take a look at the whitespace handling (I think I got it
> right)

-------------------------------------------------------------
What I have seen of whitespace handling so far looked good.
-------------------------------------------------------------



> and any suggestions for how to handle XML namespaces would be
> appreciated.

-------------------------------------------------------------
Not sure what exactly you want to know. I'll just write down
a few notes and hope I'll hit some of your possible questions:

* When you write "<playlist>" in XSPF the actual name
  of that tag is "http://xspf.org/ns/0/" + separator + "playlist".
  "+" is concatenation, the separator can be anything but should
  be a char not legal in URIs like space or '§', as you like.
  Not sure what's the best choice though.

* Namespaces can be opened anywhere and their scope *includes*
  the tag that they reside in (which makes sense since you
  couldn't set a namespace for root otherwise).
  This code

     <one xmlns="http://example.com/one/">
       <two xmlns="http://example.com/two/">
         <three />
       </two>
     </one>

  references these tags:
  * http://example.com/one/ one
  * http://example.com/two/ two
  * http://example.com/two/ three

* What you have seen so far was setting and overriding the
  default namespace. You can also assign prefixes and use
  them to better show namespace affiliation when desired:

    <one xmlns="http://example.com/one/">
      <b:two xmlns:b="http://example.com/two/">
        <b:three />
      </b:two>
    </one>

  references the same tags as before.

* So in general namespaces try to avoid naming conflicts
  without making names too long. They first seem complex
  but are quite easy once you're going.

* Most documents will have namespace references just in the
  root element - that is what is recommended to increase
  interoperability - but in theory they can appear anywhere,
  especially in XSPF extension tags. And since that is both
  valid XML and XSPF a parser should ideally be able to
  handle that cases as well.

* Real life example of XML namespaces in XSPF can be seen here:
  http://wiki.xiph.org/index.php/List_of_known_XSPF_extensions#Project_Opus

I hope there was at least something new to you in here so it
made sense to write it down. Please let me know what else
you need to know.



Sebastian




More information about the Playlist mailing list