Ulrich wrote:

> I'd like to validate my xml files against a xsd file linked to my binary
(in a Windows resource).
> I use a XercesDOMParser instance to create a DOM of my XML.
> Is there a possibility to validate against a string wich contains the xsd
resource???

If you save the import the XSD into your project as an HTML resource, you
could use the following code.

        // Load the reporting schema from the resources
        const HRSRC hSrcXsd = FindResource(hInstResource,
                                           MAKEINTRESOURCE(IDR_XSD),
                                           RT_HTML);

        const HGLOBAL hGblXsd = LoadResource(hInstResource,
                                              hSrcXsd);

        const char* const pXsdXml = static_cast<const char*>(
LockResource(hGblXsd) );


You can then add this to a Grammar cache associated with your parser

   DOMBuilder* pParser = ...

   MemBufInputSource XsdInputSrc(pXsdXml, ....);

   pParser->loadGrammar( Wrapper4InputSource(&XsdInputSrc, false),
                          Grammar::SchemaGrammarType,
                                  true /* Save in Cache */);

   pParser->setFeature(XMLUni::fgXercesUseCachedGrammarInParse, true);

Hope this helps


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to