Hidden
Hidden

Reputation: 3628

IXMLNode set prefix and namespace

this is an xml file i had received and i want to generate the same output with delphi. I used the delphi xml wizard to generate a big unit by my schema.

So this is the output i want to have (original file)

<?xml version="1.0" encoding="iso-8859-1"?><reh:Reha xmlns:reh="http://www.vdek.com/xml-schema/REH/1.8">
  <reh:logische_Version>1.6.0</reh:logische_Version> 
 <reh:KV>
 <reh:Kopfdaten>
  <kod:Erstellungsdatum_Uhrzeit xmlns:kod="http://www.vdek.com/xml-schema/KOD/1.2">2014-09-23T15:33:23</kod:Erstellungsdatum_Uhrzeit> 
  <kod:Version xmlns:kod="http://www.vdek.com/xml-schema/KOD/1.2">1.2.0</kod:Version> 
  <kod:Dateinummer xmlns:kod="http://www.vdek.com/xml-schema/KOD/1.2">000010</kod:Dateinummer> 
 <kod:Identifikationsdaten xmlns:kod="http://www.vdek.com/xml-schema/KOD/1.2">
  <kod:IK_Absender>108018007</kod:IK_Absender> 
  <kod:IK_Empfaenger>510800000</kod:IK_Empfaenger> 
  <kod:IK-Kostentraeger>108018007</kod:IK-Kostentraeger> 
  <kod:IK_Einrichtung>510800000</kod:IK_Einrichtung> 
  </kod:Identifikationsdaten>
 <kod:Fall_ID_KV xmlns:kod="http://www.vdek.com/xml-schema/KOD/1.2">
  <kod:Krankenversichertennummer>I123456789</kod:Krankenversichertennummer> 
  <kod:Versichertenstatus>50001</kod:Versichertenstatus> 
  <kod:Kartengueltigkeit>1712</kod:Kartengueltigkeit> 
  <kod:Fallnummer>01800000099988877</kod:Fallnummer> 
  </kod:Fall_ID_KV>
    <reh:Dateinummer></reh:Dateinummer>
    </reh:Kopfdaten>
 <reh:Bewilligung>
 <bew:Admindaten xmlns:bew="http://www.vdek.com/xml-schema/BEW/1.5">
  <bew:Verarbeitungskennzeichen>10</bew:Verarbeitungskennzeichen> 
  <bew:Version>1.5.0</bew:Version> 
  <bew:LfdNr>01</bew:LfdNr> 
  </bew:Admindaten>
 <bew:Fachliche_Daten xmlns:bew="http://www.vdek.com/xml-schema/BEW/1.5">
 <bew:Rehabilitand>
  <bew:Anrede>1</bew:Anrede> 
 <bew:Name>
  <bty:Nachname xmlns:bty="http://www.vdek.com/xml-schema/BTY/1.2">Mustermann</bty:Nachname> 
  <bty:Vorname xmlns:bty="http://www.vdek.com/xml-schema/BTY/1.2">Max</bty:Vorname> 
  </bew:Name>
  <bew:Geschlecht>1</bew:Geschlecht> 
  <bew:Geburtsdatum>1950-08-21</bew:Geburtsdatum> 
 <bew:Adresse>
  <bty:Strasse xmlns:bty="http://www.vdek.com/xml-schema/BTY/1.2">Saonestr.</bty:Strasse> 
  <bty:Hausnummer xmlns:bty="http://www.vdek.com/xml-schema/BTY/1.2">3</bty:Hausnummer> 
  <bty:Wohnort xmlns:bty="http://www.vdek.com/xml-schema/BTY/1.2">Frankfurt</bty:Wohnort> 
  <bty:PLZ xmlns:bty="http://www.vdek.com/xml-schema/BTY/1.2">60528</bty:PLZ> 
  <bty:Laenderkennzeichen xmlns:bty="http://www.vdek.com/xml-schema/BTY/1.2">D</bty:Laenderkennzeichen> 
  </bew:Adresse>
 <bew:Kommunikation>
  <bty:Telefon xmlns:bty="http://www.vdek.com/xml-schema/BTY/1.2">069/12345</bty:Telefon> 
  </bew:Kommunikation>
  </bew:Rehabilitand>
 <bew:Kosteninformationen>
 <bew:Zuzahlung>
  <bew:Zuzahlungseinzug>2</bew:Zuzahlungseinzug> 
  <bew:AnzahlTage>028</bew:AnzahlTage> 
  <bew:Zuzahlungsbetrag>01000</bew:Zuzahlungsbetrag> 
  </bew:Zuzahlung>
  </bew:Kosteninformationen>
 <bew:Rehainformationen>
  <bew:Rehaart>93</bew:Rehaart> 
  </bew:Rehainformationen>
 <bew:Aufnahmedaten>
  <bew:IK_Krankenhaus>260612124</bew:IK_Krankenhaus> 
  <bew:Behandlungsart>1</bew:Behandlungsart> 
 <bew:Bewilligungsdiagnosen>
  <bew:Version_ICD>2014</bew:Version_ICD> 
 <bew:Diagnose>
  <bty:Diagnosenschluessel xmlns:bty="http://www.vdek.com/xml-schema/BTY/1.2">M151</bty:Diagnosenschluessel> 
  </bew:Diagnose>
  </bew:Bewilligungsdiagnosen>
 <bew:Aufnahmedaten>
  <bew:Erfolgt>N</bew:Erfolgt> 
  <bew:Geplant>2014-10-05</bew:Geplant> 
  </bew:Aufnahmedaten>
  <bew:Indikationsgruppe>SA</bew:Indikationsgruppe> 
  </bew:Aufnahmedaten>
 <bew:Bewilligungsinformationen>
  <bew:Bewilligungsdatum>2014-09-23</bew:Bewilligungsdatum> 
  <bew:Kostenzusage_gueltig_bis>2014-10-31</bew:Kostenzusage_gueltig_bis> 
  </bew:Bewilligungsinformationen>
 <bew:Stationaerdaten>
  <bew:Behandlungsabschnitte>01</bew:Behandlungsabschnitte> 
  <bew:bewilligte_Tage>020</bew:bewilligte_Tage> 
  </bew:Stationaerdaten>
  </bew:Fachliche_Daten>
    <reh:Fachliche_Daten>
        <reh:Rehabilitand/>
      </reh:Fachliche_Daten>
    </reh:Bewilligung>
  </reh:KV>
  <reh:Papieranlage>N</reh:Papieranlage> 
  </reh:Reha>

