Solved

How do I link two xml schemas with include?

Posted on 2009-05-15
2
559 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
ID: 24395164
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
ID: 24395638
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reset asp.net login password 4 42
ASP.net Show "please wait " message as page loads 2 41
SQL Result Set to XML 4 36
Question about JQuery and asp.net 3 25
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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