DTDs, schema's and namespaces

Discussion in 'XML' started by Miel Bronneberg, Sep 30, 2003.

  1. Hi,

    I've got a problem validating an xml document with both a dtd and
    a schema. The problem seems to be about namespaces. What I want is a
    well-formed, valid XML document, which also validates against a schema.
    The following document validates ok at
    http://www.stg.brown.edu/service/xmlvalid/ which doesn't check the schema.

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>

    <!DOCTYPE minim SYSTEM "http://www.cs.vu.nl/~embronne/XML/minim/minim.dtd">

    <minim xmlns="http://www.cs.vu.nl/~embronne/XML/minim"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.cs.vu.nl/~embronne/XML/minim http://www.cs.vu.nl/~embronne/XML/minim/minim.xsd">

    <lmnt>
    Only one.
    </lmnt>

    </minim>

    However, the xsv schema validator (http://www.w3.org/2001/03/webdata/xsv)
    complains that: "element {http://www.cs.vu.nl/~embronne/XML/minim}:lmnt
    not allowed here (1) in element
    {http://www.cs.vu.nl/~embronne/XML/minim}:minim, expecting [{None}:lmnt]".
    This can be fixed as follows:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>

    <!DOCTYPE minim SYSTEM "http://www.cs.vu.nl/~embronne/XML/minim/minim.dtd">

    <mnm:minim xmlns:mnm="http://www.cs.vu.nl/~embronne/XML/minim"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.cs.vu.nl/~embronne/XML/minim http://www.cs.vu.nl/~embronne/XML/minim/minim.xsd">

    <lmnt>
    Only one.
    </lmnt>

    </mnm:minim>

    This seems to be unacceptable to the dtd-validator. If I want this to work
    I'd have to modify the dtd and make "mnm:minim" the root element and add as
    an attribute "xmlns:mnm". This I find an ugly solution. I was already
    dissatisfied that I had to declare "xmlns:xsi" and "xsi:schemaLocation" as
    attributes, but making "mnm:minim" the root element, while it should be
    "minim" which just happens to be in the namespace "mnm" is really horrible.
    Are there better solutions?

    Regards, Miel.
     
    Miel Bronneberg, Sep 30, 2003
    #1
    1. Advertising

  2. In article <blc9fd$jh$>,
    Miel Bronneberg <> wrote:

    > <minim xmlns="http://www.cs.vu.nl/~embronne/XML/minim"
    > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    > xsi:schemaLocation="http://www.cs.vu.nl/~embronne/XML/minim
    >http://www.cs.vu.nl/~embronne/XML/minim/minim.xsd">
    >
    > <lmnt>
    > Only one.
    > </lmnt>
    >
    > </minim>


    Ok, so you want minim and lmnt to both be in the minim namespace, which
    is very reasonable.

    But your schema (I just downloaded it) is

    <schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.cs.vu.nl/~embronne/XML/minim"
    xmlns:xml="http://www.w3.org/XML/1998/namespace"
    xmlns:mnm="http://www.cs.vu.nl/~embronne/XML/minim">

    <element name="minim" type="mnm:minimType"/>

    <complexType name="minimType">
    <sequence>
    <element name="lmnt" type="string" minOccurs="0" maxOccurs="unbounded"/>
    </sequence>
    </complexType>

    </schema>

    This declares the local lmnt element in *no namespace*, not in the
    minim namespace. Add elementFormDefault="qualified" to the schema
    element.

    -- Richard
    --
    Spam filter: to mail me from a .com/.net site, put my surname in the headers.

    FreeBSD rules!
     
    Richard Tobin, Sep 30, 2003
    #2
    1. Advertising

  3. Richard Tobin <> wrote:
    : In article <blc9fd$jh$>,
    : Miel Bronneberg <> wrote:

    [snip]

    : Ok, so you want minim and lmnt to both be in the minim namespace, which
    : is very reasonable.

    : But your schema (I just downloaded it) is

    [snip]

    : This declares the local lmnt element in *no namespace*, not in the
    : minim namespace. Add elementFormDefault="qualified" to the schema
    : element.

    Ok, thanks, that works. Now that you mention it, I have read about this
    somewhere. Apologies for not reading the manual well enough.

    Thanks, Miel.

    --
    I'm sorry if my messages are a bit short and perhaps seem somewhat
    impolite. Terrible pains in my right arm prevent me from writing longer,
    more courteous messages.
     
    Miel Bronneberg, Sep 30, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,637
    Markus
    Nov 23, 2005
  2. JimO

    DTDs and syntax

    JimO, May 30, 2005, in forum: HTML
    Replies:
    3
    Views:
    450
    Jukka K. Korpela
    May 31, 2005
  3. Clifford W. Racz
    Replies:
    4
    Views:
    2,079
    Clifford W. Racz
    Feb 13, 2004
  4. martin

    inline schema vs DTDs

    martin, Aug 16, 2004, in forum: XML
    Replies:
    1
    Views:
    502
    Martin Honnen
    Aug 16, 2004
  5. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,312
    Stanimir Stamenkov
    Apr 25, 2005
Loading...

Share This Page