I have a XML schema like:
<?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" the TextHeader element from another file?
Like so:
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 it's possible at all, will the .NET XMLSerializer
be able to parse and understand the document containing such an "include..."?
Thank you for help in advance!