Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with XML 2

Status
Not open for further replies.

xxxFALKORxxx

Programmer
Apr 26, 2010
4
MX
Hi;

im trying to create an app to create a complex XML file; the goverment supplies an XSD for it.

I've been trying to use it to create a class (following some internet examples) with Delphi's XML DataBinding wizard.

At first; it creates a lot of duplicated identifiers, i'd modified the original XSD to give them different names to them, that solves that problem...

but now; when i try to compile the result class i got errors of undeclared identifiers...

i've uploaded a zip file with the XSD an the class.

Hope someone can point me in the right direcction to solve this.

Thanks in advance...
 
I use for working with XML.

The XML data binding wizard is great as long as it builds the object correctly. If it doesn't it can be challenging to make it right. I lost a day on a project because it didn't like having nodes with the same name.
 
Thanks for you answer DjangMan...

but i think im so close with the wizard.... taking a look to the class generated, do you think is not possible to fix it?
 
You might be a better programmer than I and you also might have a better XSD file to work with. I found it hard to fix up the object that was generated but you might not. :) Give it a try. I would have loved to have used the data wizard to import my XML file.
 
Falkor, what version of delphi do you have.
I generated the class in D2010 and it compiles without a problem.

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Delphi 7...


do you think i can use the class you generate with D2010?

could you post it?
 
Here is the class compiled in D2006:

MD5: 14C06A59881D464DE2A05EBE14E2309D

the class didn't compile without errors, I needed to change the line

Code:
  TXMLTDepositoEfectivo = class(TXMLNode, IXMLTDepositoEfectivo)
to
Code:
  TXMLTDepositoEfectivo = class(TXMLNodeCollection, IXMLTDepositoEfectivo)

Cheers,
Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Thanks whosrdaddy !


it worked great!... i assume XML Databinding wizard was one of the updates since Delphi 7's days.

 
whosrdaddy,

If I attach an XML file could you process it with your version of the XML Data Binding Wizard? I think I'm having the same problem as xxxFALKORxxx.

Thanks.

Kevin
 
sure no problem!

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Here you go. This was given to me by a company we will be exchanging data/images with so I don't have control over its format:

