AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

OpenXML XPath Syntax problem

Ein Thema von Kostas · begonnen am 1. Feb 2011 · letzter Beitrag vom 3. Apr 2013
Antwort Antwort
kostgr

Registriert seit: 4. Dez 2008
5 Beiträge
 
Delphi 2010 Professional
 
#1

AW: OpenXML XPath Syntax problem

  Alt 3. Apr 2013, 09:59
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 ...}
Konstantin
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:47 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz