Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle json dump for inputs with CDATA? #553

Closed
8 tasks
cehbrecht opened this issue Dec 8, 2020 · 3 comments
Closed
8 tasks

How to handle json dump for inputs with CDATA? #553

cehbrecht opened this issue Dec 8, 2020 · 3 comments
Labels

Comments

@cehbrecht
Copy link
Collaborator

Description

When dumping (as json) a complex-input with format json then the data gets tagged with CDATA:

data["data"] = u'<![CDATA[{}]]>'.format(out)

Is this necessary?

This needs to be handled when loading the json dump again ... currently this is not the case.

See also #444.

Environment

  • operating system:
  • Python version:
  • PyWPS version: 4.2
  • source/distribution
  • git clone
  • Debian
  • PyPI
  • zip/tar.gz
  • other (please specify):
  • web server
  • Apache/mod_wsgi
  • CGI
  • other (please specify):

Steps to Reproduce

We have a workflow process with a workflow document in json:
https://github.com/roocs/rook/blob/858130631bf0a37c19a78e8e94961b7159846833/rook/processes/wps_orchestrate.py#L13

The json document is send with the wps request ... not as reference.

When we use the pywps scheduler extension the WPSRequest is dumped as a json file:

def dump(self):

In this case the workflow document (json format) is tagged by CDATA:

data["data"] = u'<![CDATA[{}]]>'.format(out)

When the json dump is loaded the CDATA tag is still part of the workflow document:

def load(cls, filename):

... and the json loader for the workflow document will fail.
https://github.com/roocs/rook/blob/858130631bf0a37c19a78e8e94961b7159846833/rook/processes/wps_orchestrate.py#L52

Additional Information

PR #444

@cehbrecht
Copy link
Collaborator Author

@huard how would you handle this?

Should we add the json data as it is without CDATA?

if self.data_format.mime_type in ["application/xml", "application/gml+xml", "text/xml"]:

Or when loading the json dump should the CDATA tag be removed?

instance.data = json_input['data']

@huard
Copy link
Collaborator

huard commented Dec 8, 2020

Hi @cehbrecht ,

I remember banging my head about this, trying to find a solution that worked across the board. I think the issue is that the json content may contain characters that will confuse the xml parser, hence the need to put everything inside CDATA tags.

I thought that the XML parser removed the CDATA tags automatically. Sorry I don't have a better answer...

@cehbrecht
Copy link
Collaborator Author

fixed by #555

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants