Added: support for multiple namespaces in the generated binding
This commit is contained in:
parent
23d6e7e18e
commit
8a5fa4af6d
@ -70,9 +70,10 @@ type
|
||||
procedure WriteValidate(AStream: TStreamHelper; AItem: TXMLDataBindingInterface; ASection: TDelphiXMLSection);
|
||||
|
||||
function GetDelphiNodeType(AProperty: TXMLDataBindingProperty): TDelphiNodeType;
|
||||
function DataTypeConversion(const ADestination, ASource: String; ADataType: IXMLTypeDef; AAccessor: TDelphiAccessor; ANodeType: TDelphiNodeType; const ALinesBefore: String = ''): String;
|
||||
function XMLToNativeDataType(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ALinesBefore: String = ''): String;
|
||||
function NativeDataTypeToXML(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ALinesBefore: String = ''): String;
|
||||
function GetDelphiElementType(AProperty: TXMLDataBindingProperty): TDelphiElementType;
|
||||
function DataTypeConversion(const ADestination, ASource: String; ADataType: IXMLTypeDef; AAccessor: TDelphiAccessor; ANodeType: TDelphiNodeType; const ATargetNamespace: string; const ALinesBefore: String = ''): String;
|
||||
function XMLToNativeDataType(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ATargetNamespace: string; const ALinesBefore: String = ''): String;
|
||||
function NativeDataTypeToXML(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ATargetNamespace: string; const ALinesBefore: String = ''): String;
|
||||
|
||||
property ProcessedItems: TX2OIHash read FProcessedItems;
|
||||
property UnitNames: TX2OSHash read FUnitNames;
|
||||
@ -417,6 +418,7 @@ begin
|
||||
hasItem := False;
|
||||
nameSpace := '';
|
||||
|
||||
// #ToDo1 -oMvR: 6-4-2012: bij de Hyundai XSD's wordt hiermee TargetNamespace incorrect de laatste schema namespace
|
||||
for schemaIndex := 0 to Pred(ASchemaList.Count) do
|
||||
begin
|
||||
schema := ASchemaList[schemaIndex];
|
||||
@ -751,9 +753,17 @@ begin
|
||||
if ASection = dxsImplementation then
|
||||
begin
|
||||
if propertyItem.PropertyType = ptItem then
|
||||
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<ItemSourceName>:s'', %<ItemClass>:s);',
|
||||
['ItemSourceName', propertyItem.Name,
|
||||
'ItemClass', GetDataTypeName(propertyItem, False)]);
|
||||
begin
|
||||
if propertyItem.HasTargetNamespace then
|
||||
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<ItemSourceName>:s'', %<ItemClass>:s, ''%<Namespace>:s'');',
|
||||
['ItemSourceName', propertyItem.Name,
|
||||
'ItemClass', GetDataTypeName(propertyItem, False),
|
||||
'Namespace', propertyItem.TargetNamespace])
|
||||
else
|
||||
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<ItemSourceName>:s'', %<ItemClass>:s);',
|
||||
['ItemSourceName', propertyItem.Name,
|
||||
'ItemClass', GetDataTypeName(propertyItem, False)]);
|
||||
end;
|
||||
|
||||
AStream.WriteLnNamedFmt(' %<FieldName>:s := CreateCollection(%<CollectionClass>:s, %<ItemInterface>:s, ''%<ItemSourceName>:s'') as %<CollectionInterface>:s;',
|
||||
['FieldName', PrefixField + propertyItem.TranslatedName,
|
||||
@ -782,9 +792,16 @@ begin
|
||||
dxsImplementation:
|
||||
begin
|
||||
WritePrototype;
|
||||
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<SourceName>:s'', TXML%<Name>:s);',
|
||||
['SourceName', propertyItem.Name,
|
||||
'Name', itemProperty.Item.TranslatedName]);
|
||||
|
||||
if propertyItem.HasTargetNamespace then
|
||||
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<SourceName>:s'', TXML%<Name>:s, ''%<Namespace>:s'');',
|
||||
['SourceName', propertyItem.Name,
|
||||
'Name', itemProperty.Item.TranslatedName,
|
||||
'Namespace', propertyItem.TargetNamespace])
|
||||
else
|
||||
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<SourceName>:s'', TXML%<Name>:s);',
|
||||
['SourceName', propertyItem.Name,
|
||||
'Name', itemProperty.Item.TranslatedName]);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -799,9 +816,16 @@ begin
|
||||
if ASection = dxsImplementation then
|
||||
begin
|
||||
WritePrototype;
|
||||
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<SourceName>:s'', %<DataClass>:s);',
|
||||
['SourceName', AItem.CollectionItem.Name,
|
||||
'DataClass', GetDataTypeName(AItem.CollectionItem, False)]);
|
||||
if AItem.CollectionItem.HasTargetNamespace then
|
||||
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<SourceName>:s'', %<DataClass>:s, ''%<Namespace>:s'');',
|
||||
['SourceName', AItem.CollectionItem.Name,
|
||||
'DataClass', GetDataTypeName(AItem.CollectionItem, False),
|
||||
'Namespace', AItem.CollectionItem.TargetNamespace])
|
||||
else
|
||||
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<SourceName>:s'', %<DataClass>:s);',
|
||||
['SourceName', AItem.CollectionItem.Name,
|
||||
'DataClass', GetDataTypeName(AItem.CollectionItem, False)]);
|
||||
|
||||
AStream.WriteLn;
|
||||
AStream.WriteLnFmt(' ItemTag := ''%s'';', [AItem.CollectionItem.Name]);
|
||||
AStream.WriteLnFmt(' ItemInterface := %s;', [GetDataTypeName(AItem.CollectionItem, True)]);
|
||||
@ -962,9 +986,9 @@ begin
|
||||
sourceCode.Add('function TXML%<Name>:s.Get_%<ItemName>:s(Index: Integer): %<DataType>:s;');
|
||||
|
||||
if GetDataTypeMapping(typeDef, typeMapping) and (typeMapping.Conversion = tcString) then
|
||||
sourceCode.Add(XMLToNativeDataType('Result', 'List[Index].Text', typeDef, dntCustom))
|
||||
sourceCode.Add(XMLToNativeDataType('Result', 'List[Index].Text', typeDef, dntCustom, AItem.CollectionItem.TargetNamespace))
|
||||
else
|
||||
sourceCode.Add(XMLToNativeDataType('Result', 'List[Index].NodeValue', typeDef, dntCustom));
|
||||
sourceCode.Add(XMLToNativeDataType('Result', 'List[Index].NodeValue', typeDef, dntCustom, AItem.CollectionItem.TargetNamespace));
|
||||
|
||||
sourceCode.AddLn;
|
||||
|
||||
@ -1181,16 +1205,16 @@ begin
|
||||
if AProperty.IsAttribute then
|
||||
sourceCode.Add(PropertyImplMethodGetOptionalAttr)
|
||||
else
|
||||
sourceCode.Add(PropertyImplMethodGetOptional);
|
||||
sourceCode.Add(PropertyImplMethodGetOptional[GetDelphiElementType(AProperty)]);
|
||||
|
||||
if writeNil then
|
||||
sourceCode.Add(PropertyImplMethodGetNil);
|
||||
sourceCode.Add(PropertyImplMethodGetNil[GetDelphiElementType(AProperty)]);
|
||||
|
||||
if writeTextProp then
|
||||
if AProperty.IsAttribute then
|
||||
sourceCode.Add(PropertyImplMethodGetTextAttr)
|
||||
else
|
||||
sourceCode.Add(PropertyImplMethodGetText);
|
||||
sourceCode.Add(PropertyImplMethodGetText[GetDelphiElementType(AProperty)]);
|
||||
|
||||
sourceCode.Add('function TXML%<Name>:s.Get%<PropertyName>:s: %<DataType>:s;');
|
||||
|
||||
@ -1205,7 +1229,8 @@ begin
|
||||
sourceCode.Add(XMLToNativeDataType('Result',
|
||||
'%<PropertySourceName>:s',
|
||||
TXMLDataBindingSimpleProperty(AProperty).DataType,
|
||||
GetDelphiNodeType(AProperty)));
|
||||
GetDelphiNodeType(AProperty),
|
||||
AProperty.TargetNamespace));
|
||||
|
||||
ptItem:
|
||||
begin
|
||||
@ -1222,7 +1247,12 @@ begin
|
||||
itInterface:
|
||||
begin
|
||||
sourceCode.Add('begin');
|
||||
sourceCode.Add(' Result := (ChildNodes[''%<PropertySourceName>:s''] as IXML%<PropertyItemName>:s);');
|
||||
|
||||
if AProperty.HasTargetNamespace then
|
||||
sourceCode.Add(' Result := (ChildNodes.FindNode(''%<PropertySourceName>:s'', ''%<Namespace>:s'') as IXML%<PropertyItemName>:s);')
|
||||
else
|
||||
sourceCode.Add(' Result := (ChildNodes[''%<PropertySourceName>:s''] as IXML%<PropertyItemName>:s);');
|
||||
|
||||
sourceCode.Add('end;');
|
||||
end;
|
||||
|
||||
@ -1246,13 +1276,13 @@ begin
|
||||
WriteNewLine;
|
||||
|
||||
if writeNil then
|
||||
sourceCode.Add(PropertyImplMethodSetNil);
|
||||
sourceCode.Add(PropertyImplMethodSetNil[GetDelphiElementType(AProperty)]);
|
||||
|
||||
if writeTextProp then
|
||||
if AProperty.IsAttribute then
|
||||
sourceCode.Add(PropertyImplMethodSetTextAttr)
|
||||
else
|
||||
sourceCode.Add(PropertyImplMethodSetText);
|
||||
sourceCode.Add(PropertyImplMethodSetText[GetDelphiElementType(AProperty)]);
|
||||
|
||||
sourceCode.Add('procedure TXML%<Name>:s.Set%<PropertyName>:s(const Value: %<DataType>:s);');
|
||||
value := '%<PropertySourceName>:s';
|
||||
@ -1260,7 +1290,8 @@ begin
|
||||
if Assigned(propertyItem) and (propertyItem.ItemType = itEnumeration) then
|
||||
begin
|
||||
sourceCode.Add(NativeDataTypeToXML(value, '%<PropertyItemName>:sValues[Value]', nil,
|
||||
GetDelphiNodeType(AProperty)));
|
||||
GetDelphiNodeType(AProperty),
|
||||
AProperty.TargetNamespace));
|
||||
end else
|
||||
begin
|
||||
if AProperty.PropertyType <> ptSimple then
|
||||
@ -1268,7 +1299,8 @@ begin
|
||||
|
||||
sourceCode.Add(NativeDataTypeToXML(value, 'Value',
|
||||
TXMLDataBindingSimpleProperty(AProperty).DataType,
|
||||
GetDelphiNodeType(AProperty)));
|
||||
GetDelphiNodeType(AProperty),
|
||||
AProperty.TargetNamespace));
|
||||
end;
|
||||
|
||||
sourceCode.AddLn;
|
||||
@ -1288,7 +1320,8 @@ begin
|
||||
'PropertyName', AProperty.TranslatedName,
|
||||
'PropertyItemName', propertyItemName,
|
||||
'DataType', dataTypeName,
|
||||
'FieldName', fieldName]));
|
||||
'FieldName', fieldName,
|
||||
'Namespace', AProperty.TargetNamespace]));
|
||||
finally
|
||||
FreeAndNil(sourceCode);
|
||||
end;
|
||||
@ -1482,12 +1515,24 @@ begin
|
||||
Result := dntAttribute
|
||||
else if AProperty.IsNodeValue then
|
||||
Result := dntNodeValue
|
||||
else if AProperty.HasTargetNamespace then
|
||||
Result := dntElementNS
|
||||
else
|
||||
Result := dntElement;
|
||||
end;
|
||||
|
||||
|
||||
function TDelphiXMLDataBindingGenerator.DataTypeConversion(const ADestination, ASource: String; ADataType: IXMLTypeDef; AAccessor: TDelphiAccessor; ANodeType: TDelphiNodeType; const ALinesBefore: String = ''): String;
|
||||
function TDelphiXMLDataBindingGenerator.GetDelphiElementType(AProperty: TXMLDataBindingProperty): TDelphiElementType;
|
||||
begin
|
||||
Result := GetDelphiNodeType(AProperty);
|
||||
if Result <> dntElementNS then
|
||||
Result := dntElement;
|
||||
end;
|
||||
|
||||
|
||||
function TDelphiXMLDataBindingGenerator.DataTypeConversion(const ADestination, ASource: String; ADataType: IXMLTypeDef;
|
||||
AAccessor: TDelphiAccessor; ANodeType: TDelphiNodeType;
|
||||
const ATargetNamespace: string; const ALinesBefore: String = ''): String;
|
||||
var
|
||||
typeMapping: TTypeMapping;
|
||||
conversion: String;
|
||||
@ -1513,23 +1558,29 @@ begin
|
||||
Add(conversion);
|
||||
Add('end;');
|
||||
|
||||
// #ToDo1 -oMvR: 6-4-2012: Namespace
|
||||
Result := Trim(Format(['Destination', ADestination,
|
||||
'Source', ASource]));
|
||||
'Source', ASource,
|
||||
'Namespace', ATargetNamespace]));
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function TDelphiXMLDataBindingGenerator.XMLToNativeDataType(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ALinesBefore: String): String;
|
||||
function TDelphiXMLDataBindingGenerator.XMLToNativeDataType(const ADestination, ASource: String; ADataType: IXMLTypeDef;
|
||||
ANodeType: TDelphiNodeType; const ATargetNamespace: string;
|
||||
const ALinesBefore: String): String;
|
||||
begin
|
||||
Result := DataTypeConversion(ADestination, ASource, ADataType, daGet, ANodeType, ALinesBefore);
|
||||
Result := DataTypeConversion(ADestination, ASource, ADataType, daGet, ANodeType, ATargetNamespace, ALinesBefore);
|
||||
end;
|
||||
|
||||
|
||||
function TDelphiXMLDataBindingGenerator.NativeDataTypeToXML(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ALinesBefore: String): String;
|
||||
function TDelphiXMLDataBindingGenerator.NativeDataTypeToXML(const ADestination, ASource: String; ADataType: IXMLTypeDef;
|
||||
ANodeType: TDelphiNodeType; const ATargetNamespace: string;
|
||||
const ALinesBefore: String): String;
|
||||
begin
|
||||
Result := DataTypeConversion(ADestination, ASource, ADataType, daSet, ANodeType, ALinesBefore);
|
||||
Result := DataTypeConversion(ADestination, ASource, ADataType, daSet, ANodeType, ATargetNamespace, ALinesBefore);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -1,11 +1,14 @@
|
||||
unit DelphiXMLDataBindingResources;
|
||||
|
||||
// #ToDo1 -oMvR: 6-4-2012: namespace support voor attributes
|
||||
|
||||
interface
|
||||
type
|
||||
TDelphiXMLSection = (dxsForward, dxsInterface, dxsClass, dxsImplementation);
|
||||
TDelphiXMLMember = (dxmPropertyGet, dxmPropertySet, dxmPropertyDeclaration);
|
||||
TDelphiAccessor = (daGet, daSet);
|
||||
TDelphiNodeType = (dntElement, dntAttribute, dntNodeValue, dntCustom);
|
||||
TDelphiNodeType = (dntElement, dntElementNS, dntAttribute, dntNodeValue, dntCustom);
|
||||
TDelphiElementType = dntElement..dntElementNS;
|
||||
|
||||
|
||||
const
|
||||
@ -111,11 +114,22 @@ const
|
||||
PropertyInterfaceText = ' property %<PropertyName>:sText: WideString read Get%<PropertyName>:sText write Set%<PropertyName>:sText;';
|
||||
PropertyInterface = ' property %<PropertyName>:s: %<DataType>:s read Get%<PropertyName>:s write Set%<PropertyName>:s;';
|
||||
|
||||
PropertyImplMethodGetOptional = 'function TXML%<Name>:s.GetHas%<PropertyName>:s: Boolean;' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' Result := Assigned(ChildNodes.FindNode(''%<PropertySourceName>:s''));' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf;
|
||||
PropertyImplMethodGetOptional: array[TDelphiElementType] of string =
|
||||
(
|
||||
{ dntElement }
|
||||
'function TXML%<Name>:s.GetHas%<PropertyName>:s: Boolean;' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' Result := Assigned(ChildNodes.FindNode(''%<PropertySourceName>:s''));' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf,
|
||||
|
||||
{ dntElementNS }
|
||||
'function TXML%<Name>:s.GetHas%<PropertyName>:s: Boolean;' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' Result := Assigned(ChildNodes.FindNode(''%<PropertySourceName>:s'', ''%<Namespace>:s''));' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf
|
||||
);
|
||||
|
||||
PropertyImplMethodGetOptionalAttr = 'function TXML%<Name>:s.GetHas%<PropertyName>:s: Boolean;' + CrLf +
|
||||
'begin' + CrLf +
|
||||
@ -123,23 +137,56 @@ const
|
||||
'end;' + CrLf +
|
||||
'' + CrLf;
|
||||
|
||||
PropertyImplMethodGetNil = 'function TXML%<Name>:s.Get%<PropertyName>:sIsNil: Boolean;' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' Result := GetNodeIsNil(ChildNodes[''%<PropertySourceName>:s'']);' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf;
|
||||
PropertyImplMethodGetNil: array[TDelphiElementType] of string =
|
||||
(
|
||||
{ dntElement }
|
||||
'function TXML%<Name>:s.Get%<PropertyName>:sIsNil: Boolean;' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' Result := GetNodeIsNil(ChildNodes[''%<PropertySourceName>:s'']);' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf,
|
||||
|
||||
PropertyImplMethodSetNil = 'procedure TXML%<Name>:s.Set%<PropertyName>:sIsNil(const Value: Boolean);' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' SetNodeIsNil(ChildNodes[''%<PropertySourceName>:s''], Value);' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf;
|
||||
{ dntElementNS }
|
||||
'function TXML%<Name>:s.Get%<PropertyName>:sIsNil: Boolean;' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' Result := GetNodeIsNil(ChildNodes.FindNode(''%<PropertySourceName>:s'', ''%<Namespace>:s''));' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf
|
||||
);
|
||||
|
||||
PropertyImplMethodGetText = 'function TXML%<Name>:s.Get%<PropertyName>:sText: WideString;' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' Result := ChildNodes[''%<PropertySourceName>:s''].Text;' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf;
|
||||
PropertyImplMethodSetNil: array[TDelphiElementType] of string =
|
||||
(
|
||||
{ dntElement }
|
||||
'procedure TXML%<Name>:s.Set%<PropertyName>:sIsNil(const Value: Boolean);' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' SetNodeIsNil(ChildNodes[''%<PropertySourceName>:s''], Value);' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf,
|
||||
|
||||
{ dntElementNS }
|
||||
'procedure TXML%<Name>:s.Set%<PropertyName>:sIsNil(const Value: Boolean);' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' SetNodeIsNil(ChildNodes.FindNode(''%<PropertySourceName>:s'', ''%<Namespace>:s''), Value);' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf
|
||||
);
|
||||
|
||||
PropertyImplMethodGetText: array[TDelphiElementType] of string =
|
||||
(
|
||||
{ dntElement }
|
||||
'function TXML%<Name>:s.Get%<PropertyName>:sText: WideString;' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' Result := ChildNodes[''%<PropertySourceName>:s''].Text;' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf,
|
||||
|
||||
{ dntElement }
|
||||
'function TXML%<Name>:s.Get%<PropertyName>:sText: WideString;' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' Result := ChildNodes.FindNode(''%<PropertySourceName>:s'', ''%<Namespace>:s'').Text;' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf
|
||||
);
|
||||
|
||||
PropertyImplMethodGetTextAttr = 'function TXML%<Name>:s.Get%<PropertyName>:sText: WideString;' + CrLf +
|
||||
'begin' + CrLf +
|
||||
@ -147,11 +194,22 @@ const
|
||||
'end;' + CrLf +
|
||||
'' + CrLf;
|
||||
|
||||
PropertyImplMethodSetText = 'procedure TXML%<Name>:s.Set%<PropertyName>:sText(const Value: WideString);' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' ChildNodes[''%<PropertySourceName>:s''].NodeValue := Value;' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf;
|
||||
PropertyImplMethodSetText: array[TDelphiElementType] of string =
|
||||
(
|
||||
{ dntElement }
|
||||
'procedure TXML%<Name>:s.Set%<PropertyName>:sText(const Value: WideString);' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' ChildNodes[''%<PropertySourceName>:s''].NodeValue := Value;' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf,
|
||||
|
||||
{ dntElementNS }
|
||||
'procedure TXML%<Name>:s.Set%<PropertyName>:sText(const Value: WideString);' + CrLf +
|
||||
'begin' + CrLf +
|
||||
' ChildNodes.FindNode(''%<PropertySourceName>:s'', ''%<Namespace>:s'').NodeValue := Value;' + CrLf +
|
||||
'end;' + CrLf +
|
||||
'' + CrLf
|
||||
);
|
||||
|
||||
PropertyImplMethodSetTextAttr = 'procedure TXML%<Name>:s.Set%<PropertyName>:sText(const Value: WideString);' + CrLf +
|
||||
'begin' + CrLf +
|
||||
@ -272,6 +330,7 @@ const
|
||||
{ daGet }
|
||||
(
|
||||
{ dntElement } ' %<Destination>:s := ChildNodes[''%<Source>:s''].NodeValue;',
|
||||
{ dntElementNS } ' %<Destination>:s := ChildNodes.FindNode(''%<Source>:s'', ''%<Namespace>:s'').NodeValue;',
|
||||
{ dntAttribute } ' %<Destination>:s := AttributeNodes[''%<Source>:s''].NodeValue;',
|
||||
{ dntNodeValue } ' %<Destination>:s := GetNodeValue;',
|
||||
{ dntCustom } ' %<Destination>:s := %<Source>:s;'
|
||||
@ -279,6 +338,7 @@ const
|
||||
{ daSet }
|
||||
(
|
||||
{ dntElement } ' ChildNodes[''%<Destination>:s''].NodeValue := %<Source>:s;',
|
||||
{ dntElementNS } ' ChildNodes.FindNode(''%<Destination>:s'', ''%<Namespace>:s'').NodeValue := %<Source>:s;',
|
||||
{ dntAttribute } ' SetAttribute(''%<Destination>:s'', %<Source>:s);',
|
||||
{ dntNodeValue } ' SetNodeValue(%<Source>:s);',
|
||||
{ dntCustom } ' %<Destination>:s := %<Source>:s;'
|
||||
@ -301,6 +361,17 @@ const
|
||||
{ tcString } ' %<Destination>:s := ChildNodes[''%<Source>:s''].Text;',
|
||||
{ tcBas64 } ' %<Destination>:s := Base64Decode(Trim(ChildNodes[''%<Source>:s''].Text));'
|
||||
),
|
||||
{ dntElementNS }
|
||||
(
|
||||
{ tcNone } '',
|
||||
{ tcBoolean } '',
|
||||
{ tcFloat } ' %<Destination>:s := XMLToFloat(ChildNodes.FindNode(''%<Source>:s'', ''%<Namespace>:s'').NodeValue);',
|
||||
{ tcDateTime } ' %<Destination>:s := XMLToDateTime(ChildNodes.FindNode(''%<Source>:s'', ''%<Namespace>:s'').NodeValue, xdtDateTime);',
|
||||
{ tcDate } ' %<Destination>:s := XMLToDateTime(ChildNodes.FindNode(''%<Source>:s'', ''%<Namespace>:s'').NodeValue, xdtDate);',
|
||||
{ tcTime } ' %<Destination>:s := XMLToDateTime(ChildNodes.FindNode(''%<Source>:s'', ''%<Namespace>:s'').NodeValue, xdtTime);',
|
||||
{ tcString } ' %<Destination>:s := ChildNodes.FindNode(''%<Source>:s'', ''%<Namespace>:s'').Text;',
|
||||
{ tcBas64 } ' %<Destination>:s := Base64Decode(Trim(ChildNodes.FindNode(''%<Source>:s'', ''%<Namespace>:s'').Text));'
|
||||
),
|
||||
{ dntAttribute }
|
||||
(
|
||||
{ tcNone } '',
|
||||
@ -348,6 +419,17 @@ const
|
||||
{ tcString } '',
|
||||
{ tcBase64 } ' ChildNodes[''%<Destination>:s''].NodeValue := Base64Encode(%<Source>:s);'
|
||||
),
|
||||
{ dntElementNS }
|
||||
(
|
||||
{ tcNone } '',
|
||||
{ tcBoolean } ' ChildNodes.FindNode(''%<Destination>:s'', ''%<Namespace>:s'').NodeValue := BoolToXML(%<Source>:s);',
|
||||
{ tcFloat } ' ChildNodes.FindNode(''%<Destination>:s'', ''%<Namespace>:s'').NodeValue := FloatToXML(%<Source>:s);',
|
||||
{ tcDateTime } ' ChildNodes.FindNode(''%<Destination>:s'', ''%<Namespace>:s'').NodeValue := DateTimeToXML(%<Source>:s, xdtDateTime);',
|
||||
{ tcDate } ' ChildNodes.FindNode(''%<Destination>:s'', ''%<Namespace>:s'').NodeValue := DateTimeToXML(%<Source>:s, xdtDate);',
|
||||
{ tcTime } ' ChildNodes.FindNode(''%<Destination>:s'', ''%<Namespace>:s'').NodeValue := DateTimeToXML(%<Source>:s, xdtTime);',
|
||||
{ tcString } '',
|
||||
{ tcBase64 } ' ChildNodes.FindNode(''%<Destination>:s'', ''%<Namespace>:s'').NodeValue := Base64Encode(%<Source>:s);'
|
||||
),
|
||||
{ dntAttribute }
|
||||
(
|
||||
{ tcNone } '',
|
||||
|
@ -258,27 +258,32 @@ type
|
||||
|
||||
TXMLDataBindingProperty = class(TXMLDataBindingItem)
|
||||
private
|
||||
FIsAttribute: Boolean;
|
||||
FIsOptional: Boolean;
|
||||
FIsNillable: Boolean;
|
||||
FIsRepeating: Boolean;
|
||||
FIsNodeValue: Boolean;
|
||||
FCollection: TXMLDataBindingInterface;
|
||||
FTargetNamespace: string;
|
||||
FIsAttribute: Boolean;
|
||||
FIsOptional: Boolean;
|
||||
FIsNillable: Boolean;
|
||||
FIsRepeating: Boolean;
|
||||
FIsNodeValue: Boolean;
|
||||
FCollection: TXMLDataBindingInterface;
|
||||
function GetHasTargetNamespace: Boolean;
|
||||
protected
|
||||
function GetIsReadOnly: Boolean; virtual; abstract;
|
||||
|
||||
function GetItemType: TXMLDataBindingItemType; override;
|
||||
function GetPropertyType: TXMLDataBindingPropertyType; virtual; abstract;
|
||||
public
|
||||
property IsAttribute: Boolean read FIsAttribute write FIsAttribute;
|
||||
property IsOptional: Boolean read FIsOptional write FIsOptional;
|
||||
property IsNillable: Boolean read FIsNillable write FIsNillable;
|
||||
property IsReadOnly: Boolean read GetIsReadOnly;
|
||||
property IsRepeating: Boolean read FIsRepeating write FIsRepeating;
|
||||
property IsNodeValue: Boolean read FIsNodeValue write FIsNodeValue;
|
||||
property PropertyType: TXMLDataBindingPropertyType read GetPropertyType;
|
||||
property TargetNamespace: string read FTargetNamespace write FTargetNamespace;
|
||||
property IsAttribute: Boolean read FIsAttribute write FIsAttribute;
|
||||
property IsOptional: Boolean read FIsOptional write FIsOptional;
|
||||
property IsNillable: Boolean read FIsNillable write FIsNillable;
|
||||
property IsReadOnly: Boolean read GetIsReadOnly;
|
||||
property IsRepeating: Boolean read FIsRepeating write FIsRepeating;
|
||||
property IsNodeValue: Boolean read FIsNodeValue write FIsNodeValue;
|
||||
property PropertyType: TXMLDataBindingPropertyType read GetPropertyType;
|
||||
|
||||
property Collection: TXMLDataBindingInterface read FCollection write FCollection;
|
||||
property Collection: TXMLDataBindingInterface read FCollection write FCollection;
|
||||
|
||||
property HasTargetNamespace: Boolean read GetHasTargetNamespace;
|
||||
end;
|
||||
|
||||
|
||||
@ -982,6 +987,7 @@ var
|
||||
actualElement: IXMLElementDef;
|
||||
propertyType: TXMLDataBindingItem;
|
||||
propertyItem: TXMLDataBindingProperty;
|
||||
namespace: string;
|
||||
|
||||
begin
|
||||
propertyType := ProcessElement(ASchema, AElement);
|
||||
@ -997,6 +1003,10 @@ begin
|
||||
AElement.Name,
|
||||
AElement.DataType);
|
||||
|
||||
namespace := AElement.SchemaDef.TargetNamespace;
|
||||
if namespace <> Schemas[0].TargetNamespace then
|
||||
propertyItem.TargetNamespace := namespace;
|
||||
|
||||
propertyItem.IsOptional := IsElementOptional(AElement) or
|
||||
IsChoice(AElement);
|
||||
propertyItem.IsRepeating := IsElementRepeating(AElement);
|
||||
@ -1020,6 +1030,7 @@ procedure TXMLDataBindingGenerator.ProcessAttribute(ASchema: TXMLDataBindingSche
|
||||
var
|
||||
propertyItem: TXMLDataBindingProperty;
|
||||
propertyType: TXMLDataBindingItem;
|
||||
namespace: string;
|
||||
|
||||
begin
|
||||
propertyType := ProcessElement(ASchema, AAttribute);
|
||||
@ -1033,6 +1044,10 @@ begin
|
||||
AAttribute.Name,
|
||||
AAttribute.DataType);
|
||||
|
||||
namespace := AAttribute.SchemaDef.TargetNamespace;
|
||||
if namespace <> ASchema.TargetNamespace then
|
||||
propertyItem.TargetNamespace := namespace;
|
||||
|
||||
propertyItem.IsOptional := (AAttribute.Use <> UseRequired);
|
||||
propertyItem.IsAttribute := True;
|
||||
|
||||
@ -1891,6 +1906,12 @@ end;
|
||||
|
||||
|
||||
{ TXMLDataBindingProperty }
|
||||
function TXMLDataBindingProperty.GetHasTargetNamespace: Boolean;
|
||||
begin
|
||||
Result := (Length(TargetNamespace) > 0);
|
||||
end;
|
||||
|
||||
|
||||
function TXMLDataBindingProperty.GetItemType: TXMLDataBindingItemType;
|
||||
begin
|
||||
Result := itProperty;
|
||||
@ -1910,6 +1931,7 @@ constructor TXMLDataBindingSimpleProperty.CreateFromAlias(AOwner: TXMLDataBindin
|
||||
begin
|
||||
Create(AOwner, AProperty.SchemaItem, AProperty.Name, ADataType);
|
||||
|
||||
// #ToDo1 -oMvR: 6-4-2012: iets met TargetNamespace??
|
||||
IsAttribute := AProperty.IsAttribute;
|
||||
IsOptional := AProperty.IsOptional;
|
||||
IsNillable := AProperty.IsNillable;
|
||||
|
Loading…
Reference in New Issue
Block a user