Hi to all!

I need to generate different Word documents in XML format. Now I have some
questions:
1. Lazarus and FPC have some classes for working with XML. I want make some
classes - descendants of TXMLDocument and TXMLElement, which will realize
WordML structure. Maybe anyone know existing solution?

2. I began work in this direction and have make some classes.
For example: text block in Word document is a xml node with following
structure:
http://schemas.liquid-technologies.com/librarydocs/office/2003/t1.html.
Text block is a child node of run
element<http://schemas.liquid-technologies.com/librarydocs/office/2003/r3.html>.
Run element is a child of paragraph element and so on. WordML is a very big
scheme, but most of element is not required for creating correct file.

I want make following classes:
TWordML - descendant of TXMLDocument and document part classes - descendants
of TDOMElement. TWordML class must have structure that will allways correspond
to WordML scheme.

for examle:

*TWordMLElement *- base class for all document parts. Function *GetElementName
*returns tag name of correspondent element.

  TWordMLElement = class (TDOMElement)
    constructor Create(AOwner: TDOMDocument);
    class function GetElementName: string; virtual; abstract;
  end;

*TRunElement - *class that representing run element in WordML scheme. It
contains one child node with tag name 't' and direct link to its content
(text block in word documents): property Text.

  TRunElement = class (TWordMLElement)
  private
    FTextNode: TDOMNode;
    function GetText: string;
    procedure SetText(const AValue: string);
    function CreateTextNode: TDOMNode;
  published
    property Text: string read GetText write SetText;
    class function GetElementName: string; override;
  end;

(Now I have inplenemtation only for one class - TRunElement. I willn't write
it here right now)

So, using this class, you don't need to write many lines of code. You need
only create new run element and write this two lines:

type
  TWordMLClass = class of TWordMLElement;

var
  MyRunElement: TRunElement;
  MyDoc: TWordML;
...

MyRunElement:=MyDoc.Create(TRunElement);
MyRunElement.Text:='Some symbols for Word document';

and you will recieve xml file with following content:

... <w:r><w:t>Some symbols for Word document<w:t/><w:r/> ...

But I have doubt: perhaps, I do something wrong?
I will be grateful for any halp or advise.
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to