RE: 4D Write Pro using expressions with XML merge file (or JSON)

2017-04-03 Thread Piotr Chabot Stadhouders via 4D_Tech
Hi,

I was thinking : Wouldn't it be nice if 4D implemented some commands where we 
can easily do this kind of stuff in 4D Write Pro?
1 command to link a xml / json data file to a 4D write pro document, and 1 
counterpart to detach data file
Extend ST INSERT EXPRESSION (maybe ST INSERT XPATH) where you can insert 
directly a xml path or json dot notation string.

Gr,

Piotr


> -Oorspronkelijk bericht-
> Van: Piotr Chabot Stadhouders [mailto:p.stadhoud...@timeff.com]
> Verzonden: woensdag 29 maart 2017 22:00
> Aan: 4d_tech@lists.4d.com
> CC: Bruno LEGAY <b.le...@ac-consulting.fr>
> Onderwerp: Re: 4D Write Pro using expressions with XML merge file (or
> JSON)
> 
> Hi Bruno,
> 
> Because it is easy to use xpath in 4D and easy to generate XML in Oracle this
> is exactly why I think this is a nice solution.
> 
> I am glad you think the same:-)
> 
> I assume one can also use attributes in xpath in 4D.
> 
> Gr,
> 
> Piotr
> 
> Op 29 mrt. 2017 21:37 schreef Bruno LEGAY <b.le...@ac-consulting.fr>:
> Hi Piotr,
> 
> I have quite a bit of experience in xml as well ;-)
> 
> So if I understand well, you want to use an xpath to some xml structure
> containing the data to merge…
> 
> Also the xml is data store in Oracle (or generated on the fly by Oracle).
> 
> something like :
> 
> 
>
>  my value
>  the name
>
> 
> 
> It is pretty easy to write a 4D function which will return the value for the
> given xpath… Let me know I can help you on this ;-)
> 
> Let say before the merge an instance of the document you parse the xml and
> keep the xml dom ref in a global var.
> Your function uses this global var to perform the xpath and return the value.
> When you finished the merge of the document, don’t forget to free the dom
> ref (or you will leak memory).
> 
> Xpath in 4D is pretty basic. It makes namespace pretty transparent
> (namespace can be a pain in a properly implemented xpath « engine »).
> But on the other hand, advanced xpath are not supported.
> It does relative or absolute path. You can use index (default is [1])
> So  parameters/debtor/nr   <=>   parameters/debtor[1]/nr[1]
> 
> In the approach above the structure will depend on your data and you will
> use 4D xpath to get the data.
> 
> This is a good idea.
> 
> You could also do something like this :
> 
> 
>my value
>the name
>...
> 
> 
> In the approach the xml structure is always the same. The key attribute is
> used to get the value.
> This is a pretty flexible way to do key-value arrays. It does not have the 
> index
> flexibility that xpath has.
> 
> 
> Cordialement,
> 
> Bruno LEGAY - A Consulting
> Tél. : +33 (0)1 41 74 13 79
> http://www.ac-consulting.fr<http://www.ac-consulting.fr/>
> 
>  Des compétences réunies pour des applications réussies
> 
> [cid:84BBEDAE-FDE8-4E61-8DAB-D1B1514121A0@home]
>   Merci de penser à l'environnement avant d'imprimer
> 
> 
> 
> 

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: 4D Write Pro using expressions with XML merge file (or JSON)

2017-04-03 Thread Koen Van Hooreweghe via 4D_Tech
Hi Piotr,

I haven't done that in 4D Write, but in a normal (template) text field which 
contains html tags and is run trough PROCESS 4D TAGS finally being sent as html 
e-mail body text.
In that particular case we fill a 4D object field with some info data. So the 
user can add the info he likes in the template using OB Get(...) in a 4DTEXT 
tag. The object has a plain structure, the properties are immediately 
accessible. But if nested objects were used, dot notation would be nice. But I 
guess the component of Bernard can be used for that purpose. Or wait until it 
gets built in 4D.

Kind regards,
Koen

Op 29-mrt.-2017, om 20:21 heeft Piotr Chabot Stadhouders via 4D_Tech 
<4d_tech@lists.4d.com> het volgende geschreven:

> Have you done something like I am planning to do in 4D Write?
> I am hoping for someone having already done this and saving me some pitfalls.




