[xsde-users] Cannot get namespaces to work
    Robert S. Grimes 
    rsgrimes at rcn.com
       
    Tue Jun  9 19:40:42 EDT 2020
    
    
  
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. 
<?xml version="1.0"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
</xsd:schema> 
My new schema looks like this 
<?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' 
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 
    
    
More information about the xsde-users
mailing list