<?xml version="1.0" encoding="UTF-8" ?>
- <NSR>
- <BATCH ID="TestWF00002">
<SETCOUNT>5</SETCOUNT>
<PROCESSDATE>11/16/2007</PROCESSDATE>
- <SET ID="TestWF000021">
<SETSEQUENCE>1</SETSEQUENCE>
<IMAGECOUNT>5</IMAGECOUNT>
- <SET_ATTRIB>
<SET_ATTRIB_FIELD>DCN</SET_ATTRIB_FIELD>
<SET_ATTRIB_VALUE>TestGDS</SET_ATTRIB_VALUE>
</SET_ATTRIB>
- <SET_ATTRIB>
<SET_ATTRIB_FIELD>APPID</SET_ATTRIB_FIELD>
<SET_ATTRIB_VALUE>GDS</SET_ATTRIB_VALUE>
</SET_ATTRIB>
- <SET_ATTRIB>
<SET_ATTRIB_FIELD>PAGECOUNT</SET_ATTRIB_FIELD>
<SET_ATTRIB_VALUE>5</SET_ATTRIB_VALUE>
</SET_ATTRIB>
- <IMAGE ID="dummy12.tif">
<IMAGENUMBER>1</IMAGENUMBER>
<PAGETYPE>IMAGE</PAGETYPE>
<IMAGESIZE>11663</IMAGESIZE>
<PAPER>N</PAPER>
</IMAGE>
- <IMAGE ID="dummy13.tif">
<IMAGENUMBER>2</IMAGENUMBER>
<PAGETYPE>IMAGE</PAGETYPE>
<IMAGESIZE>11663</IMAGESIZE>
<PAPER>N</PAPER>
</IMAGE>
- <IMAGE ID="dummy14.tif">
<IMAGENUMBER>3</IMAGENUMBER>
<PAGETYPE>IMAGE</PAGETYPE>
<IMAGESIZE>11663</IMAGESIZE>
<PAPER>N</PAPER>
</IMAGE>
- <IMAGE ID="dummy15.tif">
<IMAGENUMBER>4</IMAGENUMBER>
<PAGETYPE>IMAGE</PAGETYPE>
<IMAGESIZE>11663</IMAGESIZE>
<PAPER>N</PAPER>
</IMAGE>
- <IMAGE ID="dummy16.tif">
<IMAGENUMBER>5</IMAGENUMBER>
<PAGETYPE>IMAGE</PAGETYPE>
<IMAGESIZE>11663</IMAGESIZE>
<PAPER>N</PAPER>
</IMAGE>
</SET>
- <SET ID="TestWF000022">
<SETSEQUENCE>2</SETSEQUENCE>
<IMAGECOUNT>1</IMAGECOUNT>
- <SET_ATTRIB>
<SET_ATTRIB_FIELD>DCN</SET_ATTRIB_FIELD>
<SET_ATTRIB_VALUE>TestGDS2</SET_ATTRIB_VALUE>
</SET_ATTRIB>
- <SET_ATTRIB>
<SET_ATTRIB_FIELD>APPID</SET_ATTRIB_FIELD>
<SET_ATTRIB_VALUE>GDS</SET_ATTRIB_VALUE>
</SET_ATTRIB>
- <SET_ATTRIB>
<SET_ATTRIB_FIELD>PAGECOUNT</SET_ATTRIB_FIELD>
<SET_ATTRIB_VALUE>5</SET_ATTRIB_VALUE>
</SET_ATTRIB>
- <IMAGE ID="dummy2.tif">
<IMAGENUMBER>1</IMAGENUMBER>
<PAGETYPE>IMAGE</PAGETYPE>
<IMAGESIZE>11663</IMAGESIZE>
<PAPER>N</PAPER>
</IMAGE>
</SET>
- <SET ID="TestWF000023">
<SETSEQUENCE>3</SETSEQUENCE>
<IMAGECOUNT>1</IMAGECOUNT>
- <SET_ATTRIB>
<SET_ATTRIB_FIELD>DCN</SET_ATTRIB_FIELD>
<SET_ATTRIB_VALUE>TestGDS3</SET_ATTRIB_VALUE>
</SET_ATTRIB>
- <SET_ATTRIB>
<SET_ATTRIB_FIELD>APPID</SET_ATTRIB_FIELD>
<SET_ATTRIB_VALUE>GDS</SET_ATTRIB_VALUE>
</SET_ATTRIB>
- <SET_ATTRIB>
<SET_ATTRIB_FIELD>PAGECOUNT</SET_ATTRIB_FIELD>
<SET_ATTRIB_VALUE>5</SET_ATTRIB_VALUE>
</SET_ATTRIB>
- <IMAGE ID="dummy3.tif">
<IMAGENUMBER>1</IMAGENUMBER>
<PAGETYPE>IMAGE</PAGETYPE>
<IMAGESIZE>11663</IMAGESIZE>
<PAPER>N</PAPER>
</IMAGE>
</SET>
- <SET ID="TestWF000024">
<SETSEQUENCE>4</SETSEQUENCE>
<IMAGECOUNT>1</IMAGECOUNT>
- <SET_ATTRIB>
<SET_ATTRIB_FIELD>DCN</SET_ATTRIB_FIELD>
<SET_ATTRIB_VALUE>TestGDS4</SET_ATTRIB_VALUE>
</SET_ATTRIB>
- <SET_ATTRIB>
<SET_ATTRIB_FIELD>APPID</SET_ATTRIB_FIELD>
<SET_ATTRIB_VALUE>GDS</SET_ATTRIB_VALUE>
</SET_ATTRIB>
- <SET_ATTRIB>
<SET_ATTRIB_FIELD>PAGECOUNT</SET_ATTRIB_FIELD>
<SET_ATTRIB_VALUE>5</SET_ATTRIB_VALUE>
</SET_ATTRIB>
- <IMAGE ID="dummy4.tif">
<IMAGENUMBER>1</IMAGENUMBER>
<PAGETYPE>IMAGE</PAGETYPE>
<IMAGESIZE>11663</IMAGESIZE>
<PAPER>N</PAPER>
</IMAGE>
</SET>
- <SET ID="TestWF000025">
<SETSEQUENCE>5</SETSEQUENCE>
<IMAGECOUNT>1</IMAGECOUNT>
- <SET_ATTRIB>
<SET_ATTRIB_FIELD>DCN</SET_ATTRIB_FIELD>
<SET_ATTRIB_VALUE>TestGDS5</SET_ATTRIB_VALUE>
</SET_ATTRIB>
- <SET_ATTRIB>
<SET_ATTRIB_FIELD>APPID</SET_ATTRIB_FIELD>
<SET_ATTRIB_VALUE>GDS</SET_ATTRIB_VALUE>
</SET_ATTRIB>
- <SET_ATTRIB>
<SET_ATTRIB_FIELD>PAGECOUNT</SET_ATTRIB_FIELD>
<SET_ATTRIB_VALUE>5</SET_ATTRIB_VALUE>
</SET_ATTRIB>
- <IMAGE ID="dummy5.tif">
<IMAGENUMBER>1</IMAGENUMBER>
<PAGETYPE>IMAGE</PAGETYPE>
<IMAGESIZE>11663</IMAGESIZE>
<PAPER>N</PAPER>
</IMAGE>
</SET>
</BATCH>
</NSR>

