[xsd-users] Re: getting "different target namespace " for CSTA XML files

Boris Kolpackov boris at codesynthesis.com
Tue Jun 16 06:58:44 EDT 2009


Hi Batya,

Batya Hacohen <Batya.Hacohen at tadirantele.com> writes:

> I am trying to parse the ConnectionClearedEvent XML, that I have
> produced by my program.
> 
> I added the following in my code:
>  
>      xml_schema::properties props;
> 
>     props.no_namespace_schema_location ("file:///" + std::string (cwd) +
> "\\"+"connection-cleared-event.xsd");

This is wrong. If you look into connection-cleared-event.xsd you will
see that it has target namespace
http://www.ecma-international.org/standards/ecma-323/csta/ed4

So the above statement should be:

props.schema_location (
  "http://www.ecma-international.org/standards/ecma-323/csta/ed4",
   "file:///" + std::string (cwd) + "\\"+"connection-cleared-event.xsd");

 
>     props.schema_location ("http://www.w3.org/2001/XMLSchema", 
> 
>             "file:///" + std::string (cwd) +
> "\\"+"connection-cleared-event.xsd");

This is wrong and unnecessary. Simply remove this statement.

 
> This is the input XML:  
> 
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <ConnectionClearedEvent 
>   xmlns:p1="http://www.ecma-international.org/standards/ecma-323/csta/ed4">
>  ...

This XML document is invalid per the connection-cleared-event.xsd schema.
The ConnectionClearedEvent element should be in the 
http://www.ecma-international.org/standards/ecma-323/csta/ed4
namespace while in the above document it is unqualified. A valid document
beginning would look like this:

<p1:ConnectionClearedEvent 
  xmlns:p1="http://www.ecma-international.org/standards/ecma-323/csta/ed4">

Or like this:

<ConnectionClearedEvent 
  xmlns="http://www.ecma-international.org/standards/ecma-323/csta/ed4">

Boris




More information about the xsd-users mailing list