Skip to content

Commit

Permalink
git-svn-id: svn://svn.code.sf.net/p/indysoap/code-0/trunk@16 75be9796…
Browse files Browse the repository at this point in the history
…-0ac5-4f83-a77f-cba69ea37c88
  • Loading branch information
grahamegrieve committed Jun 13, 2013
1 parent e0f2709 commit 955b65f
Showing 1 changed file with 38 additions and 9 deletions.
47 changes: 38 additions & 9 deletions source/IdSoapXML.pas
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,13 @@
GMsXmlProgId_FTDOM : String;
GMsXmlProgId_SCHEMA : String;
GMsXmlProgId_XSLT : String;
GMsXmlProgId_XSLP : String;
GMsXmlProgId_SAX : String;


Procedure DetermineMsXmlProgId;
Function LoadMsXMLDom : IXMLDomDocument2;
Function LoadMsXMLDomV : Variant;
Function LoadMsXMLDomV(isFree : boolean = false) : Variant;

{=== MSXML =================================================================}

Expand All @@ -314,6 +316,8 @@
TIdSoapMSXmlDom = Class (TIdSoapXmlDom)
Private
FDom : IXMLDomDocument2;
FSchemas: IXMLDOMSchemaCollection;
FParseError : IXMLDOMParseError;
Procedure IterateChildren(AElem : TIdSoapMSXmlElement);
Protected
Procedure Clear; Override;
Expand All @@ -323,6 +327,10 @@
Procedure writeUTF16(ADest : TStream; ANoXMLDec : Boolean = False); Override;
Procedure writeUTF8(ADest : TStream; ANoXMLDec : Boolean = False); Override;
Function ImportElement(AElem : TIdSoapXmlElement) : TIdSoapXmlElement; Override;

Property schemas : IXMLDOMSchemaCollection read FSchemas write FSchemas;
Property ParseError : IXMLDOMParseError read FParseError write FParseError;
Property Impl : IXMLDomDocument2 read FDom;
End;

TIdSoapMSXmlElement = Class (TIdSoapXmlElement)
Expand Down Expand Up @@ -1246,6 +1254,8 @@ procedure TIdSoapOpenXmlElement.appendComment(source: String);
GMsXmlProgId_FTDOM := 'MSXML2.FreeThreadedDOMDocument'+sId;
GMsXmlProgId_SCHEMA := 'MSXML2.XMLSchemaCache'+sId;
GMsXmlProgId_XSLT := 'MSXML2.XSLTemplate'+sId;
GMsXmlProgId_XSLP := 'MSXML2.XSLProcessor'+sId;
GMsXmlProgId_SAX := 'MSXML2.SAXXMLReader'+sId;
End;
End;
End;
Expand All @@ -1268,11 +1278,14 @@ procedure TIdSoapOpenXmlElement.appendComment(source: String);
Result := IUnknown(TVarData(LVariant).VDispatch) as IXMLDomDocument2;
End;

Function LoadMsXMLDomV : Variant;
Function LoadMsXMLDomV(isFree : boolean = false) : Variant;
Begin
if GMsXmlProgId_DOM = '' Then
Raise Exception.Create('Unable to load Microsoft XML Services');
Result := CreateOleObject(GMsXmlProgId_DOM);
if isFree then
Result := CreateOleObject(GMsXmlProgId_FTDOM)
else
Result := CreateOleObject(GMsXmlProgId_DOM);
End;


Expand Down Expand Up @@ -1322,18 +1335,34 @@ procedure TIdSoapOpenXmlElement.appendComment(source: String);
Const ASSERT_LOCATION = ASSERT_UNIT+'.TIdSoapMSXmlDom.Read';
Var
LAdapter : Variant;
ok : boolean;
Begin
Assert(Self.TestValid(TIdSoapMSXmlDom), ASSERT_LOCATION+': self is not valid');
FDom := LoadMsXmlDom;
FDom.validateOnParse := False;
FDom.preserveWhiteSpace := True;
FDom.setProperty('NewParser', True);
FDom.schemas := FSchemas;
if Fschemas <> nil then
FDom.validateOnParse := true
else
FDom.validateOnParse := False;
LAdapter := TStreamAdapter.Create(ASource) As IStream;
Assert(FDom.load(LAdapter), ASSERT_LOCATION+': xml load failed: '+FDom.parseError.reason);
Assert(Assigned(FDom.documentElement), ASSERT_LOCATION+': document could not be parsed');
FDom.documentElement.normalize;
FRoot := TIdSoapMSXmlElement.Create(Self, Nil, FDom.documentElement);
IterateChildren(FRoot As TIdSoapMSXmlElement);
ok := FDom.load(LAdapter);
if schemas = nil then
begin
Assert(ok, ASSERT_LOCATION+': xml load failed: '+FDom.parseError.reason);
Assert(Assigned(FDom.documentElement), ASSERT_LOCATION+': document could not be parsed');
end
else
ParseError := FDom.ParseError;
if Assigned(FDom.documentElement) then
begin
FDom.documentElement.normalize;
FRoot := TIdSoapMSXmlElement.Create(Self, Nil, FDom.documentElement);
IterateChildren(FRoot As TIdSoapMSXmlElement);
end
else
FRoot := nil;
End;

Procedure TIdSoapMSXmlDom.StartBuild(AName, ANS: String);
Expand Down

0 comments on commit 955b65f

Please sign in to comment.