Thanks again.

Kevin
 
Here you go:

Code:
{*********************************************}
{                                             }
{              XML Data Binding               }
{                                             }
{         Generated on: 20/08/2010 13:55:40   }
{       Generated from: C:\temp\test.xml      }
{   Settings stored in: C:\temp\test.xdb      }
{                                             }
{*********************************************}

unit test;

interface

uses xmldom, XMLDoc, XMLIntf;

type

{ Forward Decls }

  IXMLNSRType = interface;
  IXMLBATCHType = interface;
  IXMLSETType = interface;
  IXMLSETTypeList = interface;
  IXMLSET_ATTRIBType = interface;
  IXMLSET_ATTRIBTypeList = interface;
  IXMLIMAGEType = interface;
  IXMLIMAGETypeList = interface;

{ IXMLNSRType }

  IXMLNSRType = interface(IXMLNode)
    ['{67C8A1C8-4A48-437C-870F-CA9A3AFF4ADF}']
    { Property Accessors }
    function Get_BATCH: IXMLBATCHType;
    { Methods & Properties }
    property BATCH: IXMLBATCHType read Get_BATCH;
  end;

{ IXMLBATCHType }

  IXMLBATCHType = interface(IXMLNode)
    ['{EA892D66-6691-42D6-8378-867393A42BDF}']
    { Property Accessors }
    function Get_ID: UnicodeString;
    function Get_SETCOUNT: Integer;
    function Get_PROCESSDATE: UnicodeString;
    function Get_SET_: IXMLSETTypeList;
    procedure Set_ID(Value: UnicodeString);
    procedure Set_SETCOUNT(Value: Integer);
    procedure Set_PROCESSDATE(Value: UnicodeString);
    { Methods & Properties }
    property ID: UnicodeString read Get_ID write Set_ID;
    property SETCOUNT: Integer read Get_SETCOUNT write Set_SETCOUNT;
    property PROCESSDATE: UnicodeString read Get_PROCESSDATE write Set_PROCESSDATE;
    property SET_: IXMLSETTypeList read Get_SET_;
  end;

{ IXMLSETType }

  IXMLSETType = interface(IXMLNode)
    ['{51E2C7D0-5FF2-4A38-A0C0-AD70F334F4BF}']
    { Property Accessors }
    function Get_ID: UnicodeString;
    function Get_SETSEQUENCE: Integer;
    function Get_IMAGECOUNT: Integer;
    function Get_SET_ATTRIB: IXMLSET_ATTRIBTypeList;
    function Get_IMAGE: IXMLIMAGETypeList;
    procedure Set_ID(Value: UnicodeString);
    procedure Set_SETSEQUENCE(Value: Integer);
    procedure Set_IMAGECOUNT(Value: Integer);
    { Methods & Properties }
    property ID: UnicodeString read Get_ID write Set_ID;
    property SETSEQUENCE: Integer read Get_SETSEQUENCE write Set_SETSEQUENCE;
    property IMAGECOUNT: Integer read Get_IMAGECOUNT write Set_IMAGECOUNT;
    property SET_ATTRIB: IXMLSET_ATTRIBTypeList read Get_SET_ATTRIB;
    property IMAGE: IXMLIMAGETypeList read Get_IMAGE;
  end;

