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

Unable to convert DOM node #5

Closed
jonnymaserati opened this issue Feb 16, 2021 · 3 comments
Closed

Unable to convert DOM node #5

jonnymaserati opened this issue Feb 16, 2021 · 3 comments

Comments

@jonnymaserati
Copy link

jonnymaserati commented Feb 16, 2021

Hi there

I'm trying out your code to see if I can import some Volve data but I'm not able to read in a file without getting the following error:

Unable to convert DOM node {http://www.witsml.org/schemas/1series}priv_objectGrowing at <unknown>[1:4462] to binding

Some additional info:

Exception has occurred: UnrecognizedContentError
Invalid content priv_objectGrowing at <unknown>[1:4462] (expect {http://www.witsml.org/schemas/1series}itemState or {http://www.witsml.org/schemas/1series}serviceCategory or {http://www.witsml.org/schemas/1series}comments or {http://www.witsml.org/schemas/1series}acquisitionTimeZone or {http://www.witsml.org/schemas/1series}defaultDatum or {http://www.witsml.org/schemas/1series}privateGroupOnly or {http://www.witsml.org/schemas/1series}extensionAny or {http://www.witsml.org/schemas/1series}extensionNameValue)
  File "/tmp/build/80754af9/python_1573076469108/work/Modules/pyexpat.c", line 461, in EndElement

Looking a bit closer, it appears that there's a bunch of tags with a priv_ prefix that are casing the issue. Is it possible to add a try except for UnrecognizedContentError if there's an unofficial tag and have these tags ignored?

@kle043
Copy link
Owner

kle043 commented Feb 16, 2021

Hi, it's a while since I looked at the schema, but would suspect that the priv_ nodes are not part of witsml and placed somewhere where the schema says no to wildcard elements.

Don't think I want to change the code to allow invalid documents, and it would be difficult since the bindings uses pyxb that does quite a good job in validating;)

But if you still think the bindings can be useful I guess it would just take a couple of lines of code to fix the document, something like

from komle.bindings.v1411.read import witsml
from lxml import etree

tree=etree.parse("MY_VOLVE_FILE_WITH_PRIV_NODE.xml")

for not_witsml in tree.xpath("//*[starts-with(name(), 'priv_')]"):
    not_witsml.getparent().remove(not_witsml)

logs = witsml.CreateFromDocument(etree.tostring(tree))

@jonnymaserati
Copy link
Author

Yeah, I was thinking something similar, a pre-processing step to remove the offensive tags, but your suggested code is more elegant than what I would have come up with!

I don't think these tags are used, it looks like the operator has added them for internal use so I'm okay not processing them.

Thank you!

@kle043
Copy link
Owner

kle043 commented Feb 16, 2021

Vendors often add some private stuff, although they should have used the customData tag for that I suspect.

Thanks for the update on volve witsml:)

@kle043 kle043 closed this as completed Feb 16, 2021
@kle043 kle043 pinned this issue Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants