[xsd-users] namespace mapping

Rizzuto, Raymond Raymond.Rizzuto at sig.com
Tue Jun 24 17:44:48 EDT 2008


Boris,

Thanks - I think I was getting namespace, prefix and location confused.
I'm still learning about XML Schema's (prior experience was DTD) and the
XSD tool, and not sure I understand why I even need to specify a mapping
to serialize the objects.  The fact that XSD insulates me from needing
to know the details of serialization is a double edged sword.  Is it
possible that XSD could choose unique prefixes for the namespaces in the
document?



Anyway, for now, I have made changes that seem to work.  If I understand
correctly, I can use an empty prefix with a namespace of
"http://sig.com/sdmp/messages".  I also have no schemaLocation.  So it
makes sense that I need the map of the empty prefix to specify
name="http://sig.com/sdmp/messages" and that I don't/can't specify a
schema location since the schema is not going to be available to the
running code.

I also came across the no_xml_declaration flag - I may end up using that
since I have no need for the xml header in my application.  It is an
intra-company application, where both ends will be using XML binding
against the same schema.  My end will be using XSD, the other end is a
C# application using another binding tool.

Ray
-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: Tuesday, June 24, 2008 2:41 PM
To: Rizzuto, Raymond
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] namespace mapping

Hi Ray,

Rizzuto, Raymond <Raymond.Rizzuto at sig.com> writes:

>         xml_schema::NamespaceInfomap map;
>         map[""].name = "";
>         map[""].schema = "SDMP-1.1.XSD";
>         message(std::cout, m, map);
>
> [...]
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>            xmlns="http://sig.com/sdmp/messages"
>            targetNamespace="http://sig.com/sdmp/messages"
>            elementFormDefault="qualified"
>            attributeFormDefault="unqualified" version="1.1">

You get this exception because your vocabulary uses the
http://sig.com/sdmp/messages namespace however you haven't provided
the prefix-namespace mapping for it.

I also think you are confusing the namespace part in the schemaLocation
attribute with the place where the schema is located. In reality the
namespace part should be the same as the targetNamespace attribute in
your schema (only if your schema does not have targetNamespace should
you be using noNamespaceSchemaLocation). The actual schema name can
contain an absolute path (or even a remote URI), for example:

schemaLocation="http://sig.com/sdmp/messages
http://sig.com/SDMP-1.1.XSD"

If the schema name is not a URI then it is resolved relative to the
location of the XML document that contains the schemaLocation attribute
(note that the namespace part is not used to locate the schema).

There is also a number of ways to override the schema location
information
that comes from XML documents. For more information on this see Section
5.1,
"XML Schema Validation and Searching" in the C++/Tree Mapping Getting
Started Guide:

http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#
5.1

Boris

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.




More information about the xsd-users mailing list