My delphi code

var
 XML: IXMLReha;
begin
  XML := NewReha;
  XML.OwnerDocument.Options := [doNodeAutoCreate, doNodeAutoIndent];
  XML.Logische_Version := '1.6.0';

  //Präfixe wie :bs, :reh fehlen noch

  {Kopfdaten}       //xmlns:kod
  Xml.KV.Kopfdaten.DeclareNamespace('kod', 'http://www.vdek.com/xml-schema/KOD/1.2');
  Xml.KV.Kopfdaten.Attributes['test'] := 'test2';

  XML.KV.Kopfdaten.Erstellungsdatum_Uhrzeit             := '2014-09-23T15:33:23';
  XML.KV.Kopfdaten.Version                              := '1.2.0';
  XML.KV.Kopfdaten.Dateinummer                          := '000010';

  XML.KV.Kopfdaten.Identifikationsdaten.IK_Absender     := '108018007';
  XML.KV.Kopfdaten.Identifikationsdaten.IK_Empfaenger   := '510800000';
  XML.KV.Kopfdaten.Identifikationsdaten.IKKostentraeger := '108018007';
  XML.KV.Kopfdaten.Identifikationsdaten.IK_Einrichtung  := '510800000';

  XML.KV.Kopfdaten.Fall_ID_KV.Krankenversichertennummer := 'I123456789';
  XML.KV.Kopfdaten.Fall_ID_KV.Versichertenstatus        := '50001';
  XML.KV.Kopfdaten.Fall_ID_KV.Kartengueltigkeit         := '1712';
  XML.KV.Kopfdaten.Fall_ID_KV.Fallnummer                := '01800000099988877';
  XML.KV.Kopfdaten.Dateinummer                          := '';


  {Bewilligung}
  XML.KV.Bewilligung.Admindaten.Verarbeitungskennzeichen := '10';
  XML.KV.Bewilligung.Admindaten.Version                  := '1.5.0';
  XML.KV.Bewilligung.Admindaten.LfdNr                    := '01';

  XML.KV.Bewilligung.Fachliche_Daten.Rehabilitand.Anrede         := '1';
  XML.KV.Bewilligung.Fachliche_Daten.Rehabilitand.Name.Nachname  := 'Mustermann';
  XML.KV.Bewilligung.Fachliche_Daten.Rehabilitand.Name.Vorname   := 'Max';

  XML.KV.Bewilligung.Fachliche_Daten.Rehabilitand.Geschlecht := '1';
  XML.KV.Bewilligung.Fachliche_Daten.Rehabilitand.Geburtsdatum := '1950-08-21';

  XML.KV.Bewilligung.Fachliche_Daten.Rehabilitand.Adresse.Strasse := 'Saonestr';
  XML.KV.Bewilligung.Fachliche_Daten.Rehabilitand.Adresse.Hausnummer := '3';
  XML.KV.Bewilligung.Fachliche_Daten.Rehabilitand.Adresse.Wohnort := 'Frankfurt';
  XML.KV.Bewilligung.Fachliche_Daten.Rehabilitand.Adresse.PLZ := '60528';
  XML.KV.Bewilligung.Fachliche_Daten.Rehabilitand.Adresse.Laenderkennzeichen := 'D';

  XML.KV.Bewilligung.Fachliche_Daten.Rehabilitand.Kommunikation.Telefon := '069/12345';

  { ...}

  //Dokument speichern
  XML.OwnerDocument.SaveToFile('\\Server\Gen.xml');