Compass bvba
Koen Van Hooreweghe
Kloosterstraat 65
9910 Knesselare
Belgium
tel +32 495 511.653

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: 4D Write Pro using expressions with XML merge file (or JSON)

2017-04-03 Thread Koen Van Hooreweghe via 4D_Tech
Hi Bernard,

Right. I should have written: 4D does not support dot notation (yet) natively 
in the OB Get and Set commands. But if I'm not mistaking, rumors say that it is 
coming...

Koen

Op 2-apr.-2017, om 13:53 heeft bernard--- via 4D_Tech <4d_tech@lists.4d.com> 
het volgende geschreven:

> 4D does not handle dot notation (not quite true : see 
> http://doc.4d.com/4Dv16/4D/16/QUERY-BY-ATTRIBUTE.301-3036512.en.html)
>  ; I have written a component published on jan 12
> 
> This component emulates 4D standard commands for objects such as OB Set or OB 
> Get to add access to properties or sub-objects by path with dot notation.
> It has been clearly inspired by OBJ_Module of Cannon Smith but differs by :



—
Koen Van Hooreweghe
—


**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: 4D Write Pro using expressions with XML merge file (or JSON)

2017-04-02 Thread bernard--- via 4D_Tech
Koen,

4D does not handle dot notation (not quite true : see 
http://doc.4d.com/4Dv16/4D/16/QUERY-BY-ATTRIBUTE.301-3036512.en.html 
) ; I 
have written a component published on jan 12

This component emulates 4D standard commands for objects such as OB Set or OB 
Get to add access to properties or sub-objects by path with dot notation.
It has been clearly inspired by OBJ_Module of Cannon Smith but differs by :
- it emulates standard commands and does not have commands by type
- it resolves paths with arrays elements
- it gives some advanced controls such as search in an array by the value of a 
property.
It does not intend to replace all functions of OBJ_Module.
You can download it here 
.
Method OBJ_Test gives several operational examples ; some functions are not yet 
implemented.

For this thread, I separate setter and getter ; the two commands have same 
syntax and you can copy the setter, change one letter and have the getter 
 OBJ_Set(MyObject;"MyPath";->MyValue)
 ... do something
 OBJ_Get(MyObject;"MyPath";->MyValue)

Direct access to the post where you can download the component : 
http://forums.4d.fr/Post//18896257/1/  

Cannon Smith has also added this feature in its component.

Cordialement,

Bernard Escaich


> Le 29 mars 2017 à 11:24, Koen Van Hooreweghe via 4D_Tech 
> <4d_tech@lists.4d.com> a écrit :
> 
> Hi Piotr,
> 
> I would advise JSON or rather 4D objects. 4D objects and JSON are not exactly 
> the same, but very closely related. JSON is actually a text representation of 
> a 4D object. The 4D debugger handles objects nicely too. You can store your 
> data into a 4D object and then retrieve the values in your 4D Write area 
> using your proposed commands. Unfortunately there is no dot notation (yet) 
> available. 
> But if your needs are not too complex, you could easily implement a basic 
> version yourself.
> 
> HTH
> Koen
> 
> Op 29-mrt.-2017, om 09:02 heeft Piotr Chabot Stadhouders via 4D_Tech 
> <4d_tech@lists.4d.com> het volgende geschreven:
> 
>> Has anybody already done "my new way" and have experience with this?
>> Does this make sense or is there a better way to do this?
>> Is JSON for example a better alternative over XML?
> 
> 
> 
> 
> Compass bvba
> Koen Van Hooreweghe
> Kloosterstraat 65
> 9910 Knesselare
> Belgium
> tel +32 495 511.653
> 
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: 4D Write Pro using expressions with XML merge file (or JSON)

2017-03-29 Thread Piotr Chabot Stadhouders via 4D_Tech
Hi Bruno,

Because it is easy to use xpath in 4D and easy to generate XML in Oracle this 
is exactly why I think this is a nice solution.

I am glad you think the same:-)

I assume one can also use attributes in xpath in 4D.

Gr,

Piotr

Op 29 mrt. 2017 21:37 schreef Bruno LEGAY :
Hi Piotr,

I have quite a bit of experience in xml as well ;-)

So if I understand well, you want to use an xpath to some xml structure 
containing the data to merge…

Also the xml is data store in Oracle (or generated on the fly by Oracle).

