Hi folks
Been a while since I have been on the forum but still here!!
I deal with quite complex and "rich" source XML files that are the contents of book chapters. My knowledge of XML and particularly the XML in question is very limited (but I have colleagues who can help if needed).
I need to enter some simple content (a few words) within the XML files, but not to interfere with the current content and tags. To use in LiveCode, I prefer to have simple HTML, so that I can use HTMLText, and use all the nifty text manipulation and highlighting features that I have. It is not hard to go from the XML to HTML, but the problem is going back to the original XML and putting back the complex tags.
Alternatively I can view the content using some special CSS files in a browser window, but then I cannot interact with the browser widget.
Sorry if I am bing a bit vague, but any ideas welcome. Happy to give more details.
Interacting with a complex XML file
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 9833
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Interacting with a complex XML file
Have you explored the commands and functions in the revXML external? They're listed in the Dictionary, and are pretty comprehensive, quite good for most needs.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Re: Interacting with a complex XML file
Hi Richard
Thanks for this pointer. Reason for my silence is I need to do a lot of homework now, probably using revXML.
Kaveh
Thanks for this pointer. Reason for my silence is I need to do a lot of homework now, probably using revXML.
Kaveh
Kaveh
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Re: Interacting with a complex XML file
As usual, a one liner from Richard pointed me in the right direction at least to start. I can now examine XML files for structure, content, tree etc. I know that I can write to the XML file too using revXML.
Here's a bit more detail about what I want to do. I am certain it can be done with LiveCode and I bet there is an elegant solution somewhere. I deal with complex scientific publications. See e.g. this page as a random example:
https://journals.plos.org/plosone/artic ... ne.0236938
The XML of the article that you can see in HTML and in PDF, can be downloaded using the download button. I have also attached it here.
The use case is as follows. Suppose you want to read a scientific paper and then make comments on it, in situ. This can be done using web based annotation software (e.g. https://web.hypothes.is/). In our case, for very specific reasons we want to put those comments directly into the XML. So the reader might want to put the following:
into this text:
resulting in:
You can see that there is a lot of complex code that I don't want to modify. I just want to craftily insert the comment code.
Now I want the user interaction to be in a LiveCode field, with all the interaction facilities that LiveCode allows. The user will not need to see a perfect representation of the XML. A "baby" HTML version will do, e.g. using HTMLText.
So my idea is to create a two-way mapping of the original XML and the HTMLText in LiveCode, so that when user selects some text and presses a "comment" button, the comment is written into the XML, without disturbing the surrounding code. The main reason I want to use LiveCode is that I need very flexible and powerful interaction with the text. Conversion from XML to a readable LiveCode field text is not hard, but mapping between the two is challenging. Somehow each chunk of text in LiveCode needs to know exactly where it came from in the XML.
I am looking with the revXML commands, but I have also come across the following:
Kaveh
Here's a bit more detail about what I want to do. I am certain it can be done with LiveCode and I bet there is an elegant solution somewhere. I deal with complex scientific publications. See e.g. this page as a random example:
https://journals.plos.org/plosone/artic ... ne.0236938
The XML of the article that you can see in HTML and in PDF, can be downloaded using the download button. I have also attached it here.
The use case is as follows. Suppose you want to read a scientific paper and then make comments on it, in situ. This can be done using web based annotation software (e.g. https://web.hypothes.is/). In our case, for very specific reasons we want to put those comments directly into the XML. So the reader might want to put the following:
Code: Select all
<comment>are you sure?</comment>
Code: Select all
<p>
Future research should focus on ... frequency band [
<xref ref-type="bibr" rid="pone.0236938.ref047">47</xref>
]. PAM studies ... of Hainan Island.
</p>
Code: Select all
<p>
Future research should focus<comment>are you sure?</comment> on ... frequency band [
<xref ref-type="bibr" rid="pone.0236938.ref047">47</xref>
]. PAM studies ... of Hainan Island.
</p>
Now I want the user interaction to be in a LiveCode field, with all the interaction facilities that LiveCode allows. The user will not need to see a perfect representation of the XML. A "baby" HTML version will do, e.g. using HTMLText.
So my idea is to create a two-way mapping of the original XML and the HTMLText in LiveCode, so that when user selects some text and presses a "comment" button, the comment is written into the XML, without disturbing the surrounding code. The main reason I want to use LiveCode is that I need very flexible and powerful interaction with the text. Conversion from XML to a readable LiveCode field text is not hard, but mapping between the two is challenging. Somehow each chunk of text in LiveCode needs to know exactly where it came from in the XML.
I am looking with the revXML commands, but I have also come across the following:
- Stack by Trevor DeVore (http://newsletters.livecode.com/july/is ... etter1.php) converting between XML and a LiveCode array. Any work by Trevor demands attention. I am still a bit wobbly with arrays but I like the idea of a multidimensional array to hold the content
- XML Library by Ken Ray (http://www.sonsothunder.com/products/xmllib/xmllib.htm)
Kaveh
- Attachments
-
- plos_example.xml.zip
- (29.25 KiB) Downloaded 170 times
Kaveh