[xsde-users] Cannot get namespaces to work

Boris Kolpackov boris at codesynthesis.com
Wed Jun 10 09:27:46 EDT 2020


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