end;

My output generated with my delphi code

<?xml version="1.0"?>
<Reha xmlns="http://www.vdek.com/xml-schema/REH/1.8" xsi:schemaLocation="http://www.foo.com/Myxsd.xsd">
  <logische_Version>1.6.0</logische_Version>
  <KV>
    <Kopfdaten xmlns:kod="http://www.vdek.com/xml-schema/KOD/1.2" test="test2">
      <Erstellungsdatum_Uhrzeit>2014-09-23T15:33:23</Erstellungsdatum_Uhrzeit>
      <Version>1.2.0</Version>
      <Dateinummer></Dateinummer>
      <Identifikationsdaten>
        <IK_Absender>108018007</IK_Absender>
        <IK_Empfaenger>510800000</IK_Empfaenger>
        <IK-Kostentraeger>108018007</IK-Kostentraeger>
        <IK_Einrichtung>510800000</IK_Einrichtung>
      </Identifikationsdaten>
      <Fall_ID_KV>
        <Krankenversichertennummer>I123456789</Krankenversichertennummer>
        <Versichertenstatus>50001</Versichertenstatus>
        <Kartengueltigkeit>1712</Kartengueltigkeit>
        <Fallnummer>01800000099988877</Fallnummer>
      </Fall_ID_KV>
    </Kopfdaten>
    <Bewilligung>
      <Admindaten>
        <Verarbeitungskennzeichen>10</Verarbeitungskennzeichen>
        <Version>1.5.0</Version>
        <LfdNr>01</LfdNr>
      </Admindaten>
      <Fachliche_Daten>
        <Rehabilitand>
          <Anrede>1</Anrede>
          <Name>
            <Nachname>Mustermann</Nachname>
            <Vorname>Max</Vorname>
          </Name>
          <Geschlecht>1</Geschlecht>
          <Geburtsdatum>1950-08-21</Geburtsdatum>
          <Adresse>
            <Strasse>Saonestr</Strasse>
            <Hausnummer>3</Hausnummer>
            <Wohnort>Frankfurt</Wohnort>
            <PLZ>60528</PLZ>
            <Laenderkennzeichen>D</Laenderkennzeichen>
          </Adresse>
          <Kommunikation>
            <Telefon>069/12345</Telefon>
          </Kommunikation>
        </Rehabilitand>
      </Fachliche_Daten>
    </Bewilligung>
  </KV>
