You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Ramesh Bobba <ra...@transerainc.com> on 2004/09/28 20:45:09 UTC

attributes and enumeration

Hi,

 

I am trying to generate a binding for an attribute that is restricted to an
enumeration. When I try to do it, I get the following error:

 

C:\sandbox\cce\build.xml:159: Following error occured while executing this
line

C:\sandbox\cce\build.xml:144:
org.apache.ws.jaxme.xs.parser.impl.LocSAXException

: At file:/C:/sandbox/cce/src/com/transerainc/cce/callback/request.xsd, line
15,

 column 23: Unable to derive package name from an empty namespace URI. Use
the s

chemaBindings to specify a package name.

 

Can you tell me what I am missing?

 

The xml is:

 

 

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema targetNamespace="http://cce.transerainc.com/gen/request"
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns="http://cce.transerainc.com/gen/request"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

            <xs:element name="request">

                        <xs:annotation>

                                    <xs:documentation>Comment describing
your root element</xs:documentation>

                        </xs:annotation>

                        <xs:complexType>

                                    <xs:sequence>

                                                <xs:element name="attribute"
minOccurs="0" maxOccurs="unbounded">

                                                            <xs:complexType>

 
<xs:attribute name="name" type="xs:string" use="required"/>

 
<xs:attribute name="value" type="xs:string" use="required"/>

 
<xs:attribute name="type" use="required">

 
<xs:simpleType>

 
<xs:restriction base="xs:string">

 
<xs:enumeration value="int"/>

 
<xs:enumeration value="float"/>

 
<xs:enumeration value="double"/>

 
<xs:enumeration value="long"/>

 
<xs:enumeration value="string"/>

 
</xs:restriction>

 
</xs:simpleType>

 
</xs:attribute>

 
</xs:complexType>

                                                </xs:element>

                                    </xs:sequence>

                                    <xs:attribute name="app-name"
type="xs:string" use="required"/>

                        </xs:complexType>

            </xs:element>

</xs:schema>

 

 

 

Thanks,

 

Ramesh K Bobba

Sr. Software Engineer

Transera <http://www.transerainc.com/>  Communications Inc.

20823 Stevens Creek Blvd., Suite 300

Cupertino, CA 95014

(w)408.873.1984x108

(f)408.873.7412

(c)510.579.0001

 


Re: attributes and enumeration

Posted by "Nacho G. Mac Dowell" <ig...@informa.es>.
The thing is that if you don't specify a package name, jaxme tries to 
generate it from the namespace URI. If your namespace was 
http://example.com, then your package would be com.example, but since 
you are using an empty namespace, it is complaining. You could try the 
following:
1. Include in your schema element declaration:
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
and then right after:
    <xs:annotation>
                <xs:appinfo>
            <jaxb:schemaBindings>
                <jaxb:package name="your.package.name" />
            </jaxb:schemaBindings>
        </xs:appinfo>
    </xs:annotation>

2. In the ant task use a package attribute with your package name.

3. If you use eclipse check often this mailing list, I'll probably 
release a plugin this week...

Ramesh Bobba wrote:

> Hi,
>
>  
>
> I am trying to generate a binding for an attribute that is restricted 
> to an enumeration. When I try to do it, I get the following error:
>
>  
>
> C:\sandbox\cce\build.xml:159: Following error occured while executing 
> this line
>
> C:\sandbox\cce\build.xml:144: 
> org.apache.ws.jaxme.xs.parser.impl.LocSAXException
>
> : At 
> file:/C:/sandbox/cce/src/com/transerainc/cce/callback/request.xsd, 
> line 15,
>
>  column 23: Unable to derive package name from an empty namespace URI. 
> Use the s
>
> chemaBindings to specify a package name.
>
>  
>
> Can you tell me what I am missing?
>
>  
>
> The xml is:
>
>  
>
>  
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <xs:schema targetNamespace="http://cce.transerainc.com/gen/request" 
> elementFormDefault="qualified" attributeFormDefault="unqualified" 
> xmlns="http://cce.transerainc.com/gen/request" 
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
>             <xs:element name="request">
>
>                         <xs:annotation>
>
>                                     <xs:documentation>Comment 
> describing your root element</xs:documentation>
>
>                         </xs:annotation>
>
>                         <xs:complexType>
>
>                                     <xs:sequence>
>
>                                                 <xs:element 
> name="attribute" minOccurs="0" maxOccurs="unbounded">
>
>                                                             
> <xs:complexType>
>
>                                                                         
> <xs:attribute name="name" type="xs:string" use="required"/>
>
>                                                                         
> <xs:attribute name="value" type="xs:string" use="required"/>
>
>                                                                         
> <xs:attribute name="type" use="required">
>
>                                                                                     
> <xs:simpleType>
>
>                                                                                                 
> <xs:restriction base="xs:string">
>
>                                                                                                             
> <xs:enumeration value="int"/>
>
>                                                                                                             
> <xs:enumeration value="float"/>
>
>                                                                                                             
> <xs:enumeration value="double"/>
>
>                                                                                                             
> <xs:enumeration value="long"/>
>
>                                                                                                             
> <xs:enumeration value="string"/>
>
>                                                                                                 
> </xs:restriction>
>
>                                                                                     
> </xs:simpleType>
>
>                                                                         
> </xs:attribute>
>
>                                                             
> </xs:complexType>
>
>                                                 </xs:element>
>
>                                     </xs:sequence>
>
>                                     <xs:attribute name="app-name" 
> type="xs:string" use="required"/>
>
>                         </xs:complexType>
>
>             </xs:element>
>
> </xs:schema>
>
>  
>
>  
>
>  
>
> Thanks,
>
>  
>
> Ramesh K Bobba
>
> Sr. Software Engineer
>
> Transera Communications Inc. <http://www.transerainc.com/>
>
> 20823 Stevens Creek Blvd., Suite 300
>
> Cupertino, CA 95014
>
> (w)408.873.1984x108
>
> (f)408.873.7412
>
> (c)510.579.0001
>
>  
>


