• Welcome to OS2World OLD-STATIC-BACKUP Forum.
 

News:

This is an old OS2World backup forum for reference only. IT IS READ ONLY!!!

If you need help with OS/2 - eComStation visit http://www.os2world.com/forum

Main Menu

Parse XML

Started by jep, 2008.03.30, 19:04:38

Previous topic - Next topic

jep

Marked as: Advanced
Hello,

I've created a tool in rexx to extract data embedded into a special kind of XML-files.
You can see the functions below that you can use as guides for further discussions
You can also give us examples of the xml parser .dll's for OS/2 and rexx that's available and where and how to use them in various situations.

Some tags in some implementations may look a bit different than the usual ones, the company I work for use empty tags at times that may look something like:
<option430 />
where the ending /> indicate that there's no end tag related to this one. ( compare to <option>bla bla bla</option> )
Please note that the code below doesn't handle such situations.


xml_dispose_tag: procedure
    retval = ARG(1)
    interpret 'parse value retval with ."<'||ARG(2)||'>"."</'||ARG(2)||'>"retval'
Return retval
   
xml_no_tag_parser: procedure
    retval = ARG(1)
    interpret 'parse value retval with ."<'||ARG(2)||' />"retval'
Return retval
   
xml_tags_parser: procedure
    retval = ARG(1)
    do i = 2 to ARG()
        interpret 'parse value retval with ."<'||ARG(i)||'>"retval"</'||ARG(i)||'>".'
    end
Return retval

xml_tag_parser: procedure
    retval = ARG(1)
    interpret 'parse value retval with ."<'||ARG(2)||'"jmf_1">"retval"</'||ARG(2)||'"jmf_2">".'
    if pos( translate( ARG(3) ), translate( jmf_1 ) ) = 0 & pos( translate( ARG(3) ), translate( jmf_2 ) ) = 0 then
        Return ''
Return retval

saborion2

Hey "jep"! It is very nice to see there are folks like you out there who can and are handling the REXX Language (just did a few introductory and that all for me for now as the preference was at the micro-computing end...  ;D) Anyway I am just being curious since you have said; "I've created a tool in rexx to extract data embedded into a special kind of XML-files.
You can see the functions below that you can use as guides for further discussions
You can also give us examples of the xml parser .dll's for OS/2 and rexx that's available and where and how to use them in various situations..." What are the compelling reasons for someone or a company to "embed data into a special kind of XML-files" when there is (a) an already established and approved International Organization for Standardization (ISO) Format Standard; re: Open Document Format (ODF) Standards; and, (b) the Microsoft's OOXML proposals are also under consideration by the International Organization for Standardization (ISO).  :-X


jep

Hello,

the example doesn't handle ODF nor OOXML files, but you can probably use the code as a base to do something like that. Just unzip the ODF-file and parse "contents.xml" for example and you'll get the text in plain format.
Hmm, you may want to reverse the procedure as you may not know all the tag names in advance as I did.

The example does however handle images and files in another format, ClipArt files (plu.) contained in 1 file (extension mpf).

Just get rxClipArt from hobbes and the files from ... somewhere ... test the tool and you have a bunch of .wmf-files to add to OO.org 2.x Theme Gallery.

Note: You're not allowed to fetch mpf-files if you don't have a valid license for "the other" Office suite, but who ca...

//jep

saborion2

#3
Here is another question: Can the "REXX Tool" that you have created ((or a similarly created one) be used to extract embedded data in the context of "Spread Sheet" scenarios.? Also, to what extent have historical considerations been given to the fact that "REXX became part of the base operating system. It (having ) previously been included in the IBM OS/2 Extended Edition 1.2 only.

Re: http://www-306.ibm.com/software/awdtools/rexx/library/rexxos2.html


kim

Quote from: saborion2 on 2008.03.30, 22:01:12Also, to what extent have historical considerations been given to the fact that "REXX became part of the base operating system. It (having ) previously been included in the IBM OS/2 Extended Edition 1.2 only.

In regards with what historical considerations do you mean? If you're thinking about the possibilities of still being able using Rexx; then Rexx can be used for quite the most OS. Guess that this little image clearly shows that:


saborion2

#5
Quite; "Note: this is the OS/2 release in which REXX became part of the base operating system. It had previously been included in the IBM OS/2 Extended Edition 1.2 only". It was in this context that the question with regards to "historical considerations" was asked. Now, the feeling is - just how easy and simple it would/could be if the "REXX Tools" like the one now being spoken about can be integrated into any existing OS/2 Operating System thus leaving OS/2 users to focus on the real "tasks" (Spread Sheet function *API* calls...) at hand.  ;D


kim

Well, you could either seamless integrate into the wps or if you'd like as a separate application with full GUI. There are several ways of doing it; so from end-users perspective you can "hide" it and just focus on getting it done.

saborion2

#7
You said; "Well, you could either seamless integrate into the wps or if you'd like as a separate application with full GUI...". But, without any access the Operating System's API (re: OS's WF Petition Letter to IBM) and with particular reference to "a separate application (including those of "Composite and Collaborative Applications") with full GUI..." how sure are all of these possible?


