How can I "include" one XML file in another XML file?

I have an XML schema, for example:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="MySchema"
    targetNamespace="http://tempuri.org/MySchema.xsd"
    elementFormDefault="qualified"
    xmlns="http://tempuri.org/MySchema.xsd"
    xmlns:mstns="http://tempuri.org/MySchema.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="MyDocument">
    <xs:complexType>
      <xs:all>
        <xs:element name="TextHeader" type="xs:string" minOccurs="0" />
        <xs:element name="TextBody" type="xs:string" minOccurs="0" />
      </xs:all>
    </xs:complexType>
  </xs:element>
</xs:schema>

A valid XML document according to this schema would be:

<?xml version="1.0" encoding="utf-8" ?>
<MyDocument xmlns="http://tempuri.org/MySchema.xsd">
  <TextHeader>My header which is almost always the same...</TextHeader>
  <TextBody>My text body which is always different...</TextBody>
</MyDocument>

Question 1: Is there a way to “include” a TextHeader element from another file?

Same:

File "Header.xml":

<?xml version="1.0" encoding="utf-8" ?>
<MyDocument xmlns="http://tempuri.org/MySchema.xsd">
  <TextHeader>My Header which is almost always the same...</TextHeader>
</MyDocument>

File "CompleteDocument.xml":

<?xml version="1.0" encoding="utf-8" ?>
<MyDocument xmlns="http://tempuri.org/MySchema.xsd">

  include "Header.xml" ???

  <TextBody>My text body which is always different...</TextBody>
</MyDocument>

Question 2. If at all possible, can .NET XMLSerializeranalyze and understand a document containing such an "include ..."?

Thank you for your help!

+5
source share
3 answers

. - (, app.config xslt include/import), XML . , .

, XmlReader, ( xmlns) , , .

+3

, XML-.

0

: "". xInclude, , (http://www.w3.org/TR/xinclude/)

0

All Articles