[xsd-users] Parsing namespace problem

Fredrik Elestedt fredrik at elestedt.com
Mon Mar 10 06:40:07 EDT 2008


Hi,

I have a bit of a parsing problem for which I cannot find any solution
online :(
Hopefully someone here can help me.

When I try to parse a message that I receive on a socket I get the following
error:
no mapping provided for namespace '<ns>'.

All occurences of <ns> are the same... this is verified already.

This is how I parse:
*
    105             auto_ptr<ctcif::GeneralMessage> message;
    106             ::xml_schema::properties schema;
    107             schema.schema_location("<ns>", "./schema.xsd");
    108             const xml_schema::flags validate(0);
    109             try
    110             {
    111               fprintf(stderr, "ClientCmi:: About to handle:\n%s\n",
m_xmlBuffer.c_str());
    112               message = ctcif::GeneralMessage_(xml, validate,
schema);
    113               handleMessage(*message);
    114             }
    115             catch (const xml_schema::no_namespace_mapping& e)
    116             {
    117               fprintf(stderr, "ClientCmi:: bad xml: %s\n%s\n",
e.namespace_().c_str(), boost::lexical_cast<std::string>(e).c_str());
    118             }
 *
And the XML which I  try to parse starts with:
*
<GeneralMessage xmlns="<ns>">
  ...
</GeneralMessage>
*
The xsd starts with:

*<xs:schema xmlns:bt="<ns>" attributeFormDefault="qualified"
elementFormDefault="qualified" targetNamespace="<ns>" version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema">*

I've tried to add

*schema.no_namespace_schema_location("./schema.xsd");*

to the parsing, then I get this error:

*Schema in ./schema.xsd has a different target namespace from the one
specified in the instance document .*

Anyone have any idea of what I'm doing wrong here? Or what is wrong in the
xml I'm trying to parse?

Any help is much appriciated.
// Fredrik



More information about the xsd-users mailing list