Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I link two xml schemas with include?

Posted on 2009-05-15
2
Medium Priority
?
565 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 750 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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, …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

598 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