From: Vincent van Beveren <v.vanbeve...@rijnhuizen.nl>
To: generateds-users@lists.sourceforge.net
Sent: Monday, February 9, 2009 11:53:54 PM
Subject: [Generateds-users] FW: Couple of issues writing XML
> Hi,
>
> I have posted this question a couple of
> months ago, yet received no reply. If by my ignorance I have asked stupid
> questions, please let me know.
>
> My main issue at this point is that empty
> elements are created as <foo></foo>, and wrong indentation. How can
> I resolve this issue so that empty elements are rendered correctly?
>
Vincent -
I apologize for not responding the first time. Give me a day or so
to look into the empty elements issue. Here are a couple of initial
comments:
- Question: Am I right that when an element is empty (has not
children or character content), that the code generated by
generaateDS.py should export:
<tag someattr="stuff" />
instead of:
<tag someattr="stuff">
</tag>
- Doing so would require that the generated code be able to check
whether a element is "empty" in some sense. Keep in mind that
one of your other issues is (generation of) default values. So,
if a child has only character content, we have to think about
what it means for that child to be empty.
- generateDS.py does have some support for the "default" attribute
on element declarations in XML Schemas. Does that help at all
with your needs? Here is an example:
<xs:element name="name" type="xs:string" minOccurs="0"
default="nobody" />
Hmmm. I wonder how XMLBeans handles this. XMLBeans is an Apache
project whose goal is similar to generateDS.py.
(http://xmlbeans.apache.org/) A major difference is that XMLBeans
generates Java code, not Python code. I'll go look.
Give me a day or so to think about this, and I'll report back. I
promise not to forget this time.
- Dave
--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
>
>
> ________________________________
>
> From:Vincent van Beveren
> Sent: donderdag 6 november 2008
> 15:56
> To: ' generateds-users@lists.sourceforge.net '
> Subject: Couple of issues writing
> XML
>
> Hi everyone,
>
> Í’ve just started using generateDS, and am enjoying it
> so-far. I have, however, a couple of issues writing an XML file, and I am
> unsure if I am doing something wrong, or whether I’m forgetting
> something. I will list them below:
>
> - No header / namespace declaration:
> When I use the export(file) method on an element it doesn’t write any
> namespace / header stuff. Ofcourse that is understandable since the element
> itself doesn’t know it is the root. Now I can append <?xml
> version=”1.0”?> to the beginning of the file without modifying
> the generated code, however, the namespace declarations must be in the root
> element. Is there a way to achieve this automatically, or should I subclass
> the
> generated code and modify a specific method?
>
> - Complex-types always written with
> open/close tag: If I write an element which has no child-elements, still an
> open/close tag are created, my XML validator starts complaining that
> “Element 'BinaryVariable' must have no character or element information
> item [children], because the type's content type is empty.” on the
> generated XML. Also the indentation is messed up for the closing-tag (since it
> apparently expects children?). Maybe my XSD requires a special way of creating
> elements with no child-elements allowed?
>
> - Numeric element attributes
> initialized to -1: When I define optional attributes of type xs:int the
> constructor for the element containing these attributes initializes them to
> -1.
> The export function of the element checks whether or no the attribute-value is
> None (which it is not, its -1), so it writes all attribute values being -1.
> Now
> I have to explicitly set all values to a value, or None. It would seem more
> logical to me to set the default value of an attribute to None (unless its
> required, maybe). Is there a way to accomplish this?
>
> Thanks in advance for any insights / help!
>
> Regards,
> Vincent van Beveren
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users