From rsgrimes at rcn.com Wed Jun 10 08:29:36 2020 From: rsgrimes at rcn.com (Robert S. Grimes) Date: Wed Jun 10 08:42:04 2020 Subject: [xsde-users] Re: Cannot get namespaces to work In-Reply-To: <1228702529.17525643.1591746042914.JavaMail.root@rcn.com> Message-ID: <1617179543.18358624.1591792176947.JavaMail.root@rcn.com> I also wanted to note that, using xmllint, the schema successfully validate the XML file; of course, same is true of the XSD/e example. Something is odd. The example shows we can use namespaces, but my code fails, though as best I see, I do the same thing. I must be missing something trivial, yet crucial... ----- Original Message ----- I have a schema that was working for quite some time; however, I've become tired of the fact that it generates global classes. I am trying to get XSD/e to generate my schema's classes into a namespace, and also, trying to write an xml file that the parser recognizes. I can't seem to figure out how to do that, as I keep getting an "unexpected element encountered" error on the root element of my xml document. My old schema looks like this. For brevity, I don't show the rest of the schema; it is the same as the next schema, without any "xdcs:" prefixes. My new schema looks like this Here is a sample XML. 1 2 5 6 7 MyDeviceName 8 v0.2 9 10 11 The error throw is this (I've modeled this code from examples): Test.xml:4:95: error: unexpected element encountered' Line 4, column 95 is at the closing angle brace (>) for the xdcs:PlatformConfig element that spans lines 2-4. I cannot see anything wrong with this, but my XML/XSD skills are rusty at best. As far as I can tell, the schema is (essentially) identical to the "protocol" example in exampls/cxx/parser/multiroot/protocol.xsd, and the xml identical to the withdraw.xml file in the same directory. What gives? I am rather desperate, as I have a big deadline coming that I just can't miss - yeah, don't we all? Regards, Bob From rsgrimes at rcn.com Tue Jun 9 19:40:42 2020 From: rsgrimes at rcn.com (Robert S. Grimes) Date: Wed Jun 10 09:16:03 2020 Subject: [xsde-users] Cannot get namespaces to work In-Reply-To: <1228348511.17481472.1591743994481.JavaMail.root@rcn.com> Message-ID: <1228702529.17525643.1591746042914.JavaMail.root@rcn.com> I have a schema that was working for quite some time; however, I've become tired of the fact that it generates global classes. I am trying to get XSD/e to generate my schema's classes into a namespace, and also, trying to write an xml file that the parser recognizes. I can't seem to figure out how to do that, as I keep getting an "unexpected element encountered" error on the root element of my xml document. My old schema looks like this. For brevity, I don't show the rest of the schema; it is the same as the next schema, withouth any "xdcs:" prefixes. My new schema looks like this Here is a sample XML. 1 2 5 6 7 MyDeviceName 8 v0.2 9 10 11 The error throw is this (I've modeled this code from examples): Test.xml:4:95: error: unexpected element encountered' Line 4, column 95 is at the closing angle brace (>) for the xdcs:PlatformConfig element that spans lines 2-4. I cannot see anything wrong with this, but my XML/XSD skills are rusty at best. As far as I can tell, the schema is (essentially) identical to the "protocol" example in exampls/cxx/parser/multiroot/protocol.xsd, and the xml identical to the withdraw.xml file in the same directory. What gives? I am rather desperate, as I have a big deadline coming that I just can't miss - yeah, don't we all? Regards, Bob From boris at codesynthesis.com Wed Jun 10 09:27:46 2020 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jun 10 09:40:16 2020 Subject: [xsde-users] Cannot get namespaces to work In-Reply-To: <1228702529.17525643.1591746042914.JavaMail.root@rcn.com> References: <1228348511.17481472.1591743994481.JavaMail.root@rcn.com> <1228702529.17525643.1591746042914.JavaMail.root@rcn.com> Message-ID: Robert S. Grimes writes: > > > xmlns:xdcs="http://www.rsgassoc.com/XMLConfig" > targetNamespace="http://www.rsgassoc.com/XMLConfig"> > > > > > > > > > > > > > > > > > > > > > > > > > > > Here is a sample XML. > > 1 > 2 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > 4 xsi:schemaLocation="http://www.rsgassoc.com/XMLConfig PlatformConfig.xsd"> > 5 > 6 > 7 MyDeviceName > 8 v0.2 > 9 > 10 > 11 > > The error throw is this (I've modeled this code from examples): > > > Test.xml:4:95: error: unexpected element encountered My guess is you (still) have something like this: xml_schema::document_pimpl doc_p (PlatformConfig_p.root_parser (), PlatformConfig_p.root_name ()); Rather than this: xml_schema::document_pimpl doc_p (PlatformConfig_p.root_parser (), PlatformConfig_p.root_namespace (), PlatformConfig_p.root_name ()); In your parser setup. Also, I don't believe the above XML document is valid per the above schema: xdcs:GlobalConfig and xdcs:ComponentConfig should be unqualified or else you should make them global in your schema (or mess with elementFormDefault). From rsgrimes at rcn.com Wed Jun 10 11:54:30 2020 From: rsgrimes at rcn.com (Robert S. Grimes) Date: Wed Jun 10 12:06:57 2020 Subject: [xsde-users] Cannot get namespaces to work In-Reply-To: Message-ID: <641205351.18738186.1591804470574.JavaMail.root@rcn.com> Hi Boris, You are indeed spot-on with both observations; FWIW I somehow had already fixed your second one. But to be crystal clear, I had indeed missed the PlatformConfig_p.root_namespace () parameter in the parser setup! To be honest, I had done the initial parser set-up literally 2 years, 4 months ago, and that is the sole time (other than working your examples) that I had ever done that; so, factor in that I didn't expect my schema changes to require code changes, and of course, I never would have found this! Thank you so very much for the prompt, accurate, spot-on help! Best regards, Bob ----- Original Message ----- From: "Boris Kolpackov" To: "Robert S. Grimes" Cc: xsde-users@codesynthesis.com Sent: Wednesday, June 10, 2020 9:27:46 AM Subject: Re: [xsde-users] Cannot get namespaces to work Robert S. Grimes writes: > > > xmlns:xdcs="http://www.rsgassoc.com/XMLConfig" > targetNamespace="http://www.rsgassoc.com/XMLConfig"> > > > > > > > > > > > > > > > > > > > > > > > > > > > Here is a sample XML. > > 1 > 2 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > 4 xsi:schemaLocation="http://www.rsgassoc.com/XMLConfig PlatformConfig.xsd"> > 5 > 6 > 7 MyDeviceName > 8 v0.2 > 9 > 10 > 11 > > The error throw is this (I've modeled this code from examples): > > > Test.xml:4:95: error: unexpected element encountered My guess is you (still) have something like this: xml_schema::document_pimpl doc_p (PlatformConfig_p.root_parser (), PlatformConfig_p.root_name ()); Rather than this: xml_schema::document_pimpl doc_p (PlatformConfig_p.root_parser (), PlatformConfig_p.root_namespace (), PlatformConfig_p.root_name ()); In your parser setup. Also, I don't believe the above XML document is valid per the above schema: xdcs:GlobalConfig and xdcs:ComponentConfig should be unqualified or else you should make them global in your schema (or mess with elementFormDefault).