#1 2018-02-12 21:33:44

mdbs99
Member
From: Rio de Janeiro, Brazil
Registered: 2018-01-20
Posts: 132
Website

Is there a XPATH implementation?

I know that is possible to work with XML instead JSON (see here). But is there an XPATH implementation to work with?

FPC has an implementation of XPATH but, it's based on WideString. I would like to know if we have a (fastest) implementation by Synopse, which works on Delphi and FPC.

Offline

#2 2018-02-13 12:07:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Is there a XPATH implementation?

No, XML support is very small, and not intended to be bigger...
We are JSON-grounded, which is a per-representation format, whereas XML is a strongly typed format.

There won't be any XPATH implementation, since there is no real XML implementation available - just simple (but fast) JSON to XML-compatible conversion.

Offline

#3 2018-02-13 14:38:38

mdbs99
Member
From: Rio de Janeiro, Brazil
Registered: 2018-01-20
Posts: 132
Website

Re: Is there a XPATH implementation?

All right.
But, as I have many systems that works with XML, what is the simplest way to use mORMot to work with?
In mostly cases, I need to receive a XML, parse (using XPATH), create a new one, and send it back.
I mean, is that possible (and fast) to use some mORMot "XML to JSON" functions, parse the JSON, create a new one, and use "JSON to XML" to send it as XML at the end?

Last edited by mdbs99 (2018-02-13 14:52:55)

Offline

#4 2018-02-13 15:17:24

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Is there a XPATH implementation?

There is a JSON to XML function, but not the reverse one. wink

Offline

#5 2018-02-13 20:16:13

mdbs99
Member
From: Rio de Janeiro, Brazil
Registered: 2018-01-20
Posts: 132
Website

Re: Is there a XPATH implementation?

It's strange do not have anyone complain about missing XML.
Many companies use WebServices and XML is the mostly used.

Offline

#6 2018-02-14 07:28:57

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Is there a XPATH implementation?

XML is so 90's.... :-)

Offline

#7 2018-02-14 11:48:19

mdbs99
Member
From: Rio de Janeiro, Brazil
Registered: 2018-01-20
Posts: 132
Website

Re: Is there a XPATH implementation?

Just like Pascal  smile

Offline

#8 2018-02-14 14:49:56

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Is there a XPATH implementation?

Not 2018's object pascal! wink

Plain pascal is so disco / 70's...

Offline

#9 2018-02-14 15:08:59

mdbs99
Member
From: Rio de Janeiro, Brazil
Registered: 2018-01-20
Posts: 132
Website

Re: Is there a XPATH implementation?

Touché!

Offline

#10 2018-02-14 15:11:51

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Is there a XPATH implementation?

mdbs99,

This might be useful for you.   You can pick the functionality you need and combine with the mORMot infrastructure.

https://github.com/benibela/internettools

Offline

#11 2018-02-14 16:52:55

mdbs99
Member
From: Rio de Janeiro, Brazil
Registered: 2018-01-20
Posts: 132
Website

Re: Is there a XPATH implementation?

Hello Leslie7
Actually, FPC already has a XPATH implementation... but this project could be interesting. Thanks for the tip.

Offline

#12 2018-02-19 04:03:45

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Is there a XPATH implementation?

XML is too verbose and is such a mess, JSON is better.

Food for thought: http://jmespath.org/


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#13 2018-02-19 10:26:13

hnb
Member
Registered: 2015-06-15
Posts: 291

Re: Is there a XPATH implementation?

the reality is not perfect and usage of JSON is not always possible. Personally I like the idea of :

https://www.npmjs.com/package/xml-js

some ideas from xml-js may be used in mORMot.


best regards,
Maciej Izak

Offline

#14 2018-02-19 10:44:56

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,534
Website

Re: Is there a XPATH implementation?

We use xmltojson and jsontoxml with SyNode in production (not very fast, but work for our tasks)

Offline

#15 2018-02-19 12:14:25

mdbs99
Member
From: Rio de Janeiro, Brazil
Registered: 2018-01-20
Posts: 132
Website

Re: Is there a XPATH implementation?

edwinsn wrote:

XML is too verbose and is such a mess, JSON is better.

Food for thought: http://jmespath.org/

It's not about verbosity or not. It's about integration with other systems.
As you can see above, there are some that think the same.

Offline

#16 2018-02-20 09:03:13

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Is there a XPATH implementation?

@mdbs99, yes, you have a valid point smile

@mpv, do we have a compatible Node.Js package list for syNode?


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB