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 Ben Griffin <be...@redsnapper.net> on 2009/03/27 13:49:18 UTC
DOMLSInput.setStringData behaving as if XMLCh* data is XMLByte*
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);
(fail)
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
Re: DOMLSInput.setStringData behaving as if XMLCh* data is XMLByte*
Posted by Ben Griffin <be...@redsnapper.net>.
Alberto, thanks
But XMLCh* does not need to be encoded - there is only one encoding
for XMLCh*
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: 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
Re: DOMLSInput.setStringData behaving as if XMLCh* data is XMLByte*
Posted by Ben Griffin <be...@redsnapper.net>.
Alberto,
I didn't mean to antagonise you!
I did not know that setStringData was to be changed in the future.
I accept the current work-around for Xerces 3.0 !
Best regards
Ben.
On 27 Mar 2009, at 14:17, Alberto Massari wrote:
> I thought we already straightened this out: Xerces 3.0 doesn't
> automatically enforce the XMLCh encoding when invoking setStringData
> - the next version will do it. In the meanwhile you HAVE to set it
> manually.
>
> Alberto
>
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
Re: DOMLSInput.setStringData behaving as if XMLCh* data is XMLByte*
Posted by Alberto Massari <am...@datadirect.com>.
I thought we already straightened this out: Xerces 3.0 doesn't
automatically enforce the XMLCh encoding when invoking setStringData -
the next version will do it. In the meanwhile you HAVE to set it manually.
Alberto
Ben Griffin wrote:
> 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: 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
>>
>
>
> ---------------------------------------------------------------------
> 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: DOMLSInput.setStringData behaving as if XMLCh* data is XMLByte*
Posted by Ben Griffin <be...@redsnapper.net>.
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: 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
Re: DOMLSInput.setStringData behaving as if XMLCh* data is XMLByte*
Posted by Alberto Massari <am...@datadirect.com>.
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: 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