Schema - Target Namespace

In my biztalk application, there are 1 flat file and 1 xml as incoming files, and 1 xml as output.

The source xml file contains no namespace. Thus, I didn't add any target namespace to the schema. But I find that the xml disassembler will not be able to recognize the file.

If I add the target namespace in the schema, then the source file will not conform to the schema.

So, what should I do?

Please help.

[670 byte] By [YCH] at [2008-1-7]
# 1
Biztalk uses the namespace#rootnode combination for all xml docs passing through it.

Jody

JodyPetroni at 2007-10-2 > top of Msdn Tech,BizTalk Server,BizTalk R2 General...
# 2

So, if the source XML is fixed, what should I do in this case?

Keep the target namespace in the schema?

YCH at 2007-10-2 > top of Msdn Tech,BizTalk Server,BizTalk R2 General...
# 3
Hi,

You don't necessarily have to have a target namespace. However your Xml message should have a namespace. And, as said in the previous post, it's this namespace in combination with the root node that will identify the message type of the message.

Post your schema and your Xml message and further describe your problem and we'll be able to help you better.

Richard Hallgren
http://richardhallgren.com/blog

RichardHallgren at 2007-10-2 > top of Msdn Tech,BizTalk Server,BizTalk R2 General...
# 4

The XML document.

Code Snippet
<?xml version="1.0" encoding="UTF-8"?>
<Example xmlns="http://www.w3.org/XML/Schema">
<Item>
<Element1>A</Element1>
<Element2>B</Element2>
</Item>
</Example>

I can't remember the schema exactly because I'm not using my PC.

But the problem is that if I put a target namespace in the schema, the xml disassembler cannot recognize the above message.

If I alter the above message to the below one and keep the target namespace. It works fine.

Code Snippet

<?xml version="1.0" encoding="UTF-8"?>
<ns0:Example targetNamespace="http://example.org/example/" xmlns="http://www.w3.org/XML/Schema">
<Item>
<Element1>A</Element1>
<Element2>B</Element2>
</Item>
</ns0:Example>

However, the real situation is that the source xml document should be the first one.
YCH at 2007-10-2 > top of Msdn Tech,BizTalk Server,BizTalk R2 General...
# 5
YCH,

The first document snippet you show is certainly using the wrong namespace... It is using the XSD namespace! Why would you want to say that an XML message should be using the XSD namespace if it is not, indeed, XSD?

TomasRestrepo at 2007-10-2 > top of Msdn Tech,BizTalk Server,BizTalk R2 General...
# 6

Sorry.

In the 1st document,

It should be<Example xmlns:xsd="http://www.w3.org/XML/Schema">

YCH at 2007-10-2 > top of Msdn Tech,BizTalk Server,BizTalk R2 General...
# 7
Still you don't need (read shouldn't have Wink) the schema namespace in you message. I'd try something like the below.

Code Snippet

<?xml version="1.0" encoding="UTF-8"?>
<ns0:Example xmlns:ns0="http://example.org/example/">
<Item>
<Element1>A</Element1>
<Element2>B</Element2>
</Item>
</ns0:Example>


Basically you have to define the "ns0" namespace that you've declared that the Example node is in (by saying "ns0:Example").

However if you like something that more like your first message you can define the namespace as a default namespace as in the example below.

Code Snippet

<?xml version="1.0" encoding="UTF-8"?>
<Example xmlns="http://example.org/example">
<Item>
<Element1>A</Element1>
<Element2>B</Element2>
</Item>
</Example>


This however means that all you nodes are within that namespace and you'll have a little harder getting the right XPath expressions and so on. But they should be perfectly valid messages.

This could also be a good time to read some about qualified vs. unqaulifed messages and namespaces in general.

Richard Hallgren
http://richardhallgren.com/blog

RichardHallgren at 2007-10-2 > top of Msdn Tech,BizTalk Server,BizTalk R2 General...
# 8

Thanks. In my case, I will keep the document like the second one.

But now there is one more schema, a property schema, it seems that property schema must have a target namespace. And that prperty schema is relate to the xml document.

Will this problem more complex? Please suggest.
YCH at 2007-10-2 > top of Msdn Tech,BizTalk Server,BizTalk R2 General...
# 9
Property schemas are easy. Use Visual Studio to create the property schemas and promote properties - you shouldn't have any problems with that. If you do let us know!

Richard Hallgren
http://richardhallgren.com/blog

RichardHallgren at 2007-10-2 > top of Msdn Tech,BizTalk Server,BizTalk R2 General...
# 10
Thanks. I know how to promote property.

Actually, there is a target namespace in the property namespace, but the xml schema and xml document do not. Therefore, the xml disassembler does not work properly.

If my want to keep the target namespace of xml schema, but none for the property schema, is that workable?

Thanks!

YCH at 2007-10-2 > top of Msdn Tech,BizTalk Server,BizTalk R2 General...
# 11
The message doesn't have to have a target namespace but I don't see why you'd wanna remove the target namespace from the schema or the property schema? Theoretically it shouldn't be a problem as I think it would use the namespace of the schema if there isn't a target namespace - but I've never tried that. Guess you just have to give it a try. It also be interesting to hear why you'd wanna remove it from the property schema? What's the point in that?
RichardHallgren at 2007-10-2 > top of Msdn Tech,BizTalk Server,BizTalk R2 General...
# 12
If I am able to do so, I would let all the message / schema have a namespace. It will be easier to manage.

Also, is it possible to have a preprocessor in the pipeline for adding a namespace to the xml document "manually" before going to the xml disassember and orchestration.

YCH at 2007-10-2 > top of Msdn Tech,BizTalk Server,BizTalk R2 General...
# 13
Richard Seroter got a nice post on how tyo add a namespace in the pipeline. I'm not sure what you mean by "manually" but I hope this is what you're looking for.
RichardHallgren at 2007-10-2 > top of Msdn Tech,BizTalk Server,BizTalk R2 General...