You've already forked lazarus-ccr
Use "LocalName" and "NamespaceURI" to handle in-line name-space
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2488 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -17,7 +17,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils,
|
Classes, SysUtils,
|
||||||
{$IFDEF FPC}
|
{$IFDEF FPC}
|
||||||
fpcunit, testutils, testregistry, DOM, XmlRead, wst_fpc_xml,
|
fpcunit, testutils, testregistry, DOM, wst_fpc_xml,
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
TestFrameWork, xmldom, wst_delphi_xml,
|
TestFrameWork, xmldom, wst_delphi_xml,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -328,8 +328,7 @@ const
|
|||||||
|
|
||||||
function LoadXmlFile(const AFileName : string) : TXMLDocument;
|
function LoadXmlFile(const AFileName : string) : TXMLDocument;
|
||||||
begin
|
begin
|
||||||
Result := nil;
|
Result := ReadXMLFile(AFileName);
|
||||||
ReadXMLFile(Result,AFileName);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TTest_CustomXsdParser }
|
{ TTest_CustomXsdParser }
|
||||||
|
@ -21,7 +21,7 @@ uses
|
|||||||
, xmldom, wst_delphi_xml
|
, xmldom, wst_delphi_xml
|
||||||
{$ENDIF WST_DELPHI}
|
{$ENDIF WST_DELPHI}
|
||||||
{$IFDEF FPC}
|
{$IFDEF FPC}
|
||||||
, DOM, XMLRead
|
, DOM, wst_fpc_xml
|
||||||
{$ENDIF FPC}
|
{$ENDIF FPC}
|
||||||
, xsd_parser;
|
, xsd_parser;
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ begin
|
|||||||
locFileName := FindFileName(ADocLocation);
|
locFileName := FindFileName(ADocLocation);
|
||||||
Result := (locFileName <> '');
|
Result := (locFileName <> '');
|
||||||
if Result then
|
if Result then
|
||||||
ReadXMLFile(ADoc,locFileName);
|
ADoc := ReadXMLFile(locFileName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFileDocumentLocator.FindPath(ADocLocation : string) : string;
|
function TFileDocumentLocator.FindPath(ADocLocation : string) : string;
|
||||||
|
@ -23,6 +23,7 @@ resourcestring
|
|||||||
' -f Specify unit(s) renaming option : oldName= NewName(;oldName= NewName)* ';
|
' -f Specify unit(s) renaming option : oldName= NewName(;oldName= NewName)* ';
|
||||||
sCOPYRIGHT = 'ws_helper, Web Service Toolkit 0.6 Copyright (c) 2006, 2007, 2008, 2009, 2010,2011 by Inoussa OUEDRAOGO';
|
sCOPYRIGHT = 'ws_helper, Web Service Toolkit 0.6 Copyright (c) 2006, 2007, 2008, 2009, 2010,2011 by Inoussa OUEDRAOGO';
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TSourceFileType = ( sftPascal, sftWSDL, sftXsd );
|
TSourceFileType = ( sftPascal, sftWSDL, sftXsd );
|
||||||
|
|
||||||
@ -113,7 +114,7 @@ var
|
|||||||
prsrW : IParser;
|
prsrW : IParser;
|
||||||
prsrCtx : IParserContext;
|
prsrCtx : IParserContext;
|
||||||
begin
|
begin
|
||||||
ReadXMLFile(locDoc,inFileName);
|
locDoc := ReadXMLFile(inFileName);
|
||||||
{$IFNDEF WST_INTF_DOM}
|
{$IFNDEF WST_INTF_DOM}
|
||||||
try
|
try
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -137,7 +138,7 @@ var
|
|||||||
prsrCtx : IParserContext;
|
prsrCtx : IParserContext;
|
||||||
begin
|
begin
|
||||||
prsr := nil;
|
prsr := nil;
|
||||||
ReadXMLFile(locDoc,inFileName);
|
locDoc := ReadXMLFile(inFileName);
|
||||||
{$IFNDEF WST_INTF_DOM}
|
{$IFNDEF WST_INTF_DOM}
|
||||||
try
|
try
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
@ -900,12 +900,14 @@ procedure TWsdlParser.ParsePort(ANode: TDOMNode);
|
|||||||
function FindBindingNode(const AName : WideString):TDOMNode;
|
function FindBindingNode(const AName : WideString):TDOMNode;
|
||||||
var
|
var
|
||||||
crs : IObjectCursor;
|
crs : IObjectCursor;
|
||||||
|
s : string;
|
||||||
begin
|
begin
|
||||||
Result := FindNamedNode(FBindingCursor,AName);
|
Result := FindNamedNode(FBindingCursor,AName);
|
||||||
if Assigned(Result) then begin
|
if Assigned(Result) then begin
|
||||||
crs := CreateChildrenCursor(Result,cetRttiNode);
|
crs := CreateChildrenCursor(Result,cetRttiNode);
|
||||||
if Assigned(crs) then begin
|
if Assigned(crs) then begin
|
||||||
crs := CreateCursorOn(crs,ParseFilter(CreateQualifiedNameFilterStr(s_binding,FSoapShortNames),TDOMNodeRttiExposer));
|
s := Format('%s = %s and %s = %s',[s_LOCAL_NAME,QuotedStr(s_binding), s_NS_URI, QuotedStr(s_soap)]);
|
||||||
|
crs := CreateCursorOn(crs,ParseFilter(s,TDOMNodeRttiExposer));
|
||||||
crs.Reset();
|
crs.Reset();
|
||||||
if not crs.MoveNext() then begin
|
if not crs.MoveNext() then begin
|
||||||
Result := nil;
|
Result := nil;
|
||||||
@ -959,12 +961,14 @@ procedure TWsdlParser.ParsePort(ANode: TDOMNode);
|
|||||||
var
|
var
|
||||||
tmpCrs : IObjectCursor;
|
tmpCrs : IObjectCursor;
|
||||||
nd : TDOMNode;
|
nd : TDOMNode;
|
||||||
|
s : string;
|
||||||
begin
|
begin
|
||||||
Result := '';
|
Result := '';
|
||||||
if ANode.HasChildNodes() then begin
|
if ANode.HasChildNodes() then begin
|
||||||
|
s := Format('%s = %s and %s = %s',[s_LOCAL_NAME,QuotedStr(s_address),s_NS_URI,QuotedStr(s_soap)]);
|
||||||
tmpCrs := CreateCursorOn(
|
tmpCrs := CreateCursorOn(
|
||||||
CreateChildrenCursor(ANode,cetRttiNode),
|
CreateChildrenCursor(ANode,cetRttiNode),
|
||||||
ParseFilter(CreateQualifiedNameFilterStr(s_address,FSoapShortNames),TDOMNodeRttiExposer)
|
ParseFilter(s,TDOMNodeRttiExposer)
|
||||||
);
|
);
|
||||||
tmpCrs.Reset();
|
tmpCrs.Reset();
|
||||||
if tmpCrs.MoveNext() then begin
|
if tmpCrs.MoveNext() then begin
|
||||||
@ -989,7 +993,7 @@ procedure TWsdlParser.ParsePort(ANode: TDOMNode);
|
|||||||
Result := False;
|
Result := False;
|
||||||
childrenCrs := CreateChildrenCursor(ABindingNode,cetRttiNode);
|
childrenCrs := CreateChildrenCursor(ABindingNode,cetRttiNode);
|
||||||
if Assigned(childrenCrs) then begin
|
if Assigned(childrenCrs) then begin
|
||||||
s := CreateQualifiedNameFilterStr(s_binding,FSoapShortNames);
|
s := Format('%s = %s and %s = %s',[s_LOCAL_NAME,QuotedStr(s_binding), s_NS_URI, QuotedStr(s_soap)]);
|
||||||
crs := CreateCursorOn(childrenCrs,ParseFilter(s,TDOMNodeRttiExposer));
|
crs := CreateCursorOn(childrenCrs,ParseFilter(s,TDOMNodeRttiExposer));
|
||||||
crs.Reset();
|
crs.Reset();
|
||||||
if crs.MoveNext() then begin
|
if crs.MoveNext() then begin
|
||||||
@ -1086,9 +1090,10 @@ var
|
|||||||
Inc(in_out_count);
|
Inc(in_out_count);
|
||||||
nd := (tmpCrs.GetCurrent() as TDOMNodeRttiExposer).InnerObject;
|
nd := (tmpCrs.GetCurrent() as TDOMNodeRttiExposer).InnerObject;
|
||||||
if nd.HasChildNodes() then begin
|
if nd.HasChildNodes() then begin
|
||||||
|
strBuffer := Format('%s = %s and %s = %s',[s_LOCAL_NAME,QuotedStr(s_body),s_NS_URI,QuotedStr(s_soap)]);
|
||||||
tmpSoapCrs := CreateCursorOn(
|
tmpSoapCrs := CreateCursorOn(
|
||||||
CreateChildrenCursor(nd,cetRttiNode),
|
CreateChildrenCursor(nd,cetRttiNode),
|
||||||
ParseFilter(CreateQualifiedNameFilterStr(s_body,FSoapShortNames),TDOMNodeRttiExposer)
|
ParseFilter(strBuffer,TDOMNodeRttiExposer)
|
||||||
);
|
);
|
||||||
tmpSoapCrs.Reset();
|
tmpSoapCrs.Reset();
|
||||||
if tmpSoapCrs.MoveNext() then begin
|
if tmpSoapCrs.MoveNext() then begin
|
||||||
@ -1121,17 +1126,17 @@ var
|
|||||||
var
|
var
|
||||||
nd : TDOMNode;
|
nd : TDOMNode;
|
||||||
tmpCrs : IObjectCursor;
|
tmpCrs : IObjectCursor;
|
||||||
//s : string;
|
locStrBuffer : string;
|
||||||
//ws : widestring;
|
|
||||||
begin
|
begin
|
||||||
ws := '';
|
ws := '';
|
||||||
s := SymbolTable.GetExternalName(AOp);
|
s := SymbolTable.GetExternalName(AOp);
|
||||||
ws := s;
|
ws := s;
|
||||||
nd := FindNamedNode(ABndngOpCurs,ws);
|
nd := FindNamedNode(ABndngOpCurs,ws);
|
||||||
if Assigned(nd) and nd.HasChildNodes() then begin
|
if Assigned(nd) and nd.HasChildNodes() then begin
|
||||||
|
locStrBuffer := Format('%s = %s and %s = %s',[s_LOCAL_NAME,QuotedStr(s_operation),s_NS_URI,QuotedStr(s_soap)]);
|
||||||
tmpCrs := CreateCursorOn(
|
tmpCrs := CreateCursorOn(
|
||||||
CreateChildrenCursor(nd,cetRttiNode),
|
CreateChildrenCursor(nd,cetRttiNode),
|
||||||
ParseFilter(CreateQualifiedNameFilterStr(s_operation,FSoapShortNames),TDOMNodeRttiExposer)
|
ParseFilter(locStrBuffer,TDOMNodeRttiExposer)
|
||||||
);
|
);
|
||||||
tmpCrs.Reset();
|
tmpCrs.Reset();
|
||||||
if tmpCrs.MoveNext() then begin
|
if tmpCrs.MoveNext() then begin
|
||||||
|
@ -26,10 +26,12 @@ type
|
|||||||
function CreateDoc() : TXMLDocument ;
|
function CreateDoc() : TXMLDocument ;
|
||||||
procedure WriteXML(Element: TDOMNode; const AFileName: String);overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
procedure WriteXML(Element: TDOMNode; const AFileName: String);overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
||||||
procedure WriteXML(Element: TDOMNode; AStream: TStream); overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
procedure WriteXML(Element: TDOMNode; AStream: TStream); overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
||||||
|
function ReadXMLFile(AStream : TStream) : TXMLDocument;overload;
|
||||||
procedure WriteXMLFile(doc: TXMLDocument; const AFileName: String); overload;
|
procedure WriteXMLFile(doc: TXMLDocument; const AFileName: String); overload;
|
||||||
procedure WriteXMLFile(ADoc : TXMLDocument; AStream : TStream);overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
procedure WriteXMLFile(ADoc : TXMLDocument; AStream : TStream);overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
||||||
procedure ReadXMLFile(out ADoc : TXMLDocument; AStream : TStream);overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
procedure ReadXMLFile(out ADoc : TXMLDocument; AStream : TStream);overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
||||||
procedure ReadXMLFile(out ADoc: TXMLDocument; const AFilename: String);overload;
|
procedure ReadXMLFile(out ADoc: TXMLDocument; const AFilename: String);overload;
|
||||||
|
function ReadXMLFile(const AFilename: String) : TXMLDocument;overload;
|
||||||
function NodeToBuffer(ANode : TDOMNode):string ;
|
function NodeToBuffer(ANode : TDOMNode):string ;
|
||||||
|
|
||||||
function FilterList(const ALIst : IDOMNodeList; const ANodeName : DOMString):IDOMNodeList;overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
function FilterList(const ALIst : IDOMNodeList; const ANodeName : DOMString):IDOMNodeList;overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
||||||
@ -97,6 +99,11 @@ begin
|
|||||||
(ADoc as IDOMPersist).loadFromStream(AStream);
|
(ADoc as IDOMPersist).loadFromStream(AStream);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ReadXMLFile(AStream : TStream) : TXMLDocument;
|
||||||
|
begin
|
||||||
|
ReadXMLFile(Result,AStream);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure ReadXMLFile(out ADoc: TXMLDocument; const AFilename: String);
|
procedure ReadXMLFile(out ADoc: TXMLDocument; const AFilename: String);
|
||||||
var
|
var
|
||||||
FileStream: TStream;
|
FileStream: TStream;
|
||||||
@ -110,6 +117,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ReadXMLFile(const AFilename: String) : TXMLDocument;
|
||||||
|
begin
|
||||||
|
ReadXMLFile(Result, AFilename);
|
||||||
|
end;
|
||||||
|
|
||||||
function GetNodeItemsCount(const ANode : TDOMNode): Integer;
|
function GetNodeItemsCount(const ANode : TDOMNode): Integer;
|
||||||
begin
|
begin
|
||||||
if ANode.HasChildNodes then begin
|
if ANode.HasChildNodes then begin
|
||||||
|
@ -38,9 +38,12 @@ type
|
|||||||
procedure ReleaseDomNode(ADomNode : TDOMNodeList);overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
procedure ReleaseDomNode(ADomNode : TDOMNodeList);overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
||||||
procedure ReleaseDomNode(ADomNode : TDOMNamedNodeMap);overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
procedure ReleaseDomNode(ADomNode : TDOMNamedNodeMap);overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
||||||
function CreateDoc() : TXMLDocument ;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
function CreateDoc() : TXMLDocument ;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
||||||
|
function ReadXMLFile(AFileName : string) : TXMLDocument;overload;
|
||||||
|
function ReadXMLFile(AStreeam : TStream) : TXMLDocument;overload;
|
||||||
function FindNode(ANode : TDOMNode;const ANodeName : string) : TDOMNode;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
function FindNode(ANode : TDOMNode;const ANodeName : string) : TDOMNode;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
||||||
|
|
||||||
function NodeToBuffer(ANode : TDOMNode):string ;
|
function NodeToBuffer(ANode : TDOMNode):string ;
|
||||||
|
|
||||||
|
|
||||||
resourcestring
|
resourcestring
|
||||||
SERR_NoNodeXpathExpression = 'This XPath expression does not correspond to node(s) : %s.';
|
SERR_NoNodeXpathExpression = 'This XPath expression does not correspond to node(s) : %s.';
|
||||||
@ -48,7 +51,34 @@ resourcestring
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses
|
uses
|
||||||
XMLWrite, xpath;
|
XMLWrite, XMLRead, xpath;
|
||||||
|
|
||||||
|
function ReadXMLFile(AStreeam : TStream) : TXMLDocument;
|
||||||
|
begin
|
||||||
|
ReadXMLFile(Result,AStreeam);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ReadXMLFile(AFileName : string) : TXMLDocument;
|
||||||
|
var
|
||||||
|
p : TDOMParser;
|
||||||
|
s : TXMLInputSource;
|
||||||
|
st : TMemoryStream;
|
||||||
|
begin
|
||||||
|
s := nil;
|
||||||
|
p := nil;
|
||||||
|
st := TMemoryStream.Create();
|
||||||
|
try
|
||||||
|
st.LoadFromFile(AFileName);
|
||||||
|
s := TXMLInputSource.Create(st);
|
||||||
|
p := TDOMParser.Create();
|
||||||
|
p.Options.Namespaces := True;
|
||||||
|
p.Parse(s,Result);
|
||||||
|
finally
|
||||||
|
p.Free();
|
||||||
|
s.Free();
|
||||||
|
st.Free();
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function GetNodeItemsCount(const ANode : TDOMNode): Integer;
|
function GetNodeItemsCount(const ANode : TDOMNode): Integer;
|
||||||
var
|
var
|
||||||
|
@ -30,8 +30,10 @@ uses
|
|||||||
|
|
||||||
const
|
const
|
||||||
|
|
||||||
s_NODE_NAME = 'NodeName';
|
s_LOCAL_NAME = 'LocalName';
|
||||||
|
s_NODE_NAME = 'NodeName';
|
||||||
s_NODE_VALUE = 'NodeValue';
|
s_NODE_VALUE = 'NodeValue';
|
||||||
|
s_NS_URI = 'NamespaceURI';
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -93,6 +95,8 @@ type
|
|||||||
TDOMNodeRttiExposer = class(TPersistent)
|
TDOMNodeRttiExposer = class(TPersistent)
|
||||||
private
|
private
|
||||||
FInnerObject: TDOMNode;
|
FInnerObject: TDOMNode;
|
||||||
|
function GetLocalName : DOMString;
|
||||||
|
function GetNamespaceURI : DOMString;
|
||||||
function GetNodeName: DOMString;
|
function GetNodeName: DOMString;
|
||||||
function GetNodeValue: DOMString;
|
function GetNodeValue: DOMString;
|
||||||
procedure SetInnerObject(const AValue: TDOMNode);
|
procedure SetInnerObject(const AValue: TDOMNode);
|
||||||
@ -102,6 +106,8 @@ type
|
|||||||
published
|
published
|
||||||
property NodeName: DOMString read GetNodeName;
|
property NodeName: DOMString read GetNodeName;
|
||||||
property NodeValue: DOMString read GetNodeValue;
|
property NodeValue: DOMString read GetNodeValue;
|
||||||
|
property LocalName : DOMString read GetLocalName;
|
||||||
|
property NamespaceURI : DOMString read GetNamespaceURI;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TDOMNodeRttiExposerCursor }
|
{ TDOMNodeRttiExposerCursor }
|
||||||
@ -255,6 +261,16 @@ begin
|
|||||||
Result := InnerObject.NodeName;
|
Result := InnerObject.NodeName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TDOMNodeRttiExposer.GetLocalName : DOMString;
|
||||||
|
begin
|
||||||
|
Result := InnerObject.LocalName;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TDOMNodeRttiExposer.GetNamespaceURI : DOMString;
|
||||||
|
begin
|
||||||
|
Result := InnerObject.NamespaceURI;
|
||||||
|
end;
|
||||||
|
|
||||||
function TDOMNodeRttiExposer.GetNodeValue: DOMString;
|
function TDOMNodeRttiExposer.GetNodeValue: DOMString;
|
||||||
begin
|
begin
|
||||||
Result := InnerObject.NodeValue;
|
Result := InnerObject.NodeValue;
|
||||||
|
Reference in New Issue
Block a user