{ IXMLSETTypeList }

  IXMLSETTypeList = interface(IXMLNodeCollection)
    ['{4D0E6674-5179-490B-8D41-FCC6ACF28E18}']
    { Methods & Properties }
    function Add: IXMLSETType;
    function Insert(const Index: Integer): IXMLSETType;

    function Get_Item(Index: Integer): IXMLSETType;
    property Items[Index: Integer]: IXMLSETType read Get_Item; default;
  end;

{ IXMLSET_ATTRIBType }

  IXMLSET_ATTRIBType = interface(IXMLNode)
    ['{E5DB4E95-41DD-4476-8DF3-7A48446C74BE}']
    { Property Accessors }
    function Get_SET_ATTRIB_FIELD: UnicodeString;
    function Get_SET_ATTRIB_VALUE: UnicodeString;
    procedure Set_SET_ATTRIB_FIELD(Value: UnicodeString);
    procedure Set_SET_ATTRIB_VALUE(Value: UnicodeString);
    { Methods & Properties }
    property SET_ATTRIB_FIELD: UnicodeString read Get_SET_ATTRIB_FIELD write Set_SET_ATTRIB_FIELD;
    property SET_ATTRIB_VALUE: UnicodeString read Get_SET_ATTRIB_VALUE write Set_SET_ATTRIB_VALUE;
  end;

{ IXMLSET_ATTRIBTypeList }

  IXMLSET_ATTRIBTypeList = interface(IXMLNodeCollection)
    ['{FD2B10D7-226F-468D-943F-DBDB281185D1}']
    { Methods & Properties }
    function Add: IXMLSET_ATTRIBType;
    function Insert(const Index: Integer): IXMLSET_ATTRIBType;

    function Get_Item(Index: Integer): IXMLSET_ATTRIBType;
    property Items[Index: Integer]: IXMLSET_ATTRIBType read Get_Item; default;
  end;

{ IXMLIMAGEType }

  IXMLIMAGEType = interface(IXMLNode)
    ['{8A46E033-0506-49EA-A73D-A09CC6F06213}']
    { Property Accessors }
    function Get_ID: UnicodeString;
    function Get_IMAGENUMBER: Integer;
    function Get_PAGETYPE: UnicodeString;
    function Get_IMAGESIZE: Integer;
    function Get_PAPER: UnicodeString;
    procedure Set_ID(Value: UnicodeString);
    procedure Set_IMAGENUMBER(Value: Integer);
    procedure Set_PAGETYPE(Value: UnicodeString);
    procedure Set_IMAGESIZE(Value: Integer);
    procedure Set_PAPER(Value: UnicodeString);
    { Methods & Properties }
    property ID: UnicodeString read Get_ID write Set_ID;
    property IMAGENUMBER: Integer read Get_IMAGENUMBER write Set_IMAGENUMBER;
    property PAGETYPE: UnicodeString read Get_PAGETYPE write Set_PAGETYPE;
    property IMAGESIZE: Integer read Get_IMAGESIZE write Set_IMAGESIZE;
    property PAPER: UnicodeString read Get_PAPER write Set_PAPER;
  end;

{ IXMLIMAGETypeList }

  IXMLIMAGETypeList = interface(IXMLNodeCollection)
    ['{65E8450B-368F-45DF-9C73-CB1F869884B1}']
    { Methods & Properties }
    function Add: IXMLIMAGEType;
    function Insert(const Index: Integer): IXMLIMAGEType;

    function Get_Item(Index: Integer): IXMLIMAGEType;
    property Items[Index: Integer]: IXMLIMAGEType read Get_Item; default;
  end;