</Reha>

So how can i set the prefixes/namespaces like reh:, :kod ... in ym xml file like in original xml file ?

As you see i dont use the ".addchild" command so i need a different answer.

Upvotes: 7

Views: 5457

Answers (4)

Raphi1
Raphi1

Reputation: 573

After you did the import via the data binding wizard, you can post-process the generated file. You have to add the third parameter to RegisterChildNode methods and the fourth parameter to the RegisterChildNodes to add the full namespace. After that you have to alter the Getter-methods:

For example you would alter the TXMLKopfdatenType_reh.AfterConstruction from

RegisterChildNode('Erstellungsdatum_Uhrzeit', TErstellungsdatum_UhrzeitTyp_kod)

to

RegisterChildNode('Erstellungsdatum_Uhrzeit', TErstellungsdatum_UhrzeitTyp_kod, 'http://www.vdek.com/xml-schema/KOD/1.2');

and the Getter-Method TXMLKopfdatenType_reh.Get_Erstellungsdatum_Uhrzeit from

Result := ChildNodes['Erstellungsdatum_Uhrzeit'] as IErstellungsdatum_UhrzeitTyp_kod;

to

Result := ChildNodes['kod:Erstellungsdatum_Uhrzeit'] as IErstellungsdatum_UhrzeitTyp_kod;

With this approach you can use the benefits of the XML wizard and correct its mistakes

UPDATE 2024-07-21

To work with the namespaces correctly, you need to also declare the namespaces manually and enhance the generated Getter even more. In your case you need to add the following lines in the three functions, which are creating your root object (GetXXX, LoadXXX and NewXXX) after the Result have been initialized:

Result.DeclareNamespace('reh', 'http://www.vdek.com/xml-schema/REH/1.8');
Result.DeclareNamespace('kod', 'http://www.vdek.com/xml-schema/KOD/1.2');
Result.DeclareNamespace('bew', 'http://www.vdek.com/xml-schema/BEW/1.5');
Result.DeclareNamespace('bty', 'http://www.vdek.com/xml-schema/BTY/1.2');

As the (for example) ChildNodes['kod:Erstellungsdatum_Uhrzeit'] also is not working properly with the namespaces, you need to use the function FindNode. You can enhance the Getter like

Result := ChildNodes.FindNode('Erstellungsdatum_Uhrzeit', 'http://www.vdek.com/xml-schema/KOD/1.2') as IErstellungsdatum_UhrzeitTyp_kod;
if not Assigned(Result) then
  Result := ChildNodes['kod:Erstellungsdatum_Uhrzeit'] as IErstellungsdatum_UhrzeitTyp_kod;

This will check if the Node exists in the specified namespace. If it doesn't exists, we will fall back to the old logic, which will create the node by default.

Upvotes: 1

kot-da-vinci
kot-da-vinci

Reputation: 1204

Just a fast solution, you can make it more pretty

using msxml;

procedure TForm1.bt1Click(Sender: TObject);
var
  Document: DOMDocument;
  RootNode, Node: IXMLDOMNode;
