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
Solved

How do I link two xml schemas with include?

Posted on 2009-05-15
2
560 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

856 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