{ Forward Decls }

  TXMLNSRType = class;
  TXMLBATCHType = class;
  TXMLSETType = class;
  TXMLSETTypeList = class;
  TXMLSET_ATTRIBType = class;
  TXMLSET_ATTRIBTypeList = class;
  TXMLIMAGEType = class;
  TXMLIMAGETypeList = class;

{ TXMLNSRType }

  TXMLNSRType = class(TXMLNode, IXMLNSRType)
  protected
    { IXMLNSRType }
    function Get_BATCH: IXMLBATCHType;
  public
    procedure AfterConstruction; override;
  end;

{ TXMLBATCHType }

  TXMLBATCHType = class(TXMLNode, IXMLBATCHType)
  private
    FSET_: IXMLSETTypeList;
  protected
    { IXMLBATCHType }
    function Get_ID: UnicodeString;
    function Get_SETCOUNT: Integer;
    function Get_PROCESSDATE: UnicodeString;
    function Get_SET_: IXMLSETTypeList;
    procedure Set_ID(Value: UnicodeString);
    procedure Set_SETCOUNT(Value: Integer);
    procedure Set_PROCESSDATE(Value: UnicodeString);
  public
    procedure AfterConstruction; override;
  end;

{ TXMLSETType }

  TXMLSETType = class(TXMLNode, IXMLSETType)
  private
    FSET_ATTRIB: IXMLSET_ATTRIBTypeList;
    FIMAGE: IXMLIMAGETypeList;
  protected
    { IXMLSETType }
    function Get_ID: UnicodeString;
    function Get_SETSEQUENCE: Integer;
    function Get_IMAGECOUNT: Integer;
    function Get_SET_ATTRIB: IXMLSET_ATTRIBTypeList;
    function Get_IMAGE: IXMLIMAGETypeList;
    procedure Set_ID(Value: UnicodeString);
    procedure Set_SETSEQUENCE(Value: Integer);
    procedure Set_IMAGECOUNT(Value: Integer);
  public
    procedure AfterConstruction; override;
  end;

{ TXMLSETTypeList }

  TXMLSETTypeList = class(TXMLNodeCollection, IXMLSETTypeList)
  protected
    { IXMLSETTypeList }
    function Add: IXMLSETType;
    function Insert(const Index: Integer): IXMLSETType;

    function Get_Item(Index: Integer): IXMLSETType;
  end;

{ TXMLSET_ATTRIBType }

  TXMLSET_ATTRIBType = class(TXMLNode, IXMLSET_ATTRIBType)
  protected
    { IXMLSET_ATTRIBType }
    function Get_SET_ATTRIB_FIELD: UnicodeString;
    function Get_SET_ATTRIB_VALUE: UnicodeString;
    procedure Set_SET_ATTRIB_FIELD(Value: UnicodeString);
    procedure Set_SET_ATTRIB_VALUE(Value: UnicodeString);
  end;

{ TXMLSET_ATTRIBTypeList }

  TXMLSET_ATTRIBTypeList = class(TXMLNodeCollection, IXMLSET_ATTRIBTypeList)
  protected
    { IXMLSET_ATTRIBTypeList }
    function Add: IXMLSET_ATTRIBType;
    function Insert(const Index: Integer): IXMLSET_ATTRIBType;

    function Get_Item(Index: Integer): IXMLSET_ATTRIBType;
  end;

{ TXMLIMAGEType }

  TXMLIMAGEType = class(TXMLNode, IXMLIMAGEType)
  protected
    { IXMLIMAGEType }
    function Get_ID: UnicodeString;
    function Get_IMAGENUMBER: Integer;
    function Get_PAGETYPE: UnicodeString;
    function Get_IMAGESIZE: Integer;
    function Get_PAPER: UnicodeString;
    procedure Set_ID(Value: UnicodeString);
    procedure Set_IMAGENUMBER(Value: Integer);
    procedure Set_PAGETYPE(Value: UnicodeString);
    procedure Set_IMAGESIZE(Value: Integer);
    procedure Set_PAPER(Value: UnicodeString);
  end;