Re: attributes and enumeration

Posted by Jochen Wiedmann <jo...@freenet.de>.
Nacho G. Mac Dowell wrote:

> The problem arises when you use a different default target namespace in 
> your schema than the one you are defining and want to use safe type 
> enumerations. The constructor for EnumerationSG needs an instance of 
> JavaQName which itself needs a package name. This package name is taken 
> from the type's prefix which is empty if the default target namespace is 
> the schema's targetspace.

Actually, the problem was simpler: The code initiating the typesafe enum 
class did not check, whether the typesafe enumeration was embedded into 
a global attribute or element or into a local attribute or element. In 
the former case, it is quite fine, to derive a package name from the 
namespace URI. In the latter case, this wasn't possible, because the 
local attribute or element typically doesn't have a target namespace.

The fix was to check for a local element or attribute and in that case 
use the outer elements package name.


Jochen


-- 
http://lilypie.com/baby1/050423/1/5/1/+1

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: attributes and enumeration

Posted by "Nacho G. Mac Dowell" <ig...@informa.es>.
Sorry for my error... I didn't take enough care while reading your 
post... Sorry again.

I'll try to guess what's happening:

The problem arises when you use a different default target namespace in 
your schema than the one you are defining and want to use safe type 
enumerations. The constructor for EnumerationSG needs an instance of 
JavaQName which itself needs a package name. This package name is taken 
from the type's prefix which is empty if the default target namespace is 
the schema's targetspace.

I can see two simple solutions:

1. Use a static var in AbstractContext with the cached package name.
2. When getting the package name from GlobalContext set it as a 
jaxme.package.name property so it will get retreived from there.

I personally prefer the second approach. Jochen? I'm willing to submit a 
patch with the solution.

regards,

Nacho G. Mac Dowell

Ramesh Bobba wrote:

> Hi,
>
>  
>
> I am trying to generate a binding for an attribute that is restricted 
> to an enumeration. When I try to do it, I get the following error:
>
>  
>
> C:\sandbox\cce\build.xml:159: Following error occured while executing 
> this line
>
> C:\sandbox\cce\build.xml:144: 
> org.apache.ws.jaxme.xs.parser.impl.LocSAXException
>
> : At 
> file:/C:/sandbox/cce/src/com/transerainc/cce/callback/request.xsd, 
> line 15,
>
>  column 23: Unable to derive package name from an empty namespace URI. 
> Use the s
>
> chemaBindings to specify a package name.
>
>  
>
> Can you tell me what I am missing?
>
>  
>
> The xml is:
>
>  
>
>  
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <xs:schema targetNamespace="http://cce.transerainc.com/gen/request" 
> elementFormDefault="qualified" attributeFormDefault="unqualified" 
> xmlns="http://cce.transerainc.com/gen/request" 
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
>             <xs:element name="request">
>
>                         <xs:annotation>
>
>                                     <xs:documentation>Comment 
> describing your root element</xs:documentation>
>
>                         </xs:annotation>
>
>                         <xs:complexType>
>
>                                     <xs:sequence>
>
>                                                 <xs:element 
> name="attribute" minOccurs="0" maxOccurs="unbounded">
>
>                                                             
> <xs:complexType>
>
>                                                                         
> <xs:attribute name="name" type="xs:string" use="required"/>
>
>                                                                         
> <xs:attribute name="value" type="xs:string" use="required"/>
>
>                                                                         
> <xs:attribute name="type" use="required">
>
>                                                                                     
> <xs:simpleType>
>
>                                                                                                 
> <xs:restriction base="xs:string">
>
>                                                                                                             
> <xs:enumeration value="int"/>
>
>                                                                                                             
> <xs:enumeration value="float"/>
>
>                                                                                                             
> <xs:enumeration value="double"/>
>
>                                                                                                             
> <xs:enumeration value="long"/>
>
>                                                                                                             
> <xs:enumeration value="string"/>
>
>                                                                                                 
> </xs:restriction>
>
>                                                                                     
> </xs:simpleType>
>
>                                                                         
> </xs:attribute>
>
>                                                             
> </xs:complexType>
>
>                                                 </xs:element>
>
>                                     </xs:sequence>
>
>                                     <xs:attribute name="app-name" 
> type="xs:string" use="required"/>
>
>                         </xs:complexType>
>
>             </xs:element>
>
> </xs:schema>
>
>  
>
>  
>
>  
>
> Thanks,
>
>  
>
> Ramesh K Bobba
>
> Sr. Software Engineer
>
> Transera Communications Inc. <http://www.transerainc.com/>
>
> 20823 Stevens Creek Blvd., Suite 300
>
> Cupertino, CA 95014
>
> (w)408.873.1984x108
>
> (f)408.873.7412
>
> (c)510.579.0001
>
>  
>