[xsde-users] Cannot get namespaces to work
Robert S. Grimes
rsgrimes at rcn.com
Wed Jun 10 11:54:30 EDT 2020
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" <boris at codesynthesis.com>
To: "Robert S. Grimes" <rsgrimes at rcn.com>
Cc: xsde-users at codesynthesis.com
Sent: Wednesday, June 10, 2020 9:27:46 AM
Subject: Re: [xsde-users] Cannot get namespaces to work
Robert S. Grimes <rsgrimes at rcn.com> writes:
> <?xml version="1.0"?>
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:xdcs="http://www.rsgassoc.com/XMLConfig"
> targetNamespace="http://www.rsgassoc.com/XMLConfig">
>
>
> <xs:complexType name="ComponentConfig">
> <xs:attribute name="cname" type="xs:string" use="required"/>
> </xs:complexType>
>
>
> <xs:complexType name="GlobalConfig">
> <xs:sequence>
> <xs:element name="name" type="xs:string"/>
> <xs:element name="version" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
>
> <xs:complexType name="PlatformConfig">
> <xs:sequence>
> <xs:element name="GlobalConfig" type="xdcs:GlobalConfig"/>
> <xs:element name="ComponentConfig" type="xdcs:ComponentConfig"/>
> </xs:sequence>
> </xs:complexType>
>
> <xs:element name="PlatformConfig" type="xdcs:PlatformConfig"/>
>
> </xsd:schema>
>
>
> Here is a sample XML.
>
> 1 <?xml version="1.0"?>
> 2 <xdcs:PlatformConfig xmlns:xdcs="http://www.rsgassoc.com/XMLConfig"
> 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 4 xsi:schemaLocation="http://www.rsgassoc.com/XMLConfig PlatformConfig.xsd">
> 5
> 6 <xdcs:GlobalConfig>
> 7 <name>MyDeviceName</name>
> 8 <version>v0.2</version>
> 9 </xdcs:GlobalConfig>
> 10 <xdcs:ComponentConfig cname="MyCompType" iname="MyCompInstance"/>
> 11 </xdcs:PlatformConfig>
>
> 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).
More information about the xsde-users
mailing list