On 06/18/2010 05:21 AM, scruffian wrote:
> I have a copy of the KJV bible in xml format, which I spent some time
> converting to JSON. However I just realised there was an error in the
> way I have done it and I have lost some data.
>
If your data starts as XML, you can convert it using:
- XSLT (XML Stylesheet Language - Transformations)
- SAX (Simple API for XML)
- Iterating through nodes in a DOM
- Iterating using a different library (like Python's ElementTree)
Writing your own XML parser using regular expressions is reinventing the
wheel.
--
---
Efraim Feinstein
Lead Developer
Open Siddur Project
http://opensiddur.net
http://wiki.jewishliturgy.org
For XSLT (1.0), a good place to start is W3Schools
<http://www.w3schools.com/xsl/default.asp>. There are a number of XSLT
1.0 interpreters out there, and there are XSLT libraries that interface
directly with other languages. For standalone XSLT 2.0 or XSLT 2.0 as a
Java library, the best open source solution is Saxon HE.
For the others, what library to use and how to interface with it really
depends on what your favorite language is. Google is your friend.
>> If your data starts as XML, you can convert it using:
>> - XSLT (XML Stylesheet Language - Transformations)
>> - SAX (Simple API for XML)
>> - Iterating through nodes in a DOM
>> - Iterating using a different library (like Python's ElementTree)
>>
--
---
Efraim Feinstein
Lead Developer
If you know PHP (or similar languages), SimpleXML is probably the
easiest approach. It turns the XML into one big nested array, and you
just loop through it.
http://php.net/manual/en/book.simplexml.php
Nigel.
> --
> You received this message because you are subscribed to the Google Groups
> "Open Scriptures" group.
> To post to this group, send email to open-sc...@googlegroups.com.
> To unsubscribe from this group, send email to
> open-scriptur...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/open-scriptures?hl=en.
>
>
Yes find and replace can be a great tool, but when I converted the
Strong's Hebrew dictionary to JSON, I used XSLT. It gives you a little
better control. Depending on the complexity of your text, it may not be
too difficult to make up a quick style sheet.
Peace,
David
On Jul 8, 2010, at 9:30 PM, Patrick Altman wrote:
> Json > XML
For object serialization, sure. For document markup, not so much.
James
Ok I have been having a go at this but there are some issues. I tried
converting using this - http://www.thomasfrank.se/xml_to_json.html.
For example I started converting Genesis 1 v 1. The XML from that
source is this:
<verse osisID="Gen.1.1" sID="Gen.1.1"/><w lemma="strong:H07225">In the
beginning</w> <w lemma="strong:H0430">God</w> <w
morph="strongMorph:TH8804" lemma="strong:H0853 strong:H01254">created</
w> <w lemma="strong:H08064">the heaven</w> <w
lemma="strong:H0853">and</w> <w lemma="strong:H0776">the earth</
w>.<verse eID="Gen.1.1"/>
but surely that should be
<verse osisID="Gen.1.1" sID="Gen.1.1">...</verse eID="Gen.1.1">