Both of these are bugs.

https://sourceforge.net/apps/trac/pyxb/ticket/88 deals with the presence of
unicode characters in the input; there were several places where Python was
unhappy, but the specific one you ran into can be fixed by changing the
str(s) to unicode(s) in the MakeIdentifier definition.

https://sourceforge.net/apps/trac/pyxb/ticket/89 deals with the improper
attempt to generate an enumeration belonging to a parent class.  A fix for
the assertion error has been checked into to the next branch of the git
repository.  The ticket has not been closed as I need to develop a test case
that verifies the content model for the restricted type.

Peter

On Fri, Aug 20, 2010 at 1:40 AM, 王守军 <wzh...@hotmail.com> wrote:

>   Hi,
> I have got 2 problems with pyxbgen.
> 1.  I  try to generate binding classes for test.xsd:
>
> <?xml version="1.0" encoding="utf-8"?>
> <xs:schema 
> xmlns:xs="http://www.w3.org/2001/XMLSchema";<http://www.w3.org/2001/XMLSchema%22>
> >
>         <xs:simpleType name="tEnum">
>                 <xs:restriction base="xs:token">
>                         <xs:enumeration value="°"/> > <!-- u'\xb0' -->
>                         <xs:enumeration value="m²"/>
>                         <xs:enumeration value="m³"/>
>                 </xs:restriction>
>         </xs:simpleType>
> </xs:schema>
>
> I have created the binding with:
> $ pyxbgen -u test.xsd -m test
>
> And then got error:
> 20100820141531:7b293ee6
> Exception generating bindings: 'ascii' codec can't encode character u'\xb0'
> in position 0: ordinal not in range(128)
> Traceback (most recent call last):
>   File "/usr/bin/pyxbgen", line 71, in ?
>     modules = generator.bindingModules()
>   File "/usr/lib/python2.4/site-packages/pyxb/binding/generate.py", line
> 2409, in bindingModules
>     self.__bindingModules = self.__buildBindingModules()
>   File "/usr/lib/python2.4/site-packages/pyxb/binding/generate.py", line
> 2382, in __buildBindingModules
>     _PrepareSimpleTypeDefinition(td, self, nsm, module_context)
>   File "/usr/lib/python2.4/site-packages/pyxb/binding/generate.py", line
> 844, in _PrepareSimpleTypeDefinition
>     ei._setTag(utility.PrepareIdentifier(ei.unicodeValue(),
> nsm.uniqueInClass(std)))
>   File "/usr/lib/python2.4/site-packages/pyxb/utils/utility.py", line 138,
> in PrepareIdentifier
>     s = DeconflictKeyword(MakeIdentifier(s).strip('_'), aux_keywords)
>   File "/usr/lib/python2.4/site-packages/pyxb/utils/utility.py", line 50,
> in MakeIdentifier
>     s = _PrefixUnderscore_re.sub('',
> _NonIdentifier_re.sub('',_UnderscoreSubstitute_re.sub('_', str(s))))
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in
> position 0: ordinal not in range(128)
>
> 2. generate binding classes for test2.xsd:
>
> $ cat test2.xsd
> <?xml version="1.0" encoding="utf-8"?>
> <xs:schema 
> xmlns:xs="http://www.w3.org/2001/XMLSchema";<http://www.w3.org/2001/XMLSchema%22>
> >
>         <xs:simpleType name="tAEnum">
>                 <xs:restriction base="xs:normalizedString">
>                         <xs:enumeration value="A"/>
>                 </xs:restriction>
>         </xs:simpleType>
>         <xs:simpleType name="tBEnum">
>                 <xs:restriction base="tAEnum"/>
>         </xs:simpleType>
> </xs:schema>
>
> Generated binding classes:
> $ pyxbgen -u test2.xsd -m test2
>
> Then got error:
> 20100820141957:d3fefae0
> Exception generating bindings: u'A' already has a tag
> Traceback (most recent call last):
>   File "/usr/bin/pyxbgen", line 71, in ?
>     modules = generator.bindingModules()
>   File "/usr/lib/python2.4/site-packages/pyxb/binding/generate.py", line
> 2409, in bindingModules
>     self.__bindingModules = self.__buildBindingModules()
>   File "/usr/lib/python2.4/site-packages/pyxb/binding/generate.py", line
> 2382, in __buildBindingModules
>     _PrepareSimpleTypeDefinition(td, self, nsm, module_context)
>   File "/usr/lib/python2.4/site-packages/pyxb/binding/generate.py", line
> 843, in _PrepareSimpleTypeDefinition
>     assert ei.tag() is None, '%s already has a tag' % (ei,)
> AssertionError: u'A' already has a tag
>
> Can anyone help?
> Thanks a lot!
>
>
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by
>
> Make an app they can't live without
> Enter the BlackBerry Developer Challenge
> http://p.sf.net/sfu/RIM-dev2dev
> _______________________________________________
> pyxb-users mailing list
> pyxb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyxb-users
>
>
------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
pyxb-users mailing list
pyxb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyxb-users

Reply via email to