Re: Target namespace - Schema - Instances



For BizTalk server, it is not recommended. It is more likely to have the
same root elements, but different content if you use blank namespace (name
conflict). BizTalk will require you to create a custom pipeline that
explicitly specify schema you want to use if it is the case which is harder.

If I think about pros of using blank namespace is that it is easier to do
some XPATH query since you don't need to deal with the namespace, but I
don't think this is a real good reason that you have to use a blank
namespace unless you already have a system which only understand blank
namespace and you don't want to touch the system.

Thanks,
Sunghwa

--------------------
| Reply-To: "John Lee" <johnl@xxxxxxxxxxxxxxx>
| From: "John Lee" <johnl@xxxxxxxxxxxxxxxx>
| References: <ODZhGMHNFHA.2384@xxxxxxxxxxxxxxxxxxxx>
<yKN42TKNFHA.3320@xxxxxxxxxxxxxxxxxxxxx>
<#G4LX4dVFHA.2172@xxxxxxxxxxxxxxxxxxxx>
<Ow$12z#VFHA.3336@xxxxxxxxxxxxxxxxxxxxx>
| Subject: Re: Target namespace - Schema - Instances
| Date: Sat, 14 May 2021 10:50:09 -0700
| Lines: 189
| Organization: College Loan Corporation
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <umU1f1KWFHA.4076@xxxxxxxxxxxxxxxxxxxx>
| Newsgroups: microsoft.public.biztalk.general
| NNTP-Posting-Host: cpe-24-161-161-175.san.res.rr.com 24.161.161.175
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.biztalk.general:13863
| X-Tomcat-NG: microsoft.public.biztalk.general
|
| Hi, Sunghwa,
|
| Thank you for your effort trying to get the doc. Could you please help on
| another question?
|
| Does Microsoft recommend or NOT recommend using BLANK Target namespace?
| What is the pros & cons of that?
|
| Thanks
| John
|
| "Sunghwa Jin [MSFT]" <shjin@xxxxxxxxxxxxxxxxxxxx> wrote in message
| news:Ow$12z%23VFHA.3336@xxxxxxxxxxxxxxxxxxxxxxxx
| > Dear John,
| >
| > I tried find public-ready version of the best practice document, but I
| > couldn't find one released from Microsoft. However I can tell it
basically
| > doesn't have much guideline other than using qualified element name and
| > unqualified attribute name. And one other thing is that Microsoft and
IBM
| > decided to use PascalCasing for element and attribute name for XML
schema
| > design, as I know.
| >
| > You will probably want to check some web search engine to find any web
| > site
| > discussing best practice for XML schema design. I will post one if I
find
| > any of course.
| >
| > Thanks,
| > Sunghwa
| >
| > --------------------
| > | Reply-To: "John Lee" <johnl@xxxxxxxxxxxxxxx>
| > | From: "John Lee" <johnl@xxxxxxxxxxxxxxxx>
| > | References: <ODZhGMHNFHA.2384@xxxxxxxxxxxxxxxxxxxx>
| > <yKN42TKNFHA.3320@xxxxxxxxxxxxxxxxxxxxx>
| > | Subject: Re: Target namespace - Schema - Instances
| > | Date: Tue, 10 May 2021 21:01:18 -0700
| > | Lines: 121
| > | Organization: College Loan Corporation
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | X-RFC2646: Format=Flowed; Original
| > | Message-ID: <#G4LX4dVFHA.2172@xxxxxxxxxxxxxxxxxxxx>
| > | Newsgroups: microsoft.public.biztalk.general
| > | NNTP-Posting-Host: cpe-24-161-161-175.san.res.rr.com 24.161.161.175
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.biztalk.general:13754
| > | X-Tomcat-NG: microsoft.public.biztalk.general
| > |
| > | Thanks very much, Sunghwa!
| > |
| > | Do you have a published document for Best practice for xml schema?
| > |
| > | Thanks!
| > | John
| > |
| > | "Sunghwa Jin [MSFT]" <shjin@xxxxxxxxxxxxxxxxxxxx> wrote in message
| > | news:yKN42TKNFHA.3320@xxxxxxxxxxxxxxxxxxxxxxxx
| > | > Three messages are all different:
| > | > <ns0:Pet
| > | >
| >
xmlns:ns0="http://schemas.pursca.com/Pet";><Name>Name_0</Name><Type>Type_0</T
| > | > ype></ns0:Pet>
| > | > <Pet><Name>Name_0</Name><Type>Type_0</Type></Pet>
| > | > <Pet
| > | >
| >
xmlns="http://schemas.pursca.com/Pet";><Name>Name_0</Name><Type>Type_0</Type>
| > | > </Pet>
| > | >
| > | > For the first one, <Pet> element has 'http://schemas.pursca.com/Pet'
| > | > namespace, but <Name> element actually has empty namespace.
| > | > For the second one, both <Pet> and <Name> elements have empty
| > namespace.
| > | > For the third one, both <Pet> and <Name> elements have
| > | > 'http://schemas.pursca.com/Pet' namespace.
| > | >
| > | > BizTalk schema editor doesn't make it default, but I suggest you
| > change
| > | > schemaFormDefault property to Qualified so that all elements you
deine
| > in
| > | > the schema can be qualified. It is a best practice for XML schema
| > design.
| > | > But do not make schemaAttributeFormDefault to Qualified. It is also
a
| > best
| > | > practice that you don't make attribute qualified in general.
| > | >
| > | > In C#, for XML serialization, you can specify namespace for each
| > element
| > | > like below:
| > | >
| > | > [XmlElement(ElementName = "Pet", Namespace =
| > | > "http://schemas.pursca.com/Pet";)]
| > | > public class Pet
| > | > {
| > | > [XmlElement(ElementName = "Name", Namespace =
| > | > "http://schemas.pursca.com/Pet";)]
| > | > public string Name
| > | > {
| > | > get { ...} set { ...}
| > | > }
| > | > ...
| > | > }
| > | >
| > | > Thanks,
| > | > Sunghwa
| > | >
| > | > --------------------
| > | > | Reply-To: "John Lee" <johnl@xxxxxxxxxxxxxxx>
| > | > | From: "John Lee" <johnl@xxxxxxxxxxxxxxxx>
| > | > | Subject: Target namespace - Schema - Instances
| > | > | Date: Tue, 29 Mar 2021 07:21:46 -0800
| > | > | Lines: 43
| > | > | Organization: College Loan Corporation
| > | > | X-Priority: 3
| > | > | X-MSMail-Priority: Normal
| > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | > | X-RFC2646: Format=Flowed; Original
| > | > | Message-ID: <ODZhGMHNFHA.2384@xxxxxxxxxxxxxxxxxxxx>
| > | > | Newsgroups: microsoft.public.biztalk.general
| > | > | NNTP-Posting-Host: cpe-24-161-161-175.san.res.rr.com
24.161.161.175
| > | > | Path:
| > TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| > | > | Xref: TK2MSFTNGXA03.phx.gbl microsoft.public.biztalk.general:25872
| > | > | X-Tomcat-NG: microsoft.public.biztalk.general
| > | > |
| > | > | Hi,
| > | > |
| > | > | I defined a schema from BizTalk schema editor like following:
| > | > | <?xml version="1.0" encoding="utf-16" ?>
| > | > | - <xs:schema xmlns="http://schemas.pursca.com/Pet";
| > | > | xmlns:b="http://schemas.microsoft.com/BizTalk/2003";
| > | > | targetNamespace="http://schemas.pursca.com/Pet";
| > | > | xmlns:xs="http://www.w3.org/2001/XMLSchema";>
| > | > | - <xs:element name="Pet">
| > | > | - <xs:complexType>
| > | > | - <xs:sequence>
| > | > | <xs:element name="Name" type="xs:string" />
| > | > | <xs:element name="Type" type="xs:string" />
| > | > | </xs:sequence>
| > | > | </xs:complexType>
| > | > | </xs:element>
| > | > | </xs:schema>
| > | > |
| > | > | When I generate an instance I got the following (always has
| > namespace
| > | > prefix
| > | > | at top level):
| > | > | - <ns0:Pet xmlns:ns0="http://schemas.pursca.com/Pet";>
| > | > | <Name>Name_0</Name>
| > | > | <Type>Type_0</Type>
| > | > | </ns0:Pet>
| > | > |
| > | > | The schema surely could valiate the generated instance but it
could
| > NOT
| > | > | validate the following xml instance:
| > | > | <Pet><Name>Name_0</Name><Type>Type_0</Type></Pet>
| > | > |
| > | > | or
| > | > |
| > | > | <Pet
| > | > |
| > | >
| >
xmlns="http://schemas.pursca.com/Pet";><Name>Name_0</Name><Type>Type_0</Type>
| > | > </Pet>
| > | > |
| > | > | Does that mean if we want to use targetnamespace we always need to
| > | > supply
| > | > an
| > | > | xml instance with namespace prefix? if so, what is the best way
from
| > C#
| > | > to
| > | > | serialize a class to xml with namespace prefix?
| > | > |
| > | > | Thanks!
| > | > |
| > | > | John
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|

.



Relevant Pages