#1
  1. No Profile Picture
    The Monk that is Fat.
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    UK
    Posts
    107
    Rep Power
    15

    XML validate from DTD (lazarus)


    I have an XML file loaded into a SynEdit component that I want to validate against an external DTD file...

    The SynEdit component works fine for highlighting etc but I am having real trouble figuring out how to us the XML validations functions.

    I've trawled over the info at http://wiki.freepascal.org/XML_Tutor...ing_a_document but am just getting myself utterly confused.

    I've read the content of the DTD into a string variable so as not to have to re-read the file every time I validate and the XML to be checked is in a SynEdit component but I've completely confused myself as to how to tie the two together and parse the XML against the DTD.

    I would post what I've done so far, but it's such a mess I'd be embarassed, so instead I'll explain what I've done in psuedo-code.

    Code:
    myDTDcontentString, myXMLtoBeValidated: String;
    XMLparser: TDOMParser;
    
    myXMLtoBeValidated:=Synedit.Text;
    myDTDcontentString:=ReadFromFile('myDTDfile.dtd');
    XMLparser.OnError:= showTheErrorInStatusBar();
    
    XMLparser.Parse(myXMLtoBeValidated,myDTDcontentString);
    I get the impression I need to be doing something with TXMLDocument and TXMLInputSource but I cannot figure out what is what and any clues (especially no-cryptic ones) would be gratefully received.

    Thanks,

    FM
    Last edited by fatmonk; March 7th, 2013 at 09:53 AM. Reason: Forgot to mention that this is in lazarus

IMN logo majestic logo threadwatch logo seochat tools logo