|
Home > Archive > BizTalk Server General > December 2005 > Schema Namespace ...
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Schema Namespace ...
|
|
| Nicato 2005-12-16, 8:48 pm |
| I have two schemas: one is the container (envelope) and one describes the
Message.
So the first is
MessageTransmission.xsd (which looks similar to)
<?xml version="1.0" encoding="utf-16" ?>
<xsd:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
elementFormDefault="unqualified" targetNamespace="http://MyMessage"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import schemaLocation=".\Message.xsd" />
<xsd:annotation>
<xsd:appinfo>
<b:schemaInfo is_envelope="yes" />
</xsd:appinfo>
</xsd:annotation>
<xsd:element name="PA">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="Transmission">
<xsd:complexType>
<xsd:choice>
<xsd:element name="AMutation" type="AMutationType" />
<xsd:element name="ATermination" type="ATerminationType" />
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
the second is the message itself:
<?xml version="1.0" encoding="utf-16" ?>
<xsd:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
elementFormDefault="unqualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="AMutation" type="AMutationType" />
<xsd:element name="ATermination" type="ATerminationType" />
<xsd:complexType name="AMutationType">
<xsd:sequence>
<xsd:element name="Id" type="xsd:int" />
<xsd:element name="ValidFrom" type="xsd:date" />
<xsd:element name="ValidTo" type="xsd:date" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ATerminationType">
<xsd:sequence>
<xsd:element name="Id" type="xsd:int" />
<xsd:element name="ValidFrom" type="xsd:date" />
<xsd:element name="ValidTo" type="xsd:date" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Now I have a message that comes like this:
<PA xmlns="http://MyMessage">
<Transmission>
<AMutation>
<Id>96377</Id>
<ValidFrom>2005-12-16</ValidFrom>
<ValidTo>9999-12-31</ValidTo>
</AMutation>
</Transmission>
<Transmission>
<AMutation>
<ValidFrom>2005-12-16</ValidFrom>
<ValidTo>9999-12-31</ValidTo>
</AMutation>
</Transmission>
</PA>
But the validation fails since the something with the namespace is not
correctly.
I don't know what . When I create an Instance it looks like
<ns0:PA xmlns:ns0="http://MyMessage">
<Transmission>
<AMutation>
<Id>10</Id>
<ValidFrom>1999-05-31</ValidFrom>
<ValidTo>1999-05-31</ValidTo>
</AMutation>
</Transmission>
</ns0:PA>
The "ns0" is something that my deliverd message does not contain. What's
wrong?
| |
| Greg Forsythe 2005-12-17, 2:47 am |
| From the XML Names spec:
The namespace declaration is considered to apply to the element where it is
specified and to all elements within the content of that element, unless
overridden by another namespace declaration with the same NSAttName part:
So in your example Xml the "http://MyMessage" namespace applies to all
elements including the Transmission node and all its elements. However,
according to your schema the Transmission node has no namespace
When you create an Instance in VS.NET it uses a namespace prefix, so the
namespace only applies to prefixed nodes i.e. PA node
Here is a way of representing this Xml without using prefixes, the default
namespace is overridden with a nil namespace.
<PA xmlns:ns0="http://MyMessage">
<Transmission xmlns="">
<AMutation>
<Id>10</Id>
<ValidFrom>1999-05-31</ValidFrom>
<ValidTo>1999-05-31</ValidTo>
</AMutation>
</Transmission>
</PA>
Greg
"Nicato" <Nicato@discussions.microsoft.com> wrote in message
news:CFA84015-CAB1-4209-BEA5-D4A6E95A1C56@microsoft.com...
>I have two schemas: one is the container (envelope) and one describes the
> Message.
> So the first is
> MessageTransmission.xsd (which looks similar to)
> <?xml version="1.0" encoding="utf-16" ?>
> <xsd:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
> elementFormDefault="unqualified" targetNamespace="http://MyMessage"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <xsd:import schemaLocation=".\Message.xsd" />
> <xsd:annotation>
> <xsd:appinfo>
> <b:schemaInfo is_envelope="yes" />
> </xsd:appinfo>
> </xsd:annotation>
> <xsd:element name="PA">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" name="Transmission">
> <xsd:complexType>
> <xsd:choice>
> <xsd:element name="AMutation" type="AMutationType" />
> <xsd:element name="ATermination" type="ATerminationType" />
> </xsd:choice>
> </xsd:complexType>
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
>
> the second is the message itself:
> <?xml version="1.0" encoding="utf-16" ?>
> <xsd:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
> elementFormDefault="unqualified"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <xsd:element name="AMutation" type="AMutationType" />
> <xsd:element name="ATermination" type="ATerminationType" />
>
> <xsd:complexType name="AMutationType">
> <xsd:sequence>
> <xsd:element name="Id" type="xsd:int" />
> <xsd:element name="ValidFrom" type="xsd:date" />
> <xsd:element name="ValidTo" type="xsd:date" />
> </xsd:sequence>
> </xsd:complexType>
> <xsd:complexType name="ATerminationType">
> <xsd:sequence>
> <xsd:element name="Id" type="xsd:int" />
> <xsd:element name="ValidFrom" type="xsd:date" />
> <xsd:element name="ValidTo" type="xsd:date" />
> </xsd:sequence>
> </xsd:complexType>
>
> </xsd:schema>
>
>
> Now I have a message that comes like this:
> <PA xmlns="http://MyMessage">
> <Transmission>
> <AMutation>
> <Id>96377</Id>
> <ValidFrom>2005-12-16</ValidFrom>
> <ValidTo>9999-12-31</ValidTo>
> </AMutation>
> </Transmission>
> <Transmission>
> <AMutation>
> <ValidFrom>2005-12-16</ValidFrom>
> <ValidTo>9999-12-31</ValidTo>
> </AMutation>
> </Transmission>
> </PA>
>
> But the validation fails since the something with the namespace is not
> correctly.
> I don't know what . When I create an Instance it looks like
>
> <ns0:PA xmlns:ns0="http://MyMessage">
> <Transmission>
> <AMutation>
> <Id>10</Id>
> <ValidFrom>1999-05-31</ValidFrom>
> <ValidTo>1999-05-31</ValidTo>
> </AMutation>
> </Transmission>
> </ns0:PA>
>
>
> The "ns0" is something that my deliverd message does not contain. What's
> wrong?
| |
| Nicato 2005-12-17, 7:47 am |
| Thanks a lot.
"Greg Forsythe" wrote:
> From the XML Names spec:
> The namespace declaration is considered to apply to the element where it is
> specified and to all elements within the content of that element, unless
> overridden by another namespace declaration with the same NSAttName part:
>
> So in your example Xml the "http://MyMessage" namespace applies to all
> elements including the Transmission node and all its elements. However,
> according to your schema the Transmission node has no namespace
>
> When you create an Instance in VS.NET it uses a namespace prefix, so the
> namespace only applies to prefixed nodes i.e. PA node
>
> Here is a way of representing this Xml without using prefixes, the default
> namespace is overridden with a nil namespace.
>
> <PA xmlns:ns0="http://MyMessage">
> <Transmission xmlns="">
> <AMutation>
> <Id>10</Id>
> <ValidFrom>1999-05-31</ValidFrom>
> <ValidTo>1999-05-31</ValidTo>
> </AMutation>
> </Transmission>
> </PA>
>
> Greg
>
>
>
>
> "Nicato" <Nicato@discussions.microsoft.com> wrote in message
> news:CFA84015-CAB1-4209-BEA5-D4A6E95A1C56@microsoft.com...
>
>
>
| |
| Nicato 2005-12-17, 7:47 am |
| Your hint helped me. The validation does work now.
But now I run into another problem:
When I use "genereate" instance I can see, that there is a prefix required
<ns0:PA xmlns:ns0="http://MyTransmission">
<Transmission>
etc.
The message that I receive do not contain any <ns0...>
So I receive a message like this:
<PA xmlns="http://MyTransmission">
<Transmission>
etc.
Again, I do not know how to tell Biztalk ignore missing prefixes like ns0
"Greg Forsythe" wrote:
> From the XML Names spec:
> The namespace declaration is considered to apply to the element where it is
> specified and to all elements within the content of that element, unless
> overridden by another namespace declaration with the same NSAttName part:
>
> So in your example Xml the "http://MyMessage" namespace applies to all
> elements including the Transmission node and all its elements. However,
> according to your schema the Transmission node has no namespace
>
> When you create an Instance in VS.NET it uses a namespace prefix, so the
> namespace only applies to prefixed nodes i.e. PA node
>
> Here is a way of representing this Xml without using prefixes, the default
> namespace is overridden with a nil namespace.
>
> <PA xmlns:ns0="http://MyMessage">
> <Transmission xmlns="">
> <AMutation>
> <Id>10</Id>
> <ValidFrom>1999-05-31</ValidFrom>
> <ValidTo>1999-05-31</ValidTo>
> </AMutation>
> </Transmission>
> </PA>
>
> Greg
>
>
>
>
> "Nicato" <Nicato@discussions.microsoft.com> wrote in message
> news:CFA84015-CAB1-4209-BEA5-D4A6E95A1C56@microsoft.com...
>
>
>
| |
|
| Hi,
I wouldn't worry about it too much.
Read this blog entry:
http://geekswithblogs.net/dmillard/...0/20/12935.aspx
I recall Charles Young has done a good write up as well.
A trick I use is to put a sample of the xml youl received thru the schema
generation wizard. Then look at the settings it gives you, particularly
elementFormDefault and attributeFormDefault.
m
"Nicato" wrote:
[vbcol=seagreen]
> Your hint helped me. The validation does work now.
> But now I run into another problem:
> When I use "genereate" instance I can see, that there is a prefix required
> <ns0:PA xmlns:ns0="http://MyTransmission">
> <Transmission>
> etc.
>
> The message that I receive do not contain any <ns0...>
> So I receive a message like this:
> <PA xmlns="http://MyTransmission">
> <Transmission>
> etc.
>
> Again, I do not know how to tell Biztalk ignore missing prefixes like ns0
>
> "Greg Forsythe" wrote:
>
|
|
|
|
|