saborion2

Additionally to; "But, without any access the Operating System's API (re: OS's WF Petition Letter to IBM) and with particular reference to "a separate application (including those of "Composite and Collaborative Applications") with full GUI..." how sure are all of these possible?

Here is why "without access to the OS/2 Operating System's API's this might not be quite possible according to this IBM Lotus Development Corporation's 1998 communication; "Re: Concerning the issues with 1-2-3 that are talked about in the documentation you gave me, most of the issues are related to converting files between older and newer versions of product and converting documents between Lotus and Microsoft. Anytime a file is saved backwards or saved with an older file format than the format the file was created under, such as saving a 1-2-3 , 97 file for Windows 95 into a WK1 format for DOS, then naturally we are expected to loose certain features due to technology and features that are present now that were not present 8 - 10 years ago. Similarly, if we try to convert a file from Lotus into Excel or Excel into Lotus, due to differences in the products not every feature will be converted perfectly with the file filters that are available. Both Lotus and Microsoft create similar spreadsheet programs; however, there are several differences in both programs and these differences will remain to distinguish the products apart. We do try to design conversion filters that will allow as much of the file formats as possible to be exchanged and converted without disrupting the actual file design and format.

In one of your letters you made mention of the @IRR and @ERR functions in the 1-2-3 product. By design the @IRR (notably "absent" in Open Office) (will calculate the Internal Rate of Return; where the @ERR is used in conjunction with other formulas, posted was an "ERR" showing an error was received in the calculations). (As far as I can see in the program I cannot find an @ERR function that will allow us to calculate an Economic Rate of Return)".  :-X


jep

Quote from: saborion2 on 2008.03.30, 22:01:12
Here is another question: Can the "REXX Tool" that you have created ((or a similarly created one) be used to extract embedded data in the context of "Spread Sheet" scenarios.? Also, to what extent have historical considerations been given to the fact that "REXX became part of the base operating system. It (having ) previously been included in the IBM OS/2 Extended Edition 1.2 only.

Re: http://www-306.ibm.com/software/awdtools/rexx/library/rexxos2.html

If you use OS/2 or eCs, then you've got rexx installed as it's integrated into the OS.

The rexx tool is just rexx code that solve a specific task. You don't compile the code, it's a text-file that instruct the interpreter to perform certain things. If you want higher performance decoding into binary data then you may want to use dll's that can do the job faster.

It should work on any OS as it doesn't rely on external functions (dll's) but may require that the interpreter can handle certain functions.


It's possible that it can help you out decoding spread sheet data, but what do you have in mind?

Rexx is a scripting language, you'd rather use C/C++ or some other traditional language and compile and use rexx on top. I'd rather think of it as the ease-of-use language to improve the every day chores in OS/2-eCS instead of VisualBasic/LotusScript that other use. REXX would certainly be a great choise to have as e.g. the scription language and functions (ERR, LEFT etc.) in some spread sheet application.


There are some obsticles you need to take into consideration if you want to handle files.
1) I haven't used rexx for OS/2 EE 1.2, so some features may not be there as in the Warp 3/4, eCS version that I usually write for.
2) Don't think that older spread sheets (1-2-3 and/or Excel files) got a form similar to xml, they're more like binary data only. So you need to know the binary sequence that precede the data you want to extract.
3) You need to know the format of the data to decode as I did (or found out on the net). ClipArt come as base64 (see other post) and someone had already written and included some code in Rexx Tips & Tricks that i modified.
4) ooxml may contain encryptions and require special software, but it's possible if you have inside knowledge to extract something there as well.