Solved

How do I link two xml schemas with include?

Posted on 2009-05-15
2
557 Views
Last Modified: 2012-06-22
I have an xml-file I'm using as template to create xsd-schemas in Visual Studio 2005.
However when I click generate schema - two files come out.
When I try to use those xsd files to generate my classes with xsd.exe schema definition tool I get an error when it cannon find one of the elements in the other file.

See example below.
The IDOC elements end up in a different xsd schema which transform just fine to classes with the xsd tool, but the <sap:ZCMR> schema will not compile. I've tried inserting the <xs:include to point out the schema containing the IDOC element, but this does not seem to work...
Source xml:
 

<?xml version="1.0" encoding="UTF-8"?>

<sap:ZCMR xmlns:sap="urn:sap-com:document:sap:idoc" tid="0A0D1E29193C4988A7F4132D">

     <IDOC BEGIN="1">

		<EDI_DC40 SEGMENT="1">

			<TABNAM>EDI_DC40</TABNAM>

			<MANDT>052</MANDT>		

     </IDOC>

</sap:ZCMR>
 

XSD output from generate schema in VS:
 

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns:sap="urn:sap-com:document:sap:idoc" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:idoc" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:include schemaLocation="IDOC.xsd" />

  <xs:element name="ZCMR">

    <xs:complexType>

      <xs:sequence>

        <xs:element name="IDOC" type="sap:IDOC" />

      </xs:sequence>

      <xs:attribute name="tid" type="xs:string" use="required" />

    </xs:complexType>

  </xs:element>

</xs:schema>

Open in new window

0
Comment
Question by:jenmat
2 Comments
 
LVL 5

Accepted Solution

by:
prashantagarw10 earned 250 total points
Comment Utility
typing xsd/? on Visual studio command prompt displays help for XSD generator exe and its parameters.
In that help the last line says that "Multiple file arguments of the same type may be provided."
I beleive this is what you are looking for.
Cheers!!
0
 

Author Comment

by:jenmat
Comment Utility
Thanks! It worked and the classes were created!
However, when I serialize the new class to a file, the namespaces aren't intact.

Original xml was

<sap:ZCMR xmlns:sap="urn:sap-com:document:sap:idoc" tid="0A0D1E29193C4988A7F4132D">

New output is
<ZCMR xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

Can anyone explain how the namespaces are set?
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now