>From: Javier
>Sent: Thu, May 13, 2010 8:03:40 PM
>
> Hi Dave,
>  
> I use the generateDS scripts to generate the Python data structures  from 
> attached XSD files. Then I parse the attached XML file by the generated 
> function. But it have the following error:
>  
> Traceback (most recent call last):
>   File "D:\simba\obiee_xmls\generateDS\genrateSimbaXml.py", line 11, in 
> <module>
>     scrObject = 
> Backlog_by_Location_Detail.parse('../Current_Backlog_by_Location.xml')
>   File "D:\simba\obiee_xmls\generateDS\Backlog_by_Location_Detail.py", line 
> 2914, in parse
>     rootObj.build(rootNode)
>   File "D:\simba\obiee_xmls\generateDS\Backlog_by_Location_Detail.py", line 
> 1003, in build
>     self.buildChildren(child_, nodeName_)
>   File "D:\simba\obiee_xmls\generateDS\Backlog_by_Location_Detail.py", line 
> 1014, in buildChildren
>     obj_.build(child_)
>   File "D:\simba\obiee_xmls\generateDS\Backlog_by_Location_Detail.py", line 
> 1758, in build
>     self.buildChildren(child_, nodeName_)
>   File "D:\simba\obiee_xmls\generateDS\Backlog_by_Location_Detail.py", line 
> 1776, in buildChildren
>     obj_.build(child_)
>   File "D:\simba\obiee_xmls\generateDS\Backlog_by_Location_Detail.py", line 
> 1441, in build
>     self.buildChildren(child_, nodeName_)
>   File "D:\simba\obiee_xmls\generateDS\Backlog_by_Location_Detail.py", line 
> 1450, in buildChildren
>     expr_ += text__content_.nodeValue
> TypeError: coercing to Unicode: need string or buffer, NoneType found
>  
> I dont know reason. could you help me resolve this problem?
>  

Javier -

Good to hear from you.

Let me make a few comments and suggestions that might help with
your issue.

1. I'm using version generateDS.py version 1.20f.  If you are using
   an earlier version, you may want to upgrade.  I can't tell which
   version you are using (the version is not in the comment line
   generated), however, it seems like I recall fixing a problem
   that had a similar signature.  I'm not too sure about that.

2. Your XML schema uncovered a problem in the current version
   (1.20f).  When a complex type declares a child that is defined
   as an (top level) element whose type is defined as a
   complexType, then the generated code is trying to create an
   instance of

   In your schema, T_expr contains a declaration of a child of type
   expr, but expr is a (top level) element which type is declared
   as T_expr.  In the build method, the generated code tries to
   create an instace of class expr (which does not exist), whereas
   it should create an instance of class T_expr.

   I patched this with the following fix in the buildChildren
   method in class T_expr:

       --- tmp1sup.py~ 2010-05-14 08:48:51.000000000 -0700
       +++ tmp1sup.py  2010-05-14 10:54:31.000000000 -0700
       @@ -291,7 +291,8 @@
            def buildChildren(self, child_, nodeName_):
                if child_.nodeType == Node.ELEMENT_NODE and \
                    nodeName_ == 'expr':
       -            childobj_ = expr.factory()
       +            childobj_ = T_expr.factory()
                    childobj_.build(child_)
                    obj_ =
       self.mixedclass_(MixedContainer.CategoryComplex,
                        MixedContainer.TypeNone, 'expr', childobj_)

   But, I'll have to look into how to fix this error in
   generateDS.py.

3. generateDS.py is not generating code for the correct root
   element given your instance document
   (Current_Backlog_by_Location.xml).  You can fix this in several
   ways: (1) edit the parse function at the bottom of your
   generated code; or (2) (copy and) write your own parse function
   in a separate file in which you import one of the generated
   files; or (3) use a parse function something like the following
   to detect the root element in an instance document:

       def get_root_tag(node):
           tag = node.tagName
           tags = tag.split(':')
           if len(tags) > 1:
               tag = tags[-1]
           rootClass = None
           if hasattr(supermod, tag):
               rootClass = getattr(supermod, tag)
           return tag, rootClass

       def parse(inFilename):
           doc = minidom.parse(inFilename)
           rootNode = doc.documentElement
           rootTag, rootClass = get_root_tag(rootNode)
           rootObj = rootClass.factory()
           rootObj.build(rootNode)
           # Enable Python to collect the space used by the DOM.
           doc = None
           sys.stdout.write('<?xml version="1.0" ?>\n')
           rootObj.export(sys.stdout, 0, name_=rootTag,
               namespacedef_='')
           doc = None
           return rootObj

   I plan to do a bit of work on this last problem, but it might
   take me a bit of time.

Hope that something above is of some help to you.  I'll
report back when I have a fix for that problem I mentioned
in point 2. above.

- Dave

 -- 


Dave Kuhlman
http://www.rexx.com/~dkuhlman

------------------------------------------------------------------------------

_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to