const
  rehNameSpace: WideString = 'reh';
  rehNameSpaceURI: WideString = 'http://www.vdek.com/xml-schema/REH/1.8';
  kodNameSpace: WideString = 'kod';
  kodNameSpaceURI: WideString = 'http://www.vdek.com/xml-schema/KOD/1.2';
begin
  Document := CoDOMDocument60.Create;

  RootNode := Document.createNode(NODE_ELEMENT, rehNameSpace + ':Reha', rehNameSpaceURI);
  Document.appendChild(RootNode);

  Node := Document.createNode(NODE_ELEMENT, rehNameSpace + ':logische_Version', rehNameSpaceURI);
  Node.text := '1.6.0';
  RootNode.appendChild(Node);

  Node := Document.createNode(NODE_ELEMENT, rehNameSpace + ':KV', rehNameSpaceURI);
  RootNode.appendChild(Node);

  RootNode := Node;

  Node := Document.createNode(NODE_ELEMENT, rehNameSpace + ':Kopfdaten', rehNameSpaceURI);
  RootNode.appendChild(Node);
  RootNode := Node;

  Node := Document.createNode(NODE_ELEMENT, kodNameSpace + ':Erstellungsdatum_Uhrzeit', kodNameSpaceURI);
  Node.text := '2014-09-23T15:33:23';
  RootNode.appendChild(Node);

  Node := Document.createNode(NODE_ELEMENT, kodNameSpace + ':Version', kodNameSpaceURI);
  Node.text := '1.2.0';
  RootNode.appendChild(Node);

  Node := Document.createNode(NODE_ELEMENT, kodNameSpace + ':Dateinummer', kodNameSpaceURI);
  Node.text := '000010';
  RootNode.appendChild(Node);

  Node := Document.createNode(NODE_ELEMENT, kodNameSpace + ':Identifikationsdaten', kodNameSpaceURI);
  RootNode.appendChild(Node);

  RootNode := Node;

  mmo1.Text := Document.xml;     // TMemo
end;

Upvotes: 2

whosrdaddy
whosrdaddy

Reputation: 11860

If you have a complex XSD schema, consisting of multiple files the XML databinding wizard fails to create the correct code (like you have noticed). In that case, it is easier to feed the wanted output to an online XML to XSD converter and use that as the input for the databinding wizard. I crafted a new XSD file (generated from the XML file you posted here), using the excellent XMLgrid converter

