Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: JiBX 1.1
-
Fix Version/s: None
-
Component/s: core
-
Labels:None
-
Environment:Windows XP Pro, Java JDK 1.4.2
-
Testcase included:yes
-
Number of attachments :
Description
Synopsis of the problem:
globals.xsd:
<xs:schema xmlns="globals" targetNamespace="globals" elementFormDefault="unqualified">
<xs:simpleType name="idType">
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:schema>
NOTE: The issue hinges on the elementFormDefault being set to unqualified.
request.xsd:
<xs:schema xmlns="request" targetNamespace="request" xmlns:g="globals" elementFormDefault="qualified">
<xs:import namespace="globals" schemaLocation="globals.xsd"/>
<xs:element name="req">
<xs:complexType>
<xs:sequence>
<xs:element name="id" type="g:idType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
request.xml:
<?xml version="1.0" encoding="UTF-8"?>
<req xmlns="request">
<id xmlns="">123</id>
</req>
binding.xml
<binding xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="binding.xsd">
<mapping name="req" class="...">
<namespace uri="request" default="elements"/>
<value name="id" field="id" ns=""/>
</mapping>
</binding>
When I try running the binding compiler against this binding, I receive the following error:
Running binding compiler version jibx_1_1
Error running binding compiler
-
-
- Error during code generation - please enter a bug report for this error in Jira if the problem is not listed as fixed on the online status page ***
-
org.jibx.runtime.JiBXException: Undefined or unusable namespace ""
at org.jibx.binding.def.NameDefinition.fixNamespace(NameDefinition.java:143)
at org.jibx.binding.def.BindingBuilder.unmarshalValue(BindingBuilder.java:553)
at org.jibx.binding.def.BindingBuilder.unmarshalStructureChildren(BindingBuilder.java:848)
at org.jibx.binding.def.BindingBuilder.unmarshalMapping(BindingBuilder.java:1651)
at org.jibx.binding.def.BindingBuilder.unmarshalMappings(BindingBuilder.java:983)
at org.jibx.binding.def.BindingBuilder.unmarshalBindingDefinition(BindingBuilder.java:1837)
at org.jibx.binding.Utility.loadBinding(Utility.java:293)
at org.jibx.binding.Utility.loadFileBinding(Utility.java:413)
at org.jibx.binding.Compile.compile(Compile.java:296)
at org.jibx.binding.Compile.main(Compile.java:385)
I tried running xsd2jibx against the schema to see what code it would generate and it produced a binding.xml without the ns="" attribute. However, this would cause the sample.xml provided to generate an error when parsing since it JiBX thinks the <id> tag should be a part of the request namespace.
Pardon my ignorance, but I just figured out that you can create multiple <namespace>'s under a <mapping> including the empty namespace.
This tool is profoundly powerful! Thank you.