I have just started to work with a new set of schemas that has required me to use tricks I did not know about.

The first problem that I struck was that when I added the schema into a BizTalk project I got the following error on opening it.

This schema is an invalid XSD Schema and has the following error(s):
1. The ‘http://www.w3.org/XML/1998/namespace:lang’ attribute is not declared.
2. The ‘http://www.w3.org/XML/1998/namespace:lang’ attribute is not declared.
3. The ‘http://www.w3.org/XML/1998/namespace:lang’ attribute is not declared.

The schemas references a schema called xml.xsd that comes from the W3C. This has to be downloaded and added to the project . http://www.w3.org/2005/08/xml.xsd

Compiling the project I got the following error;

error BEC2012: Node "product-attribute-definitions" – Specify a valid .NET type name for this root node. The current .NET type name of this root node is invalid (it is a reserved BizTalk Keyword or is an invalid C# identifier).

OMG can’t people design proper schemas these days. The schema contain fields that have hyphens in them. BizTalk does not like this. I had to change the Rootnode Typename and remove the hyphen.( See https://social.msdn.microsoft.com/Forums/en-US/04a80789-6073-453b-b531-2188416e45af/biztalk-problem-with-schema-elements-which-have-hyphens?forum=biztalkgeneral)

image

Compiling the project for second time I got the following.

error BEC2017: Node "" – This schema file has a TypeName that collides with the RootNode TypeName of one of its root nodes. Make sure that they are different.

OMG can’t people design BizTalk friendly schemas these days. The schema types collide with some of the root names. I had to change all the schema types.  I changed the schema type for the catalog.xsd from catalog to dwcatalog. (See http://biztalk-dev.blogspot.co.nz/2008/12/resolving-schema-type-name-clashes.html)

image

Finally the project compiles. This changes will have no affect on the actual XML that is produced but it will allow us to compile the schemas into a .Net assembly.

All is good you might think but no cigar yet.

If you try to create a map to this schema you get this error.

error btm1046: Output validation error: Prefix ‘ns1’ cannot be mapped to namespace name reserved for "xml" or "xmlns". Line 1, position 124

Sure enough the map has injected xmlns:ns1="http://www.w3.org/XML/1998/namespace into the output message.
.
< ns0:catalog catalog-id="wsl-product-master" xmlns:ns0="http://www.demandware.com/xml/impex/catalog/2006-10-31" xmlns:ns1="http://www.w3.org/XML/1998/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

< /ns0:catalog>

What I don’t get is if I generate a message from schema it does not inject this namespace. I get as the root node.

Now why is the map doing this?

My colleague Johann Cooper pointed me at this forum post……But it is the answer that has got zero votes that is the real solution.

What you do is add xmlns:xml=http://www.w3.org/XML/1998/namespace” to the root node. The error now disappears.

Now we have a schema that works.  If you want to play with this unfriendly schema then start with this project and make all the edits along the way and feel my pain. The final solution is here.

NOTE ADDED 19/6/2015

The above only works if the schemas and maps are all in the same project. If you want to have maps in one project and schemas in another then you also have to edit the map file. Edit the .btm file in an editor (not BizTalk map editor) manually set the reference to local file path of the unfriendly schema, if it is not set correctly. By default if you have your maps in a different project the map will reference the schema project instead. Now you will be able to develop using Visual studio.

But…..this set up adds a complication because when you compile the project it will fail because the local file path for the schemas cannot be found. Once development of the map is complete replace the schema in the map with the a reference to the project, create the xsl file by validating the map,copy the xsl file created by validate map from the temp folder, paste into map project location and add the .xsl file as Custom XSLT file . The map will be compile successfully without any errors.

In summary the steps are;

Development

  1. Remove hyphens from the root node of the unfriendly schema
  2. Change schema type so it does not collide with the name of the root node.
  3. Add xmlns:xml=http://www.w3.org/XML/1998/namespace” to the root node of the schema.
  4. Edit the .btm file in an editor (not BizTalk map editor) manually set the reference to local file path of the unfriendly schema.

Runtime

  1. Replace the schema in the map with the a reference to the project.
  2. Create the xsl file by validating the map.
  3. Copy the xsl file created by validate map from the temp folder.
  4. Paste into map project location.
  5. Add the .xsl file as Custom XSLT file.
BizTalk360
BizTalk Server

Over 500+ customers across
30+ countries depend on BizTalk360

Learn More
Serverless360
Azure

Manage and monitor serverless
components effortlessly

Learn More
Atomicscope
Business Users

Monitor your Business Activity in iPaaS
or Hybrid integration solutions

Learn More

Back to Top