0

Can some recommend an XML serializer that is element or attribute centric, and that doesn't use key-value pairs.

For example, GAE db.model has a to_xml() function but it writes out like this:

  <property name="firstname" type="string">John</property>
  <property name="lastname" type="string">Doe</property>
  <property name="city" type="string">Dallas</property>
  <property name="dateTimeCreated" type="gd:when">2009-09-30 19:45:45.975270</property>

From what I remember, these are much harder to map in XSLT tools than simple elements/attributes like this:

DESIRED OUTPUT

   <firstname>John</firstname>
   <lastname>Doe</lastname>
   <city>Dallas</city>
   <dateTimeCreated type="gd:when">2009-09-30 19:45:45.975270</dateTimeCreated>

I just tried the GNOSIS lib, and my first attempt worked, but also created name value pairs something like this:

  <attr name="__coredata__" type="dict" id="4760164835402068688" >
    <entry>
      <key type="string">firstname</key>
      <val type="string">John</val>
    </entry>
    <entry>
      <key type="string">lastname</key>
      <val type="string">Doe</val>
    </entry> 
    etc... 

Thanks,

Neal Walters

1
  • I ended-up writing custom code using inspection (aka reflection). It really wasn't that hard. Commented Oct 2, 2009 at 18:04

1 Answer 1

2

pyxslt.serialize looks closest to your specs but not a 100% map (for example, it doesn't record the type -- just turns everything into strings). Could still be a good basis from where to customize (maybe by copy / paste / edit, if it doesn't offer all the hooks you need for a cleaner customization).

Sign up to request clarification or add additional context in comments.

1 Comment

Took a look at it, seems to require libxml2 (xmlsoft.org) which is dependent on C, and thus cannot use with GAE.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.