java - Local part cannot be “null” when creating a QName -


i use apache xmlschema 2.2.1 parse xsd schema. has following schema:

<?xml version="1.0" encoding="utf-8"?> <xs:schema targetnamespace="http://www.example.com/aigu"        xmlns="http://www.example.com/aigu"        xmlns:xs="http://www.w3.org/2001/xmlschema"        xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.0">     <xs:attribute name="label" type="xs:string" />     <xs:element name="object">         <xs:complextype>             <xs:attribute ref="label" form="unqualified"/>         </xs:complextype>     </xs:element> </xs:schema> 

the following code produces exception

import org.apache.ws.commons.schema.xmlschemacollection; import org.xml.sax.inputsource;  import java.io.bytearrayinputstream; import java.nio.charset.standardcharsets;  public class aigu {     public static void main(string[] args) {         string schema = "here_is_content_of_schema";         xmlschemacollection collection = new xmlschemacollection();         collection.read(new inputsource(new bytearrayinputstream(schema.getbytes(standardcharsets.utf_8))));     } } 

stacktrace:

exception in thread "main" java.lang.illegalargumentexception: local part cannot "null" when creating qname     @ javax.xml.namespace.qname.<init>(qname.java:244)     @ javax.xml.namespace.qname.<init>(qname.java:188)     @ org.apache.ws.commons.schema.utils.xmlschemanamedwithformimpl.setname(xmlschemanamedwithformimpl.java:117)     @ org.apache.ws.commons.schema.utils.xmlschemanamedwithformimpl.setform(xmlschemanamedwithformimpl.java:105)     @ org.apache.ws.commons.schema.xmlschemaattribute.setform(xmlschemaattribute.java:170)     @ org.apache.ws.commons.schema.schemabuilder.handleattribute(schemabuilder.java:959)     @ org.apache.ws.commons.schema.schemabuilder.handleattribute(schemabuilder.java:923)     @ org.apache.ws.commons.schema.schemabuilder.handlecomplextype(schemabuilder.java:307)     @ org.apache.ws.commons.schema.schemabuilder.handleelement(schemabuilder.java:420)     @ org.apache.ws.commons.schema.schemabuilder.handleschemaelementchild(schemabuilder.java:1512)     @ org.apache.ws.commons.schema.schemabuilder.handlexmlschemaelement(schemabuilder.java:659)     @ org.apache.ws.commons.schema.schemabuilder.build(schemabuilder.java:157)     @ org.apache.ws.commons.schema.xmlschemacollection.read(xmlschemacollection.java:508)     @ org.apache.ws.commons.schema.xmlschemacollection.read(xmlschemacollection.java:717)     @ org.apache.ws.commons.schema.xmlschemacollection.read(xmlschemacollection.java:565)     @ com.netcracker.mediation.transition.model.xmltojava.aigu.main(aigu.java:23) 

is bug in apache code or schema invalid?

the attribute form cannot used in attribute use has ref (as constrained in point 3.2 in this paragraph of xml schema specification).

also, since target of reference top-level attribute declaration in schema target namespace, form, if allowed put explicitly, have qualified.

it may explain error, trace seems indicate happens there.

this corrected schema:

<?xml version="1.0" encoding="utf-8"?> <xs:schema targetnamespace="http://www.example.com/aigu"     xmlns="http://www.example.com/aigu"     xmlns:xs="http://www.w3.org/2001/xmlschema"     xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.0">     <xs:attribute name="label" type="xs:string" />     <xs:element name="object">         <xs:complextype>             <xs:attribute ref="label"/>         </xs:complextype>     </xs:element> </xs:schema> 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -