From a8c3182f427807b49f79375d708f1f12bad42c0c Mon Sep 17 00:00:00 2001 From: inoussa Date: Sun, 12 Aug 2012 01:12:14 +0000 Subject: [PATCH] SOAP inline namespace handling, thanks to Christian Schiffler for patch git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2486 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- wst/trunk/base_soap_formatter.pas | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/wst/trunk/base_soap_formatter.pas b/wst/trunk/base_soap_formatter.pas index 5b0fb6779..06a6b56b3 100644 --- a/wst/trunk/base_soap_formatter.pas +++ b/wst/trunk/base_soap_formatter.pas @@ -344,6 +344,7 @@ type const ANameSpace : string; const ACreateIfNotFound : Boolean ):shortstring;{$IFDEF USE_INLINE}inline;{$ENDIF} + function FindXMLNodeWithNamespaceInSubScope(ANameSpace, ANodeName: string): TDOMNode; protected function GetCurrentScope():String; function GetCurrentScopeObject():TDOMElement; @@ -832,6 +833,42 @@ begin Result := ''; end; end; +function TSOAPBaseFormatter.FindXMLNodeWithNamespaceInSubScope( + ANameSpace, + ANodeName : string +) : TDOMNode; + + function ScanNode(ANode: TDOMNode): TDOMNode; + var + AttrName : string; + begin + Result := nil; + if FindAttributeByValueInNode(ANameSpace, ANode, AttrName) then begin + if not IsStrEmpty(AttrName) then begin + AttrName := ExtractNameSpaceShortName(AttrName); + if not IsStrEmpty(AttrName) then begin + if(ANode.NodeName = AttrName + ':' + ANodeName) then + Result := ANode; + end; + end; + end; + end; + +var + locNode : TDOMNode; +begin + locNode := GetCurrentScopeObject(); + Result := ScanNode(locNode); + if (Result <> nil) or not(locNode.HasChildNodes) then + exit; + locNode := locNode.FirstChild; + while (locNode <> nil) do begin + Result := ScanNode(locNode); + if (Result <> nil) then + Break; + locNode := locNode.NextSibling; + end; +end; function TSOAPBaseFormatter.InternalPutData( const ANameSpace : string; @@ -1047,6 +1084,8 @@ begin end else begin locElt := GetCurrentScopeObject().GetAttributeNode(strNodeName); end; + if (locElt = nil) and (Style = Document) then + locElt := FindXMLNodeWithNamespaceInSubScope(ANameSpace,AName); Result := ( locElt <> nil ); if Result then begin @@ -1572,6 +1611,8 @@ begin ( ( AScopeType = stArray ) and ( AStyle = asScoped ) ) then begin locNode := stk.FindNode(strNodeName); + if (locNode = nil) and (Style = Document) then + locNode := FindXMLNodeWithNamespaceInSubScope(nmspc,AScopeName); end else begin locNode := stk.ScopeObject; end;