From miaowang.tw at gmail.com Fri Jun 3 23:52:09 2022 From: miaowang.tw at gmail.com (Miao Wang) Date: Mon Jun 6 06:48:06 2022 Subject: [xsd-users] Output lowercase HexBinary Message-ID: Hello Boris, I am working on writing a KML (ver.2.2) file using codes generated by CodeSynthesis XSD (4.2.0-b.3). I find that hexbinary values, e.g. color values at PolyStyle, are all in uppercase (ex: FF7FAAAA). I traced the code to the file [xsd\cxx\tree\types.txx], at line 434, template std::basic_string hex_binary:: encode () const { std::basic_string str; const char tab[] = "0123456789ABCDEF"; which shows why the hexbinary is all in uppercase. Because the hexbinary in kml examples found on webs are all in lowercase (ex: ff7faaaa), is there any way to output the hexbinary in lowercase. (Though all programmers know that both the uppercase and lowercase hexbinary values are the same, the others do not know it.) BR, Miao Wang From boris at codesynthesis.com Mon Jun 6 06:55:54 2022 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 6 06:51:37 2022 Subject: [xsd-users] Output lowercase HexBinary In-Reply-To: References: Message-ID: Miao Wang writes: > Because the hexbinary in kml examples found on webs are all in lowercase > (ex: ff7faaaa), is there any way to output the hexbinary in lowercase. You can probably achieve this by customizing the hexBinary type: http://wiki.codesynthesis.com/Tree/Customization_guide#Customizing_the_XML_Schema_built-in_types (There are also some examples of customizing the built-in types). From carloswong54 at gmail.com Mon Jun 6 22:19:52 2022 From: carloswong54 at gmail.com (Carlos Wong) Date: Tue Jun 7 05:54:06 2022 Subject: [xsd-users] Custom DOMLSParser Message-ID: Hi all, I am using the embedded binary representation of the schema and trying to create a custom DOMLSParser, so that I can overload the DOMLSParserImpl::error method. I want to do this so I can access custom_dom_LS_parser_impl->getCurrentNode() and pass that into my custom error handler for further processing. But I can only either make the embedded binary representation work or my customer error handler. I have run out of ideas, please any feedback and/or suggestions would be greatly appreciated. I have also linked a MWE: https://github.com/clxyder/xsd-embedded-custom-parser. Thank you, Carlos From boris at codesynthesis.com Wed Jun 8 10:51:49 2022 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jun 8 10:47:31 2022 Subject: [xsd-users] Custom DOMLSParser In-Reply-To: References: Message-ID: Carlos Wong writes: > But I can only either make the embedded binary representation work or my > customer error handler. I have run out of ideas, please any feedback and/or > suggestions would be greatly appreciated. I tried to follow your code and AFAICS, here is what happens: you call DOMImplementationRegistry::getDOMImplementation() which returns some Xerces-provided instance of DOMImplementation. Then you cast it (with a C-style cast) to your custom_dom_implementation_impl type, even though it's not. Then you call createLSParser(), which (probably) ends up calling Xerces' original implementation and you get Xerces' original DOMLSParserImpl. Or you call createCustomLSParser(), which is wrong, but by the looks of it, it should return you an instance of your custom_dom_LS_parser_impl (because it's not a virtual function and you don't reference any data member). Why don't you get rid of all this DOMImplementation stuff and create an instance of your custom_dom_LS_parser_impl directly: xml::dom::auto_ptr parser( new (manager) custom_dom_LS_parser_impl(0, manager, gramPool)); From carloswong54 at gmail.com Wed Jun 8 11:02:45 2022 From: carloswong54 at gmail.com (Carlos Wong) Date: Thu Jun 9 03:30:22 2022 Subject: [xsd-users] Custom DOMLSParser In-Reply-To: References: Message-ID: Hi Boris, Thank you for the prompt response. It turns out my issue was resolved by calling the DOMLSParserImpl constructor from the initialization list. I was calling it directly from the constructor body. I will give your suggestion to directly create a custom_dom_LS_parser_impl a shot. Thanks again, Carlos On Wed, Jun 8, 2022 at 10:51 AM Boris Kolpackov wrote: > Carlos Wong writes: > > > But I can only either make the embedded binary representation work or my > > customer error handler. I have run out of ideas, please any feedback > and/or > > suggestions would be greatly appreciated. > > I tried to follow your code and AFAICS, here is what happens: you call > DOMImplementationRegistry::getDOMImplementation() which returns some > Xerces-provided instance of DOMImplementation. Then you cast it (with > a C-style cast) to your custom_dom_implementation_impl type, even though > it's not. Then you call createLSParser(), which (probably) ends up > calling Xerces' original implementation and you get Xerces' original > DOMLSParserImpl. Or you call createCustomLSParser(), which is wrong, > but by the looks of it, it should return you an instance of your > custom_dom_LS_parser_impl (because it's not a virtual function and > you don't reference any data member). > > Why don't you get rid of all this DOMImplementation stuff and create > an instance of your custom_dom_LS_parser_impl directly: > > xml::dom::auto_ptr parser( > new (manager) custom_dom_LS_parser_impl(0, manager, gramPool)); On Wed, Jun 8, 2022 at 10:51 AM Boris Kolpackov wrote: > Carlos Wong writes: > > > But I can only either make the embedded binary representation work or my > > customer error handler. I have run out of ideas, please any feedback > and/or > > suggestions would be greatly appreciated. > > I tried to follow your code and AFAICS, here is what happens: you call > DOMImplementationRegistry::getDOMImplementation() which returns some > Xerces-provided instance of DOMImplementation. Then you cast it (with > a C-style cast) to your custom_dom_implementation_impl type, even though > it's not. Then you call createLSParser(), which (probably) ends up > calling Xerces' original implementation and you get Xerces' original > DOMLSParserImpl. Or you call createCustomLSParser(), which is wrong, > but by the looks of it, it should return you an instance of your > custom_dom_LS_parser_impl (because it's not a virtual function and > you don't reference any data member). > > Why don't you get rid of all this DOMImplementation stuff and create > an instance of your custom_dom_LS_parser_impl directly: > > xml::dom::auto_ptr parser( > new (manager) custom_dom_LS_parser_impl(0, manager, gramPool)); >