Solved

How do I link two xml schemas with include?

Posted on 2009-05-15
2
561 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

How our DevOps Teams Maximize Uptime

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

Question has a verified solution.

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

Suggested Solutions

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
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…

733 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