You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by evangeline <ev...@gmail.com> on 2009/05/04 20:35:07 UTC
XSL schema in (char*) form instead of saved in file
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
--
View this message in context: http://www.nabble.com/XSL-schema-in-%28char*%29-form-instead-of-saved-in-file-tp23374072p23374072.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
Re: XSL schema in (char*) form instead of saved in file
Posted by Ben Griffin <be...@redsnapper.net>.
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: c-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: c-dev-help@xerces.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
Re: XSL schema in (char*) form instead of saved in file
Posted by Alberto Massari <am...@datadirect.com>.
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: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org