Is it normal to cry when given XML?
Adam Tauno Williams
awilliam at whitemice.org
Tue May 5 06:20:28 EDT 2015
On Tue, 2015-05-05 at 02:28 -0700, Sayth Renshaw wrote:
> Just checking if the reaction to cry when given XML is normal.
No, not at all. I leap for ecstatic joy when given, as all to rarely
happens, XML. Rather than someone's turdy text [which includes JSON]
file. I wish all 1,200+ of my vendors and suppliers would provide their
data in XML rather than the random swirl of bizarre crap I receive.
> I thought maybe I am approaching it all wrong, using lxml largely or
> some xquery to club it into submission.
I do most of my processing with LXML, XSLT, and XPath. Fast, efficient,
reliable, works great. And it is easy to abstract these tools to
automate what I need to do over and over again.
> See the usual goal is just to take the entire XML and push it into a
> database.
I do a lot of pushing into an SQL database, no problem. XSLT does 99.4%
of the work.
> See its never basic xml,
"basic xml"?
> usually comes from some database with a walk of tables and strange relationships.
No problem.
> Am I doing it wrong is there a simple way I am missing?
I suspect so. Data is easily transformed into
<ResultSet table="xyz">
<row>
<field1 dataType="string" isNull="false"
isPrimaryKey="true">abc</field1>
<field2 dataType="string" isNull="true" isPrimaryKey="false"/>
<field3 dataType="string" isNull="false"
isPrimaryKey="false">stanley</field1>
</row>
...
</ResultSet>
And then that data can be processes as SQL insert/update/delete/upsert
operations while being swung around on the end of a stick while you
dance.
<https://sourceforge.net/p/coils/code/ci/default/tree/coils/logic/workflow/actions/sql/upsert.py>
XML is the ultimate file "format". It solves problems, much better than
everyone trying to re-engineer their needs INTO a format [like JSON].
--
Adam Tauno Williams <mailto:awilliam at whitemice.org> GPG D95ED383
Systems Administrator, Python Developer, LPI / NCLA
More information about the Python-list
mailing list