{ TXMLIMAGETypeList }

  TXMLIMAGETypeList = class(TXMLNodeCollection, IXMLIMAGETypeList)
  protected
    { IXMLIMAGETypeList }
    function Add: IXMLIMAGEType;
    function Insert(const Index: Integer): IXMLIMAGEType;

    function Get_Item(Index: Integer): IXMLIMAGEType;
  end;

{ Global Functions }

function GetNSR(Doc: IXMLDocument): IXMLNSRType;
function LoadNSR(const FileName: string): IXMLNSRType;
function NewNSR: IXMLNSRType;

const
  TargetNamespace = '';

implementation

{ Global Functions }

function GetNSR(Doc: IXMLDocument): IXMLNSRType;
begin
  Result := Doc.GetDocBinding('NSR', TXMLNSRType, TargetNamespace) as IXMLNSRType;
end;

function LoadNSR(const FileName: string): IXMLNSRType;
begin
  Result := LoadXMLDocument(FileName).GetDocBinding('NSR', TXMLNSRType, TargetNamespace) as IXMLNSRType;
end;

function NewNSR: IXMLNSRType;
begin
  Result := NewXMLDocument.GetDocBinding('NSR', TXMLNSRType, TargetNamespace) as IXMLNSRType;
end;

{ TXMLNSRType }

procedure TXMLNSRType.AfterConstruction;
begin
  RegisterChildNode('BATCH', TXMLBATCHType);
  inherited;
end;

function TXMLNSRType.Get_BATCH: IXMLBATCHType;
begin
  Result := ChildNodes['BATCH'] as IXMLBATCHType;
end;

{ TXMLBATCHType }

procedure TXMLBATCHType.AfterConstruction;
begin
  RegisterChildNode('SET', TXMLSETType);
  FSET_ := CreateCollection(TXMLSETTypeList, IXMLSETType, 'SET') as IXMLSETTypeList;
  inherited;
end;

function TXMLBATCHType.Get_ID: UnicodeString;
begin
  Result := AttributeNodes['ID'].Text;
end;

procedure TXMLBATCHType.Set_ID(Value: UnicodeString);
begin
  SetAttribute('ID', Value);
end;

function TXMLBATCHType.Get_SETCOUNT: Integer;
begin
  Result := ChildNodes['SETCOUNT'].NodeValue;
end;

procedure TXMLBATCHType.Set_SETCOUNT(Value: Integer);
begin
  ChildNodes['SETCOUNT'].NodeValue := Value;
end;

function TXMLBATCHType.Get_PROCESSDATE: UnicodeString;
begin
  Result := ChildNodes['PROCESSDATE'].Text;
end;

procedure TXMLBATCHType.Set_PROCESSDATE(Value: UnicodeString);
begin
  ChildNodes['PROCESSDATE'].NodeValue := Value;
end;

function TXMLBATCHType.Get_SET_: IXMLSETTypeList;
begin
  Result := FSET_;
end;

{ TXMLSETType }

procedure TXMLSETType.AfterConstruction;
begin
  RegisterChildNode('SET_ATTRIB', TXMLSET_ATTRIBType);
  RegisterChildNode('IMAGE', TXMLIMAGEType);
  FSET_ATTRIB := CreateCollection(TXMLSET_ATTRIBTypeList, IXMLSET_ATTRIBType, 'SET_ATTRIB') as IXMLSET_ATTRIBTypeList;
  FIMAGE := CreateCollection(TXMLIMAGETypeList, IXMLIMAGEType, 'IMAGE') as IXMLIMAGETypeList;
  inherited;
end;

function TXMLSETType.Get_ID: UnicodeString;
begin
  Result := AttributeNodes['ID'].Text;
end;

procedure TXMLSETType.Set_ID(Value: UnicodeString);
begin
  SetAttribute('ID', Value);
end;

function TXMLSETType.Get_SETSEQUENCE: Integer;
begin
  Result := ChildNodes['SETSEQUENCE'].NodeValue;
