Back to Four Js Website
Four Js Customer Forum
Subscribe for automatic updates:
RSS
Sign in for full access
|
Help
Four Js Development Tools Forum
>
Discussions by product
>
Genero BDL
>
XML DomNodes evaluating Attribute data type
Most recent posts
Pages: [
1
]
« previous
next »
Reply
|
Print
Author
Topic: XML DomNodes evaluating Attribute data type (Read 12718 times)
Shawn G.
Posts: 4
XML DomNodes evaluating Attribute data type
«
on:
September 10, 2009, 03:31:48 am »
I'm using an Informix DB v11.50.FC2 with Genero BDL 2.11. While reading the attribute values in a Dom Node, I'm trying to compare one with another attribute value. eg. whether $lhs > $rhs, where $lhs,$rhs are the attribute values. But, without knowing the data type of the attribute value, it is difficult to compare correctly. eg. 1000>300 but "1000" < "300". Or,"31/01/08" > "01/01/09". Is there a way to determine the data type in Genero BDL? Thanks.
Reuben B.
Posts: 1116
Re: XML DomNodes evaluating Attribute data type
«
Reply #1 on:
September 10, 2009, 04:27:07 am »
Hi Shawn,
Whoever supplies you the .xml file should be able to give you a schema for it that indicates what datatypes are expected as attribute values.
It is generaly not possible to look at a value and determine "the" datatype. e.g. is 100 a CHAR(3), or an INTEGER.
What most Genero users will have though is a library function such as is_date(x), is_number(x) that returns TRUE/FALSE. These routines are written using techniques similar to the code below, that is attempt to assign the unknown datatype (stored as a string) to a variable of that datatype. If the operation succeeds then it is possible that value is that datatype and hence RETURN TRUE, if the assignment fails then we know that value is not an example of that datatype.
FUNCTION is_date(s)
DEFINE s STRING
DEFINE d DATE
WHENEVER ANY ERROR CONTINUE
LET d = s
RETURN (STATUS=0)
WHENEVER ANY ERROR ... # set back to previous state
END FUNCTION
FUNCTION is_date(s)
DEFINE s STRING
DEFINE d DATE
TRY
LET d = s
RETURN TRUE
CATCH
RETURN FALSE
END TRY
END FUNCTION
Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of
https://4js.com/ask-reuben
Contributor to
https://github.com/FourjsGenero
Shawn G.
Posts: 4
Re: XML DomNodes evaluating Attribute data type
«
Reply #2 on:
September 10, 2009, 04:45:47 am »
Thank you Reuben.
Frank G.
Posts: 48
Re: XML DomNodes evaluating Attribute data type
«
Reply #3 on:
September 10, 2009, 09:05:51 am »
Hi,
Have you ever tried with the GWS package and its XML and serializer APIs ? You can for instance use the fglwsdl -x tool to generate 4GL variables according to XML schemas, and then use the serializer functions to convert a XML file into that 4GL variables. Notice also that the serializer will care about the datatype specified in the XML schema when doing the conversion.
Regards,
Frank
Shawn G.
Posts: 4
Re: XML DomNodes evaluating Attribute data type
«
Reply #4 on:
September 10, 2009, 10:59:28 am »
Hi Frank - I will research your idea and determine if it can be applied in my program. Thanks.
Shawn G.
Posts: 4
Re: XML DomNodes evaluating Attribute data type
«
Reply #5 on:
September 11, 2009, 06:45:07 am »
Frank - this is new to me - i'm not sure what you mean...
Frank G.
Posts: 48
Re: XML DomNodes evaluating Attribute data type
«
Reply #6 on:
September 15, 2009, 09:19:08 am »
Hi Shawn,
I don't know your exact needs, but if you have trouble to convert XML attributes into 4GL variables, maybe that the GWS extension can help. Actually the GWS package is not only to support Web Services, but it provides all necessary APIs to handle XML and convert it into 4GL. It's why I suggested to convert the XML Schema you have to follow by using the fglwsdl tool with option -x. It will generate a 4GL variable representing your XML Schema, and keeping all necessary piece of information to convert correctly any XML document in that 4GL variable. Then in your application you won't have to access to your XML document via a DomNode, but directly by that generated 4GL variable, once you have called the xml.Serializer.DomToVariable function.
Hope it is more clear now,
If you have more precise questions, don't hesitate.
Frank
Pages: [
1
]
Reply
|
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Discussion
=> Ask Reuben
=> WWDC21
-----------------------------
Discussions by product
-----------------------------
=> Products announcements
=> Genero BDL
=> GWS
=> GAS and GBC
=> GDC
=> Genero Mobile for Android or iOS
=> Genero Studio
=> Reporting tools (GRW, GRE)
-----------------------------
Jobs
-----------------------------
=> Jobs
Powered by SMF 1.1.21
|
SMF © 2015, Simple Machines
Loading...