Sorry, let me rephrase that!
There is only one encoding for XMLCh* - so if setStringData accepts
XMLCh*, then there is no need for us to inform the DOMLSInput what
encoding the StringData is in.
This is why I point out that if setStringData needs setEncoding, then
it should accept XMLByte* instead of XMLCh* - you cannot have it both
ways!
Either setStringData should accept XMLByte*, in which case it is
sensible/necessary to use setEncoding.
Or setStringData should accept XMLCh*, in which case it is non
necessary to use setEncoding (because XMLCh IS AN ENCODING!)
Best regards
Ben.
On 27 Mar 2009, at 13:20, Alberto Massari wrote:
Ben Griffin wrote:
It appears that the DOMLSInput.setStringData method behaves as if
it has been passed XMLByte*, rather than XMLCh*
The following code fragment succeeds,
std::string grammar = "<schema xmlns='http://www.w3.org/2001/XMLSchema'
targetNamespace='anyXml'><element name='xml' type='anyType'/ ></
schema>";
DOMLSInput* ginput = ((DOMImplementationLS*)impl)->createLSInput();
ginput->setEncoding(XMLUni::fgUTF8EncodingString);
ginput->setStringData((XMLCh*)grammar.c_str()); //nasty!
parser->loadGrammar(ginput, Grammar::SchemaGrammarType, true);
(success)
The following code fragment fails.
XMLCh grammar[] = {'<','s','c','h','e' [[[[ ..same as above but as
XMLCh...]]]] '>',chNull};
DOMLSInput* ginput = ((DOMImplementationLS*)impl)->createLSInput();
ginput->setStringData(grammar);
parser->loadGrammar(ginput, Grammar::SchemaGrammarType, true);
In this case you are forgetting the ginput-
>setEncoding(XMLUni::fgXMLChEncodingString) (that is needed if the
XML fragment you are trying to parse is missing the XML header).
Alberto
(fail)
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]