end;

procedure TXMLSETType.Set_SETSEQUENCE(Value: Integer);
begin
  ChildNodes['SETSEQUENCE'].NodeValue := Value;
end;

function TXMLSETType.Get_IMAGECOUNT: Integer;
begin
  Result := ChildNodes['IMAGECOUNT'].NodeValue;
end;

procedure TXMLSETType.Set_IMAGECOUNT(Value: Integer);
begin
  ChildNodes['IMAGECOUNT'].NodeValue := Value;
end;

function TXMLSETType.Get_SET_ATTRIB: IXMLSET_ATTRIBTypeList;
begin
  Result := FSET_ATTRIB;
end;

function TXMLSETType.Get_IMAGE: IXMLIMAGETypeList;
begin
  Result := FIMAGE;
end;

{ TXMLSETTypeList }

function TXMLSETTypeList.Add: IXMLSETType;
begin
  Result := AddItem(-1) as IXMLSETType;
end;

function TXMLSETTypeList.Insert(const Index: Integer): IXMLSETType;
begin
  Result := AddItem(Index) as IXMLSETType;
end;

function TXMLSETTypeList.Get_Item(Index: Integer): IXMLSETType;
begin
  Result := List[Index] as IXMLSETType;
end;

{ TXMLSET_ATTRIBType }

function TXMLSET_ATTRIBType.Get_SET_ATTRIB_FIELD: UnicodeString;
begin
  Result := ChildNodes['SET_ATTRIB_FIELD'].Text;
end;

procedure TXMLSET_ATTRIBType.Set_SET_ATTRIB_FIELD(Value: UnicodeString);
begin
  ChildNodes['SET_ATTRIB_FIELD'].NodeValue := Value;
end;

function TXMLSET_ATTRIBType.Get_SET_ATTRIB_VALUE: UnicodeString;
begin
  Result := ChildNodes['SET_ATTRIB_VALUE'].Text;
end;

procedure TXMLSET_ATTRIBType.Set_SET_ATTRIB_VALUE(Value: UnicodeString);
begin
  ChildNodes['SET_ATTRIB_VALUE'].NodeValue := Value;
end;

{ TXMLSET_ATTRIBTypeList }

function TXMLSET_ATTRIBTypeList.Add: IXMLSET_ATTRIBType;
begin
  Result := AddItem(-1) as IXMLSET_ATTRIBType;
end;

function TXMLSET_ATTRIBTypeList.Insert(const Index: Integer): IXMLSET_ATTRIBType;
begin
  Result := AddItem(Index) as IXMLSET_ATTRIBType;
end;

function TXMLSET_ATTRIBTypeList.Get_Item(Index: Integer): IXMLSET_ATTRIBType;
begin
  Result := List[Index] as IXMLSET_ATTRIBType;
end;

{ TXMLIMAGEType }

function TXMLIMAGEType.Get_ID: UnicodeString;
begin
  Result := AttributeNodes['ID'].Text;
end;

procedure TXMLIMAGEType.Set_ID(Value: UnicodeString);
begin
  SetAttribute('ID', Value);
end;

function TXMLIMAGEType.Get_IMAGENUMBER: Integer;
begin
  Result := ChildNodes['IMAGENUMBER'].NodeValue;
end;

procedure TXMLIMAGEType.Set_IMAGENUMBER(Value: Integer);
begin
  ChildNodes['IMAGENUMBER'].NodeValue := Value;
end;

function TXMLIMAGEType.Get_PAGETYPE: UnicodeString;
begin
  Result := ChildNodes['PAGETYPE'].Text;
end;

procedure TXMLIMAGEType.Set_PAGETYPE(Value: UnicodeString);
begin
  ChildNodes['PAGETYPE'].NodeValue := Value;
end;

function TXMLIMAGEType.Get_IMAGESIZE: Integer;
begin
  Result := ChildNodes['IMAGESIZE'].NodeValue;
end;

procedure TXMLIMAGEType.Set_IMAGESIZE(Value: Integer);
begin
  ChildNodes['IMAGESIZE'].NodeValue := Value;