<?xml version="1.0" encoding="UTF-8"?>
   <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
         <!-- XML Schema Generated from XML Document on Thu Apr 09 2015 14:31:00 GMT+0200 (Romance Daylight Time) -->
         <!-- with XmlGrid.net Free Online Service http://xmlgrid.net -->
         <xs:element name="reh:Reha">
               <xs:complexType>
                     <xs:sequence>
                           <xs:element name="reh:logische_Version" type="xs:string"></xs:element>
                           <xs:element name="reh:KV">
                                 <xs:complexType>
                                       <xs:sequence>
                                             <xs:element name="reh:Kopfdaten">
                                                   <xs:complexType>
                                                         <xs:sequence>
                                                               <xs:element name="kod:Erstellungsdatum_Uhrzeit" type="xs:dateTime">
                                                                     <xs:complexType>
                                                                           <xs:attribute name="xmlns:kod" type="xs:string"></xs:attribute>
                                                                     </xs:complexType>
                                                               </xs:element>
                                                               <xs:element name="kod:Version" type="xs:string">
                                                                     <xs:complexType>
                                                                           <xs:attribute name="xmlns:kod" type="xs:string"></xs:attribute>
                                                                     </xs:complexType>
                                                               </xs:element>
                                                               <xs:element name="kod:Dateinummer" type="xs:string">
                                                                     <xs:complexType>
                                                                           <xs:attribute name="xmlns:kod" type="xs:string"></xs:attribute>
                                                                     </xs:complexType>
                                                               </xs:element>
                                                               <xs:element name="kod:Identifikationsdaten">
                                                                     <xs:complexType>
                                                                           <xs:sequence>
                                                                                 <xs:element name="kod:IK_Absender" type="xs:string"></xs:element>
                                                                                 <xs:element name="kod:IK_Empfaenger" type="xs:string"></xs:element>
                                                                                 <xs:element name="kod:IK-Kostentraeger" type="xs:string"></xs:element>
                                                                                 <xs:element name="kod:IK_Einrichtung" type="xs:string"></xs:element>
                                                                           </xs:sequence>
                                                                           <xs:attribute name="xmlns:kod" type="xs:string"></xs:attribute>
                                                                     </xs:complexType>
                                                               </xs:element>
                                                               <xs:element name="kod:Fall_ID_KV">
                                                                     <xs:complexType>
                                                                           <xs:sequence>
                                                                                 <xs:element name="kod:Krankenversichertennummer" type="xs:string"></xs:element>
                                                                                 <xs:element name="kod:Versichertenstatus" type="xs:string"></xs:element>
                                                                                 <xs:element name="kod:Kartengueltigkeit" type="xs:string"></xs:element>
                                                                                 <xs:element name="kod:Fallnummer" type="xs:string"></xs:element>
                                                                           </xs:sequence>
                                                                           <xs:attribute name="xmlns:kod" type="xs:string"></xs:attribute>
                                                                     </xs:complexType>
                                                               </xs:element>                                                               
                                                         </xs:sequence>
                                                   </xs:complexType>
                                             </xs:element>
                                             <xs:element name="reh:Bewilligung">
                                                   <xs:complexType>
                                                         <xs:sequence>
                                                               <xs:element name="bew:Admindaten">
                                                                     <xs:complexType>
                                                                           <xs:sequence>
                                                                                 <xs:element name="bew:Verarbeitungskennzeichen" type="xs:string"></xs:element>
                                                                                 <xs:element name="bew:Version" type="xs:string"></xs:element>
                                                                                 <xs:element name="bew:LfdNr" type="xs:string"></xs:element>
                                                                           </xs:sequence>
                                                                           <xs:attribute name="xmlns:bew" type="xs:string"></xs:attribute>
                                                                     </xs:complexType>
                                                               </xs:element>
                                                               <xs:element name="bew:Fachliche_Daten">
                                                                     <xs:complexType>
                                                                           <xs:sequence>
                                                                                 <xs:element name="bew:Rehabilitand">
                                                                                       <xs:complexType>
                                                                                             <xs:sequence>
                                                                                                   <xs:element name="bew:Anrede" type="xs:string"></xs:element>
                                                                                                   <xs:element name="bew:Name">
                                                                                                         <xs:complexType>
                                                                                                               <xs:sequence>
                                                                                                                     <xs:element name="bty:Nachname" type="xs:string">
                                                                                                                           <xs:complexType>
                                                                                                                                 <xs:attribute name="xmlns:bty" type="xs:string"></xs:attribute>
                                                                                                                           </xs:complexType>
                                                                                                                     </xs:element>
                                                                                                                     <xs:element name="bty:Vorname" type="xs:string">
                                                                                                                           <xs:complexType>
                                                                                                                                 <xs:attribute name="xmlns:bty" type="xs:string"></xs:attribute>
                                                                                                                           </xs:complexType>
                                                                                                                     </xs:element>
                                                                                                               </xs:sequence>
                                                                                                         </xs:complexType>
                                                                                                   </xs:element>
                                                                                                   <xs:element name="bew:Geschlecht" type="xs:string"></xs:element>
                                                                                                   <xs:element name="bew:Geburtsdatum" type="xs:date"></xs:element>
                                                                                                   <xs:element name="bew:Adresse">
                                                                                                         <xs:complexType>
                                                                                                               <xs:sequence>
                                                                                                                     <xs:element name="bty:Strasse" type="xs:string">
                                                                                                                           <xs:complexType>
                                                                                                                                 <xs:attribute name="xmlns:bty" type="xs:string"></xs:attribute>
                                                                                                                           </xs:complexType>
                                                                                                                     </xs:element>
                                                                                                                     <xs:element name="bty:Hausnummer" type="xs:string">
                                                                                                                           <xs:complexType>
                                                                                                                                 <xs:attribute name="xmlns:bty" type="xs:string"></xs:attribute>
                                                                                                                           </xs:complexType>
                                                                                                                     </xs:element>
                                                                                                                     <xs:element name="bty:Wohnort" type="xs:string">
                                                                                                                           <xs:complexType>
                                                                                                                                 <xs:attribute name="xmlns:bty" type="xs:string"></xs:attribute>
                                                                                                                           </xs:complexType>
                                                                                                                     </xs:element>
                                                                                                                     <xs:element name="bty:PLZ" type="xs:string">
                                                                                                                           <xs:complexType>
                                                                                                                                 <xs:attribute name="xmlns:bty" type="xs:string"></xs:attribute>
                                                                                                                           </xs:complexType>
                                                                                                                     </xs:element>
                                                                                                                     <xs:element name="bty:Laenderkennzeichen" type="xs:string">
                                                                                                                           <xs:complexType>
                                                                                                                                 <xs:attribute name="xmlns:bty" type="xs:string"></xs:attribute>
                                                                                                                           </xs:complexType>
                                                                                                                     </xs:element>
                                                                                                               </xs:sequence>
                                                                                                         </xs:complexType>
                                                                                                   </xs:element>
                                                                                                   <xs:element name="bew:Kommunikation">
                                                                                                         <xs:complexType>
                                                                                                               <xs:sequence>
                                                                                                                     <xs:element name="bty:Telefon" type="xs:string">
                                                                                                                           <xs:complexType>
                                                                                                                                 <xs:attribute name="xmlns:bty" type="xs:string"></xs:attribute>
                                                                                                                           </xs:complexType>
                                                                                                                     </xs:element>
                                                                                                               </xs:sequence>
                                                                                                         </xs:complexType>
                                                                                                   </xs:element>
                                                                                             </xs:sequence>
                                                                                       </xs:complexType>
                                                                                 </xs:element>
                                                                                 <xs:element name="bew:Kosteninformationen">
                                                                                       <xs:complexType>
                                                                                             <xs:sequence>
                                                                                                   <xs:element name="bew:Zuzahlung">
                                                                                                         <xs:complexType>
                                                                                                               <xs:sequence>
                                                                                                                     <xs:element name="bew:Zuzahlungseinzug" type="xs:string"></xs:element>
                                                                                                                     <xs:element name="bew:AnzahlTage" type="xs:string"></xs:element>
                                                                                                                     <xs:element name="bew:Zuzahlungsbetrag" type="xs:string"></xs:element>
                                                                                                               </xs:sequence>
                                                                                                         </xs:complexType>
                                                                                                   </xs:element>
                                                                                             </xs:sequence>
                                                                                       </xs:complexType>
                                                                                 </xs:element>
                                                                                 <xs:element name="bew:Rehainformationen">
                                                                                       <xs:complexType>
                                                                                             <xs:sequence>
                                                                                                   <xs:element name="bew:Rehaart" type="xs:string"></xs:element>
                                                                                             </xs:sequence>
                                                                                       </xs:complexType>
                                                                                 </xs:element>
                                                                                 <xs:element name="bew:Aufnahmedaten">
                                                                                       <xs:complexType>
                                                                                             <xs:sequence>
                                                                                                   <xs:element name="bew:IK_Krankenhaus" type="xs:string"></xs:element>
                                                                                                   <xs:element name="bew:Behandlungsart" type="xs:string"></xs:element>
                                                                                                   <xs:element name="bew:Bewilligungsdiagnosen">
                                                                                                         <xs:complexType>
                                                                                                               <xs:sequence>
                                                                                                                     <xs:element name="bew:Version_ICD" type="xs:string"></xs:element>
                                                                                                                     <xs:element name="bew:Diagnose">
                                                                                                                           <xs:complexType>
                                                                                                                                 <xs:sequence>
                                                                                                                                       <xs:element name="bty:Diagnosenschluessel" type="xs:string">
                                                                                                                                             <xs:complexType>
                                                                                                                                                   <xs:attribute name="xmlns:bty" type="xs:string"></xs:attribute>
                                                                                                                                             </xs:complexType>
                                                                                                                                       </xs:element>
                                                                                                                                 </xs:sequence>
                                                                                                                           </xs:complexType>
                                                                                                                     </xs:element>
                                                                                                               </xs:sequence>
                                                                                                         </xs:complexType>
                                                                                                   </xs:element>
                                                                                                   <xs:element name="bew:Aufnahmedaten">
                                                                                                         <xs:complexType>
                                                                                                               <xs:sequence>
                                                                                                                     <xs:element name="bew:Erfolgt" type="xs:string"></xs:element>
                                                                                                                     <xs:element name="bew:Geplant" type="xs:date"></xs:element>
                                                                                                               </xs:sequence>
                                                                                                         </xs:complexType>
                                                                                                   </xs:element>
                                                                                                   <xs:element name="bew:Indikationsgruppe" type="xs:string"></xs:element>
                                                                                             </xs:sequence>
                                                                                       </xs:complexType>
                                                                                 </xs:element>
                                                                                 <xs:element name="bew:Bewilligungsinformationen">
                                                                                       <xs:complexType>
                                                                                             <xs:sequence>
                                                                                                   <xs:element name="bew:Bewilligungsdatum" type="xs:date"></xs:element>
                                                                                                   <xs:element name="bew:Kostenzusage_gueltig_bis" type="xs:date"></xs:element>
                                                                                             </xs:sequence>
                                                                                       </xs:complexType>
                                                                                 </xs:element>
                                                                                 <xs:element name="bew:Stationaerdaten">
                                                                                       <xs:complexType>
                                                                                             <xs:sequence>
                                                                                                   <xs:element name="bew:Behandlungsabschnitte" type="xs:string"></xs:element>
                                                                                                   <xs:element name="bew:bewilligte_Tage" type="xs:string"></xs:element>
                                                                                             </xs:sequence>
                                                                                       </xs:complexType>
                                                                                 </xs:element>
                                                                           </xs:sequence>
                                                                           <xs:attribute name="xmlns:bew" type="xs:string"></xs:attribute>
                                                                     </xs:complexType>
                                                               </xs:element>
                                                         </xs:sequence>
                                                   </xs:complexType>
                                             </xs:element>
                                       </xs:sequence>
                                 </xs:complexType>
                           </xs:element>
                           <xs:element name="reh:Papieranlage" type="xs:string"></xs:element>
                     </xs:sequence>
                     <xs:attribute name="xmlns:reh" type="xs:string"></xs:attribute>
               </xs:complexType>
         </xs:element>
   </xs:schema>

If you import this XSD file into the XML binding wizard, it will generate a unit that can produce the correct XML for you.

Upvotes: 3

Jon Lennart Aasenden
Jon Lennart Aasenden

Reputation: 4020

This is an ancient Delphi bug and a problem everyone who wants to use Delphi for high-end programming in a modern environment face. The XML binding wizard tends to crash if it encounters things like @include, so if you have nested namespaces (or external dependencies, like most schemas have these days) you are out of luck. Adding a namespace however is not possible. Under normal circumstances its not needed as the XML parser will resolve the names, but if you have the same identifier used by two files - then it will collide and render the XML useless. You should file a demand to EMB and get them to fix this, like I have done on 2 occations -- perhaps they will wake up and do something this time.

Upvotes: 2

Related Questions