something like :


   
 my value
 the name
   


It is pretty easy to write a 4D function which will return the value for the 
given xpath…
Let me know I can help you on this ;-)

Let say before the merge an instance of the document you parse the xml and keep 
the xml dom ref in a global var.
Your function uses this global var to perform the xpath and return the value.
When you finished the merge of the document, don’t forget to free the dom ref 
(or you will leak memory).

Xpath in 4D is pretty basic. It makes namespace pretty transparent (namespace 
can be a pain in a properly implemented xpath « engine »).
But on the other hand, advanced xpath are not supported.
It does relative or absolute path. You can use index (default is [1])
So  parameters/debtor/nr   <=>   parameters/debtor[1]/nr[1]

In the approach above the structure will depend on your data and you will use 
4D xpath to get the data.

This is a good idea.

You could also do something like this :


   my value
   the name
   ...


In the approach the xml structure is always the same. The key attribute is used 
to get the value.
This is a pretty flexible way to do key-value arrays. It does not have the 
index flexibility that xpath has.


Cordialement,

Bruno LEGAY - A Consulting
Tél. : +33 (0)1 41 74 13 79
http://www.ac-consulting.fr

 Des compétences réunies pour des applications réussies

[cid:84BBEDAE-FDE8-4E61-8DAB-D1B1514121A0@home]
  Merci de penser à l'environnement avant d'imprimer





**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

RE: 4D Write Pro using expressions with XML merge file (or JSON)

2017-03-29 Thread Piotr Chabot Stadhouders via 4D_Tech
Hi Koen,

The reason I tend to XML is that I am planning to generate the merge data in 
Oracle
Only since Oracle 12c plus there are some JSON functions
So as I see it XML is kind of the standard in Oracle

Have you done something like I am planning to do in 4D Write?
I am hoping for someone having already done this and saving me some pitfalls.

Gr,

Piotr

> -Oorspronkelijk bericht-
> Van: Koen Van Hooreweghe [mailto:bvbacomp...@telenet.be]
> Verzonden: woensdag 29 maart 2017 11:25
> Aan: 4D iNug Technical <4d_tech@lists.4d.com>
> Onderwerp: Re: 4D Write Pro using expressions with XML merge file (or
> JSON)
> 
> Hi Piotr,
> 
> I would advise JSON or rather 4D objects. 4D objects and JSON are not
> exactly the same, but very closely related. JSON is actually a text
> representation of a 4D object. The 4D debugger handles objects nicely too.
> You can store your data into a 4D object and then retrieve the values in your
> 4D Write area using your proposed commands. Unfortunately there is no dot
> notation (yet) available.
> But if your needs are not too complex, you could easily implement a basic
> version yourself.
> 
> HTH
> Koen
> 
> Op 29-mrt.-2017, om 09:02 heeft Piotr Chabot Stadhouders via 4D_Tech
> <4d_tech@lists.4d.com> het volgende geschreven:
> 
> > Has anybody already done "my new way" and have experience with this?
> > Does this make sense or is there a better way to do this?
> > Is JSON for example a better alternative over XML?
> 
> 
> 
> 
> Compass bvba
> Koen Van Hooreweghe
> Kloosterstraat 65
> 9910 Knesselare
> Belgium
> tel +32 495 511.653
> 

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: 4D Write Pro using expressions with XML merge file (or JSON)

2017-03-29 Thread Koen Van Hooreweghe via 4D_Tech
Hi Piotr,

I would advise JSON or rather 4D objects. 4D objects and JSON are not exactly 
the same, but very closely related. JSON is actually a text representation of a 
4D object. The 4D debugger handles objects nicely too. You can store your data 
into a 4D object and then retrieve the values in your 4D Write area using your 
proposed commands. Unfortunately there is no dot notation (yet) available. 
But if your needs are not too complex, you could easily implement a basic 
version yourself.

HTH
Koen

Op 29-mrt.-2017, om 09:02 heeft Piotr Chabot Stadhouders via 4D_Tech 
<4d_tech@lists.4d.com> het volgende geschreven:

> Has anybody already done "my new way" and have experience with this?
> Does this make sense or is there a better way to do this?
> Is JSON for example a better alternative over XML?




Compass bvba
Koen Van Hooreweghe
Kloosterstraat 65
9910 Knesselare
Belgium
tel +32 495 511.653

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**