3

gpx ファイルの作成を処理するための便利なツールを採用する予定です。

簡単な XML データ管理、データ ストレージ、およびシステム間のデータ交換に適した OmniXML ベースのストレージであるSimpleStorageは、それに適していると思います。

ベアボーン gpx ファイルをそのように生成するための (不完全な) スニペットを次に示します。

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;

私を助けてください !

4

2 に答える 2

1

OmniXMLサイトでMiha Remecからの関連する投稿を見つけました。

私の質問に対する考えられる答えの1つは、次のように要約できます。

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

命令行の直後に追加するには:

  Result := CreateStorage('gpx'); 
于 2012-02-13T15:04:00.780 に答える
0
uses
  OmniXML,
  OmniXMLUtils;

function CreateGpx: ISimpleStorage;
{ ... }
var
  xmlDocument: IXMLDocument;
  xmlProcessingInstruction: IXMLProcessingInstruction;
  fisrtChild: IXMLNode;
begin
  { ... }
  xmlDocument := OmniXMLUtils.OwnerDocument(Result.Node.ParentNode);
  if OmniXMLUtils.FindProcessingInstruction(xmlDocument) = nil then
  begin
    xmlProcessingInstruction := xmlDocument.CreateProcessingInstruction('xml', 'version="1.0" encoding="utf-8"');

    fisrtChild := xmlDocument.FirstChild;
    if fisrtChild = nil then
    begin
      xmlDocument.AppendChild(xmlProcessingInstruction);
    end
    else
    begin
      xmlDocument.InsertBefore(xmlProcessingInstruction, fisrtChild);
    end;
  end;
  { ... }
end;
于 2015-10-02T09:45:28.633 に答える