XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] prefix not bound to a namespace

On 12/10/2007, Skip Evans <skip@bigskypenguin.com> wrote:
> Hey all,
>
> I just joined the list and hope to solve a problem
> I'm having with an XML file.
>
> I'm a PHP/MySQL developer with lots of coding
> experience but no real XML experience. I am now
> working on a project for a client that will
> involve reading XML files.
>
> I have a file beginning with the following:
>
> <?xml version="1.0" ?>
> <!DOCTYPE galeeBkdoc PUBLIC "-//Gale//DTD Gale
> eBook Document DTD 20031113//EN" "galeeBkdoc.dtd">
> <html gale:versionNumber="OEB 1.2, Gale 1.0">
>
> I also have the file galeeBkdoc.dtd in the same
> directory as the XML file, and it contains the
> following:
>
> <!ATTLIST html  xml:lang
> %LanguageCode.datatype;  #IMPLIED
>                    xmlns
> %URI.datatype;           #FIXED
> 'http://www.w3.org/1999/xhtml'
>                    xmlns:gale         CDATA
>               #FIXED 'http://www.gale.com/eBooks'
>                    gale:versionNumber CDATA
>               #FIXED 'OEB 1.2, Gale 1.2' >
> <!ELEMENT head (%HeadOpts.mix; , gale:docName ,
> gale:documentCitation , ((title , %HeadOpts.mix; ,
> (base , %HeadOpts.mix;)?) | (base , %HeadOpts.mix;
> , (title , %HeadOpts.mix;))))>
>
> But when I attempt to load the XML file into
> Firefox running on Ubuntu Linux I get the
> following error:
>
> XML Parsing Error: prefix not bound to a namespace
> Location:
> file:///usr/local/projects/oakwood/esr_01_00002.xml
> Line Number 3, Column 1:<html
> gale:versionNumber="OEB 1.2, Gale 1.0">
>
> I've Googled this error, but I don't think I found
> anything relevant to my problem, or at least my
> newness to XML prevented me from understanding it.
>
> Does this seem to indicate that the XML file is in
> fact not finding the DTD file, or is there
> potentially another problem?

It does - the DTD is defaulting the namespace declaration for the
"gale" prefix, so unless the XML gets validated the prefix won't be
bound, so you get the error. If the parser can find the DTD then it
should be fine.

Personally I really dislike this kind of thing, because (1)
effectively the XML is no longer namespace well-formed so you can't
process it without the DTD and (2) it's treating the namespace like an
attribute which it isn't (and 3 someone probably thinks they're being
really cunning, when if they new the hassle they would cause they'd
realise "cunning" isnt the word)...

I would ensure the namespace declaration actually appears in the XML.
You can still leave the DTD as is, but you'll probably still need to
validate the XML each and every time you use it in case any other
values are defaulted.  (If only the namespace was defaulted and you
sort that out then you can safely validate once, run many)

cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS