defaultElementForm, defaultAttributeForm : Runtime WSDL/XSD generation.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4233 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa
2015-07-31 13:16:03 +00:00
parent f666da77a0
commit abaae03afa
3 changed files with 48 additions and 0 deletions

View File

@ -67,6 +67,7 @@ type
RootAddress : ShortString; RootAddress : ShortString;
ServicesCount : Word; ServicesCount : Word;
Services : PService; Services : PService;
Properties : PPropertyData;
end; end;
IModuleMetadataMngr = interface IModuleMetadataMngr = interface
@ -75,6 +76,11 @@ type
function GetCount():Integer; function GetCount():Integer;
function GetRepositoryName(const AIndex : Integer):shortstring; function GetRepositoryName(const AIndex : Integer):shortstring;
procedure SetRepositoryNameSpace(const ARepName,ANameSpace : shortstring); procedure SetRepositoryNameSpace(const ARepName,ANameSpace : shortstring);
procedure SetRepositoryCustomData(
const ARepName : shortstring;
const ADataName,
AData : string
);
function LoadRepositoryName( function LoadRepositoryName(
const ARepName,ARootAddress : shortstring; const ARepName,ARootAddress : shortstring;
out ARepository : PServiceRepository out ARepository : PServiceRepository
@ -316,6 +322,8 @@ begin
end; end;
Freemem(ARepository^.Services, c * SizeOf(TService) ); Freemem(ARepository^.Services, c * SizeOf(TService) );
end; end;
if (ARepository^.Properties <> nil) then
ClearProperties(ARepository^.Properties);
Freemem(ARepository,SizeOf(TServiceRepository)); Freemem(ARepository,SizeOf(TServiceRepository));
ARepository := nil; ARepository := nil;
end; end;
@ -493,6 +501,7 @@ begin
ADest^.Name := ASource^.Name; ADest^.Name := ASource^.Name;
ADest^.NameSpace := ASource^.NameSpace; ADest^.NameSpace := ASource^.NameSpace;
ADest^.RootAddress := ASource^.RootAddress; ADest^.RootAddress := ASource^.RootAddress;
ADest^.Properties := CloneProperties(ASource^.Properties);
c := ASource^.ServicesCount; c := ASource^.ServicesCount;
if ( c > 0 ) then begin if ( c > 0 ) then begin
ADest^.Services := wst_GetMem( c * SizeOf(TService) ); ADest^.Services := wst_GetMem( c * SizeOf(TService) );
@ -531,6 +540,11 @@ type
function GetCount():Integer; function GetCount():Integer;
function GetRepositoryName(const AIndex : Integer):shortstring; function GetRepositoryName(const AIndex : Integer):shortstring;
procedure SetRepositoryNameSpace(const ARepName,ANameSpace : shortstring); procedure SetRepositoryNameSpace(const ARepName,ANameSpace : shortstring);
procedure SetRepositoryCustomData(
const ARepName : shortstring;
const ADataName,
AData : string
);
function LoadRepositoryName( function LoadRepositoryName(
const ARepName,ARootAddress : shortstring; const ARepName,ARootAddress : shortstring;
out ARepository : PServiceRepository out ARepository : PServiceRepository
@ -673,6 +687,23 @@ begin
FRepositories[i]^.NameSpace := ANameSpace; FRepositories[i]^.NameSpace := ANameSpace;
end; end;
procedure TModuleMetadataMngr.SetRepositoryCustomData(
const ARepName : shortstring;
const ADataName,
AData : string
);
var
i : Integer;
rp : PServiceRepository;
sp : PService;
begin
i := FindInnerListIndex(ARepName);
if (i < 0) then
i := InternalLoadRepository(ARepName);
rp := FRepositories[i];
Add(rp^.Properties,ADataName,AData);
end;
function TModuleMetadataMngr.LoadRepositoryName( function TModuleMetadataMngr.LoadRepositoryName(
const ARepName,ARootAddress : shortstring; const ARepName,ARootAddress : shortstring;
out ARepository : PServiceRepository out ARepository : PServiceRepository

View File

@ -178,6 +178,9 @@ const
sFORMAT_Input_EncodingStyle = 'FORMAT_Input_EncodingStyle'; sFORMAT_Input_EncodingStyle = 'FORMAT_Input_EncodingStyle';
sFORMAT_Input_EncodingStyleURI = 'FORMAT_Input_EncodingStyleURI'; sFORMAT_Input_EncodingStyleURI = 'FORMAT_Input_EncodingStyleURI';
sFORM_attributeFormDefault = 'attributeFormDefault';
sFORM_elementFormDefault = 'elementFormDefault';
var var
WsdlTypeHandlerRegistryInst : IWsdlTypeHandlerRegistry; WsdlTypeHandlerRegistryInst : IWsdlTypeHandlerRegistry;
@ -596,6 +599,7 @@ var
defNode, typesNode, schNode : TDOMElement; defNode, typesNode, schNode : TDOMElement;
i, c : Integer; i, c : Integer;
ps : PService; ps : PService;
propData : PPropertyData;
begin begin
if not ( Assigned(AMdtdRep) and Assigned(ADoc)) then if not ( Assigned(AMdtdRep) and Assigned(ADoc)) then
Exit; Exit;
@ -605,6 +609,12 @@ begin
schNode := CreateElement(sXSD + ':' + sWSDL_SCHEMA,typesNode,ADoc); schNode := CreateElement(sXSD + ':' + sWSDL_SCHEMA,typesNode,ADoc);
schNode.SetAttribute(sXMLNS,sXSD_NS); schNode.SetAttribute(sXMLNS,sXSD_NS);
schNode.SetAttribute(sWSDL_TARGET_NS,AMdtdRep^.NameSpace); schNode.SetAttribute(sWSDL_TARGET_NS,AMdtdRep^.NameSpace);
propData := Find(AMdtdRep^.Properties,sFORM_elementFormDefault);
if (propData <> nil) and (propData^.Data <> '') then
schNode.SetAttribute(sFORM_elementFormDefault,Trim(propData^.Data));
propData := Find(AMdtdRep^.Properties,sFORM_attributeFormDefault);
if (propData <> nil) and (propData^.Data <> '') then
schNode.SetAttribute(sFORM_attributeFormDefault,Trim(propData^.Data));
GenerateServiceTypes(); GenerateServiceTypes();

View File

@ -2981,6 +2981,7 @@ procedure TInftGenerator.GenerateCustomMetadatas();
var var
i : Integer; i : Integer;
s : string;
begin begin
SetCurrentStream(FImpStream); SetCurrentStream(FImpStream);
IncIndent(); IncIndent();
@ -2992,6 +2993,12 @@ begin
WriteLn('begin'); WriteLn('begin');
Indent();WriteLn('mm := GetModuleMetadataMngr();'); Indent();WriteLn('mm := GetModuleMetadataMngr();');
Indent();WriteLn('mm.SetRepositoryNameSpace(%s, %s);',[sUNIT_NAME,sNAME_SPACE]); Indent();WriteLn('mm.SetRepositoryNameSpace(%s, %s);',[sUNIT_NAME,sNAME_SPACE]);
s := Trim(SymbolTable.Properties.GetValue(SymbolTable.CurrentModule,s_elementFormDefault));
if (s <> '') then
Indent();WriteLn('mm.SetRepositoryCustomData(%s, %s, %s);',[sUNIT_NAME,QuotedStr(s_elementFormDefault),QuotedStr(s)]);
s := Trim(SymbolTable.Properties.GetValue(SymbolTable.CurrentModule,s_attributeFormDefault));
if (s <> '') then
Indent();WriteLn('mm.SetRepositoryCustomData(%s, %s, %s);',[sUNIT_NAME,QuotedStr(s_attributeFormDefault),QuotedStr(s)]);
for i := 0 to Pred(SymbolTable.BindingCount) do begin for i := 0 to Pred(SymbolTable.BindingCount) do begin
WriteServiceDatas(SymbolTable.Binding[i]); WriteServiceDatas(SymbolTable.Binding[i]);
end; end;