Evangeline, maybe you are asking about how to transcode the grammar document? Possibly the easiest way is to use a MemBufInputSource for your grammar, rather than to transcode it.

//Your Grammar
        char* my_grammar="<.....>"
        const XMLCh my_namespace[]= {'h','t',[your namespace here],chNull};

//First set up the implementation and the parser...
        const XMLCh impltype[]= {'L','S',chNull};
        impl = DOMImplementationRegistry::getDOMImplementation( impltype );
DOMLSParser* parser = ((DOMImplementationLS*)impl)- > createLSParser (DOMImplementationLS ::MODE_SYNCHRONOUS,NULL,XMLPlatformUtils::fgMemoryManager);
        DOMConfiguration* dc = parser->getDomConfig();
        dc->setParameter(XMLUni::fgXercesSchema, true);      
        dc->setParameter(XMLUni::fgXercesCacheGrammarFromParse, true);          
     
        dc->setParameter(XMLUni::fgXercesUseCachedGrammarInParse, true);        
     
        dc->setParameter(XMLUni::fgDOMValidate, true);
        
//load the grammar for future documents.
        XMLByte* graw = (XMLByte*)(my_grammar);
        DOMLSInput* inp = ((DOMImplementationLS*)impl)->createLSInput();     
MemBufInputSource* mem = new MemBufInputSource(graw, strlen(my_grammar), my_namespace);
        mem->setCopyBufToStream(false);
        inp->setByteStream(mem);
        inp->setEncoding(XMLUni::fgUTF8EncodingString);
        parser->loadGrammar(inp, Grammar::SchemaGrammarType, true);
        
//Now you can use the parser to load up documents and validate them against your grammar.

You will also need to make sure that your document's root elements are declared with an xmlns attribute.

Alberto, does that look right to you?
Isn't there a sample for this?

        Ben.


On 6 May 2009, at 08:29, Alberto Massari wrote:

In this case you usually have two choices: a) use loadGrammar to load and cache the schema using your char* as source, and then force validation on and turn on 'use cached grammars' before parsing your XML or b) use setExternalNoNomespaceSchemaLocation to point to a non- existent path and use an EntityResolver to trap the attempt to load that file in order to provide the char* to the parser.

Alberto

evangeline ha scritto:
Hi...

How can I pass the whole already read schema (char *) to X function, instead of passing the filename to setExternalNoNamespaceSchemaLocation(filename)...
So what I want to know is the name of X function I can use.
Thanks



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to