• Home
  • RSS Feed
  • Log in

If it looks like XML…
Posted by Jeroen van Erp in the early morning: August 17th, 2007

And walks and talks like XML, it surely must be XML. Yes, well how wrong you can be about assumptions is once more shown in this blog.

One of our clients has an application through which videos are streamed. They do this by providing a browser embedded player, or your stand-alone Windows Media Player with an ASX file. The ASX file tends to look like this:

 
<ASX Version="3">
  <ENTRY>
    <REF HREF="http://www.somecompany.com/videos/video.wmv"/>
  </ENTRY>
</ASX>
 

So far so good. As long as that "video.wmv" exists, it will be played correctly by the Windows Media Player. Our client however requested that we add metadata from a database to the ASX file, so that when it is played in your stand-alone Windows Media Player, you will see the title, author and publication date of the video and a logo of the company. The problem however was that we don't generate these ASX files, they exist on the streaming server. This meant that we needed to read the ASX files on the fly, change them and send the response to the requesting client.

Because of the format we decided to use Dom4J to parse the XML and create a DOM tree of the ASX. We then added nodes to the DOM document, and wrote the resulting XML to the response stream. The XML which was the result of this exercise looked like the following:

 
<?xml version="1.0" encoding="UTF-8"?>
<ASX Version="3">
  <ENTRY>
    <DURATION>00:00:10.00</DURATION>
    <REF HREF="http://www.somecompany.com/images/companylogo.jpg"/>
  </ENTRY>
  <ENTRY>
    <TITLE>Title of the video</TITLE>
    <AUTHOR>Xebia</AUTHOR>
    <COPYRIGHT>2007-08-17</COPYRIGHT>
    <REF HREF="http://www.somecompany.com/videos/video.wmv"/>
  </ENTRY>
</ASX>
 

This is valid XML. But all of a sudden, the videos didn't play anymore in Windows Media Player. After re-checking each of the tags carefully with the ASX Elements Reference on MSDN, we couldn't find what was wrong with this ASX file. That was, until we read the following statement here:

"... The first four characters of an ASX file must be <ASX. ..."

Wait a minute, that means it is XML, but you cannot include the XML preamble?!... After discarding the preamble from the result XML, the file suddenly worked again, and the video was streamed. The valuable lesson here of course is that If it looks, walks, talks and acts like XML, it still just might not be real XML.

  • Share/Bookmark

Filed under XML | 3 Comments »



3 Responses to “If it looks like XML…”



    Lars Vonk Says:
    Posted at: August 17, 2007 at 10:15 am

    As Homer would say: “Doh!”



    Robert van Loghem Says:
    Posted at: August 17, 2007 at 10:24 am

    As if Microsoft would have it any other way! ;)

    “Embrace and Extend” eh…no in this case “Embrace and Detract”



    Nico Says:
    Posted at: August 17, 2007 at 7:49 pm

    Yeah, IE does something similar, if you don’t specify the DOCTYPE on the first line in your strict xhtml webpage, IE won’t recognize, however to be strict xhtml you have to specify the XML preamble on the first line…



Leave a Reply

Click here to cancel reply.

Deployment automation for Java application running on Websphere, WebLogic and JBoss

Archives

  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009

Xebia Sites

  • Xebia Corporate
  • Xebia France
  • Xebia India

Categories

  • Java (282)
  • Agile (109)
  • General (50)
  • Testing (42)
  • Performance (42)
  • Hibernate (36)
  • Scrum (33)
  • Podcast (31)
  • Architecture (31)
  • Spring (28)
  • SOA (24)
  • Maven (22)
  • Project Management (22)
  • Middleware (23)
    • Deployment (14)
  • Flex (17)
  • JPA (17)
  • Eclipse (15)
  • Xebia Labs (15)
  • Quality Assurance (14)

Tag Cloud

    Semantic Web Agile Seam Groovy qcon IntelliJ product owner Lean Functional Programming Maven Testing Performance Closures XML JavaOne Poppendieck Grails Ajax Scrum Agile Awareness Workshop SOA Scala Introduction to Agile fitnesse Hibernate esb Java Xebia Spring Architecture