end;

function TXMLIMAGEType.Get_PAPER: UnicodeString;
begin
  Result := ChildNodes['PAPER'].Text;
end;

procedure TXMLIMAGEType.Set_PAPER(Value: UnicodeString);
begin
  ChildNodes['PAPER'].NodeValue := Value;
end;

{ TXMLIMAGETypeList }

function TXMLIMAGETypeList.Add: IXMLIMAGEType;
begin
  Result := AddItem(-1) as IXMLIMAGEType;
end;

function TXMLIMAGETypeList.Insert(const Index: Integer): IXMLIMAGEType;
begin
  Result := AddItem(Index) as IXMLIMAGEType;
end;

function TXMLIMAGETypeList.Get_Item(Index: Integer): IXMLIMAGEType;
begin
  Result := List[Index] as IXMLIMAGEType;
end;

end.

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Daddy,

Thanks. That actually is what the wizard in Delphi 7 produced.

Why doesn't "IXMLBATCHType" have an Add method? I'm not quite sure how to set the "ID" attribute on "BATCH" element/tag/node. However, I'm learning Delphi on the fly.

I was following the example you gave in this thread:


Kevin
 
I think I've figured it out:

procedure CreateESIRXMLFile;
var
IESIRDocument : IXMLNSRType;
ISet : IXMLSETType;

begin
IESIRDocument := NewNSR;
IESIRDocument.BATCH.ID := 'ESIR.201008160001';
IESIRDocument.BATCH.SETCOUNT := 5;
IESIRDocument.BATCH.PROCESSDATE := '11/16/2007';
IESIRDocument.OwnerDocument.SaveToFile('ESIR.2010081600001.XML');
end;

However, the XML file it's creating is not formatted correctly. It's one long string (no CR or indentions). Do I have to manually do this?
 
Why do I get an access violation when the "ISet" attributes are being set?

procedure CreateESIRXMLFile;
var
IESIRDocument : IXMLNSRType;
ISet : IXMLSETType;

begin
IESIRDocument := NewNSR;

// Batch Node
IESIRDocument.BATCH.ID := 'ESIR.201008160001';
IESIRDocument.BATCH.SETCOUNT := 5;
IESIRDocument.BATCH.PROCESSDATE := '11/16/2007';

// Set Node
ISet.ID := 'ESIR.201008160001_0000000001';
ISet.SETSEQUENCE := 1;
ISet.IMAGECOUNT := 5;

IESIRDocument.OwnerDocument.SaveToFile('ESIR.2010081600001.XML');
end;
 
you need to create ISet first.

take a look at IXMLBATCHType, it contains a property SET_
(set is a reserved word in Delphi, hence the underscore).
SET_ wHich is IXMLSETTypeList, so a collection of IXMLSETType.

the correct code would be:

Code:
procedure CreateESIRXMLFile;
var  IESIRDocument : IXMLNSRType;  
     ISet          : IXMLSETType;begin  
     
begin     
 IESIRDocument := NewNSR;  
 // Batch Node  
 IESIRDocument.BATCH.ID := 'ESIR.201008160001';  
 IESIRDocument.BATCH.SETCOUNT := 5;  
 IESIRDocument.BATCH.PROCESSDATE := '11/16/2007';  
 // Set Node  
 ISet := IESIRDocument.BATCH.SET_.Add; 
 ISet.ID := 'ESIR.201008160001_0000000001'; 
 ISet.SETSEQUENCE := 1;  
 ISet.IMAGECOUNT := 5;  
 ISet := IESIRDocument.BATCH.SET_.Add; 
 ISet.ID := 'ESIR.201008160001_0000000002'; 
 ISet.SETSEQUENCE := 2;  
 ISet.IMAGECOUNT := 5;
 ...  
 IESIRDocument.OwnerDocument.SaveToFile('ESIR.2010081600001.XML');
end;

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Thanks, Daddy. Worked perfectly.

Is there a reason why my XML file isn't formatted? It's one long string. No linefeeds or indentions.
 
thats how it should be.
open the file in xml notepad if you intend to edit the file.

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top