How to insert xml prolog using SimpleStorage to generate gpx file?

I plan to adopt once and for all handy a tool for handling the creation of gpx files.

I believe SimpleStorage which is a OmniXML based storage suited for easy XML data management, data storage and data interchange beetween systems fits it.

Here is an (incomplete) snippet to generate a bare bone gpx file that way :

function CreateGpx: ISimpleStorage;
const
  versionStr = '1.1';
  creatorStr = 'MyGpxCreatorSSway';

  xmlnsStr = 'http://www.topografix.com/GPX/1/1';
  xmlns_xsiStr = 'http://www.w3.org/2001/XMLSchema-instance';
  xsiStr: string =  xmlnsStr+' '+
                    xmlnsStr+'/gpx.xsd';

begin
  Result := CreateStorage('gpx');

  CreateBuilder(Result).Construct(
  [
    AddAttr('xmlns',xmlnsStr),
    AddAttr('version',versionStr),
    AddAttr('creator',creatorStr),
    AddAttr('xmlns:xsi',xmlns_xsiStr),
    AddAttr('xsi:schemaLocation',xsiStr),
    //
    AddElement('metadata',
    [
      AddElement('bounds',
      [
        AddAttr('minlat','90.00000000'),
        AddAttr('minlon','180.00000000'),
        AddAttr('maxlat','-90.00000000'),
        AddAttr('maxlon','-180.00000000')
      ]),
      AddElement('extensions',[])
    ]),
    AddElement('extensions',[])
  ]
  );
end;

Please help me !

Answers


I've spotted relevant post from Miha Remec on OmniXML site.

One possible answer to my question might be boiled down to as follows :

with OwnerDocument(Result.XMLNode) do
begin
  InsertBefore(CreateProcessingInstruction('xml', 'version="1.0" encoding="UTF-8"'), DocumentElement)
end;

to append just after the instruction line :

  Result := CreateStorage('gpx'); 

Need Your Help

Is this an appropriate time to look into using async?

c# asynchronous async-await

I'm working on a program that pings a long list of IP addresses. Currently there are about 250 in the database to ping, and it takes a long time to get through all of them. The program also sends e...

Can create_join_table only take 2-3 arguments?

ruby-on-rails ruby migration

I've tried a bunch of variations of this migration file:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.