Добрый день знатокам!
Написал программу которая обрабатывает XML документы и загружает данные файла в программу (ГИС "Ингео"). Строю объект по координатам с данного файла и переношу семантику.
Программа работает, данные переносятся, но возникла проблема что в файлах XML которые скачивает пользователь почему то меняются префиксы (или как они точнее называются). Пример:
Код:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://portal.rosreestr.ru/xsl/EGRP/Reestr_Extract_Gkn/ZU/07/Common.xsl"?>
<KPZU xmlns="urn://x-artefacts-rosreestr-ru/outgoing/kpzu/6.0.1" xmlns:smev="urn://x-artefacts-smev-gov-ru/supplementary/commons/1.0.1"
xmlns:num="urn://x-artefacts-rosreestr-ru/commons/complex-types/numbers/1.0" xmlns:adrs="urn://x-artefacts-rosreestr-ru/commons/complex-types/address-output/4.0.1"
xmlns:spa="urn://x-artefacts-rosreestr-ru/commons/complex-types/entity-spatial/5.0.1"
xmlns:cer="urn://x-artefacts-rosreestr-ru/commons/complex-types/certification-doc/1.0"
xmlns:doc="urn://x-artefacts-rosreestr-ru/commons/complex-types/document-output/4.0.1"
xmlns:nobj="urn://x-artefacts-rosreestr-ru/commons/complex-types/natural-objects-output/1.0.1">
<Parcel CadastralNumber="56:43:0110026:24" State="06" DateCreated="2008-03-19" Method="4">
<EntitySpatial EntSys="ID0">
<spa:SpatialElement>
<spa:SpelementUnit TypeUnit="Точка" SuNmb="1">
<spa:Ordinate X="372630.97" Y="3329297.42" OrdNmb="1" DeltaGeopoint="0.1" />
</spa:SpelementUnit>
<spa:SpelementUnit TypeUnit="Точка" SuNmb="2">
<spa:Ordinate X="372649.52" Y="3329313.77" OrdNmb="1" DeltaGeopoint="0.1" />
</spa:SpelementUnit>
<spa:SpelementUnit TypeUnit="Точка" SuNmb="3">
<spa:Ordinate X="372673.14" Y="3329286.6" OrdNmb="1" DeltaGeopoint="0.1" />
</spa:SpelementUnit>
<spa:SpelementUnit TypeUnit="Точка" SuNmb="4">
<spa:Ordinate X="372654.37" Y="3329270.19" OrdNmb="1" DeltaGeopoint="0.1" GeopointZacrep="626002000000" />
</spa:SpelementUnit>
<spa:SpelementUnit TypeUnit="Точка" SuNmb="5">
<spa:Ordinate X="372631.37" Y="3329296.97" OrdNmb="1" DeltaGeopoint="0.3" GeopointZacrep="626002000000" />
</spa:SpelementUnit>
<spa:SpelementUnit TypeUnit="Точка" SuNmb="1">
<spa:Ordinate X="372630.97" Y="3329297.42" OrdNmb="1" DeltaGeopoint="0.1" />
</spa:SpelementUnit>
</spa:SpatialElement>
</EntitySpatial>
</Parcel>
</KPZU>
Пример 2:
Код:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="https://portal.rosreestr.ru/xsl/GKN/Vidimus/07/common.xsl"?>
<KVZU
xmlns:ns2="urn://x-artefacts-rosreestr-ru/commons/complex-types/numbers/1.0"
xmlns:ns3="urn://x-artefacts-rosreestr-ru/commons/complex-types/entity-spatial/5.0.1"
xmlns:adrOut4="urn://x-artefacts-rosreestr-ru/commons/complex-types/address-output/4.0.1"
xmlns:ns5="urn://x-artefacts-rosreestr-ru/commons/complex-types/natural-objects-output/1.0.1"
xmlns:ns6="urn://x-artefacts-smev-gov-ru/supplementary/commons/1.0.1"
xmlns:ns7="urn://x-artefacts-rosreestr-ru/commons/complex-types/document-output/4.0.1"
xmlns:ns8="urn://x-artefacts-rosreestr-ru/commons/complex-types/certification-doc/1.0"
xmlns="urn://x-artefacts-rosreestr-ru/outgoing/kvzu/7.0.1">
<Parcel CadastralNumber="56:18:0601002:361" State="06" DateCreated="2012-12-17">
<EntitySpatial EntSys="ID1">
<ns3:SpatialElement>
<ns3:SpelementUnit TypeUnit="Точка" SuNmb="5">
<ns3:Ordinate X="385907.66" Y="3364855.93" OrdNmb="1" />
</ns3:SpelementUnit>
<ns3:SpelementUnit TypeUnit="Точка" SuNmb="2">
<ns3:Ordinate X="385906.23" Y="3364855.79" OrdNmb="1" DeltaGeopoint="0.20" />
</ns3:SpelementUnit>
<ns3:SpelementUnit TypeUnit="Точка" SuNmb="3">
<ns3:Ordinate X="385903.48" Y="3364883.70" OrdNmb="1" DeltaGeopoint="0.20" />
</ns3:SpelementUnit>
<ns3:SpelementUnit TypeUnit="Точка" SuNmb="6">
<ns3:Ordinate X="385904.92" Y="3364883.84" OrdNmb="1" />
</ns3:SpelementUnit>
<ns3:SpelementUnit TypeUnit="Точка" SuNmb="5">
<ns3:Ordinate X="385907.66" Y="3364855.93" OrdNmb="1" />
</ns3:SpelementUnit>
</ns3:SpatialElement>
<ns3:Borders>
<ns3:Border Spatial="1" Point1="5" Point2="2">
<ns3:Edge>
<ns3:Length>1.44</ns3:Length>
<ns3:DirectionAngle>
<ns3:Degree>185</ns3:Degree>
<ns3:Minute>35</ns3:Minute>
</ns3:DirectionAngle>
</ns3:Edge>
</ns3:Border>
<ns3:Border Spatial="1" Point1="2" Point2="3">
<ns3:Edge>
<ns3:Length>28.05</ns3:Length>
<ns3:DirectionAngle>
<ns3:Degree>95</ns3:Degree>
<ns3:Minute>38</ns3:Minute>
</ns3:DirectionAngle>
</ns3:Edge>
</ns3:Border>
<ns3:Border Spatial="1" Point1="3" Point2="6">
<ns3:Edge>
<ns3:Length>1.45</ns3:Length>
<ns3:DirectionAngle>
<ns3:Degree>5</ns3:Degree>
<ns3:Minute>33</ns3:Minute>
</ns3:DirectionAngle>
</ns3:Edge>
</ns3:Border>
<ns3:Border Spatial="1" Point1="6" Point2="5">
<ns3:Edge>
<ns3:Length>28.04</ns3:Length>
<ns3:DirectionAngle>
<ns3:Degree>275</ns3:Degree>
<ns3:Minute>36</ns3:Minute>
</ns3:DirectionAngle>
</ns3:Edge>
</ns3:Border>
</ns3:Borders>
</EntitySpatial>
</Parcel>
</KPZU>
В первом случае префикс "
spa:", в другом уже "
ns3". Может как то можно игнорировать данный префикс и как это сделать?
Для поиска дочерних элементов использую функцию
Код:
function TXMLParserForm.GetNodeByPath(Root: IXMLNode; Path,Namespace: string): IXMLNode;
var tempNode:IXMLNode;
currentElement:string;
delimPos:integer;
begin
tempNode:=nil;
if Root=nil then begin result:=nil;exit;end;
if Path<>'' then begin
delimPos := pos('\',Path);
tempNode:=Root;
while delimPos>0 do begin //Усли имеется несколько элементов
currentElement := Copy(Path,1,delimPos-1);
Path := Copy(Path,delimPos+1,length(Path)-delimPos);
if currentElement='..' then begin
tempNode:=tempNode.ParentNode;
end else begin
tempNode:=tempNode.ChildNodes.FindNode(currentElement,Namespace);
end;
if tempNode=nil then begin result:=nil;exit;end;
delimPos := pos('\',Path);
end;
if (delimPos=0) then begin
if Path='..' then tempNode:=tempNode.ParentNode else tempNode := tempNode.ChildNodes.FindNode(Path,Namespace);
if tempNode=nil then begin result:=nil;exit;end;
result := tempNode;
exit;
end;
end;
end;
Вызываю следующим способом:
Код:
currNode := GetNodeByPath(RootNode,Root+'\'+Path,'');
Где передается корневой элемент и путь вида "Ветка1\Ветка2\Ветка.."
В конкретном случае
Код:
currNode := GetNodeByPath(RootNode,Root+'EntitySpatial\spa:SpatialElement','');