Für diejenigen, die nach der Lösung des Problems "XPath mit OpenXML nutzen" suchen:
Ich glaube, ich habe die Antwort von dem Author von OpenXML gefunden (in den Beispielen zu der 5.1 Version von ADOMCore)
Delphi-Quellcode:
// The XPath data model is based on XML Namespaces (cf. the introduction to
// the XPath spec. available at "http://www.w3.org"). XML Namespace
// conformance can only fully be checked by validating a document (cf. sec. 6
// of the "Namespaces in XML" spec. also available at "http://www.w3.org").
// Therefore, we use a four step process here:
// 1. Parse the document into a "normal" XML tree.
// 2. Validate it.
// 3. Parse the "normal" document tree into a namespace-aware document tree.
// 4. Validate the namespace-aware object tree.
// NB: a) Since the XPath data model is based on XML Namespaces, XPath
// works only with namespace-aware document trees.
// b) Since the XPath data model does not include a document type
// declaration node, the XmlDocBuilder.KeepDocumentTypeDecl flag must be
// set to 'False'.
// c) Since the XPath data model treats default attributes the same as
// specified attributes, the XmlStandardDomReader.IgnoreUnspecified flag
// must be set to 'False'.
// d) Since in the XPath data model there are no attributes corresponding to
// attributes that declare namespaces, the
// XmlNamespaceSignalGenerator.SupressXmlns flag is set to 'True'.
with XmlToDomParser
do begin
try
Doc_1 := ParseFile(OpenDialog.FileName, True);
try
(*if not Doc_1.ValidationAgent.ValidateDocument(erReplace) then begin
ShowErrorMessage('Document is invalid!');
Doc_1.Free;
Exit;
end; *)
Doc_2 := TDomDocumentXPath.Create(Doc_1.DomImplementation);
Doc_2.Clear;
XmlDomBuilder.ReferenceNode := Doc_2;
if not XmlStandardDomReader.Parse(Doc_1)
then begin
ShowErrorMessage('
Conversion to XPath data model failed!');
Doc_2.Free;
Exit;
end;
finally
Doc_1.Free;
end;
except
ShowErrorMessage('
Document is not well-formed!');
Exit;
end;
end;
{with ...}