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

XML elements not imported when tags not presents in the IDML file. #53

Open
sinarchy opened this issue May 18, 2020 · 5 comments
Open

Comments

@sinarchy
Copy link

Hey, I try to import an XML to the package using import_xml method, but it just keeps adding the attributes, but not the elements.
Any ideas?

BTW, is there any way to change 'import XML options'? I know there are elements defined on Resources/Preferences.xml

@Starou
Copy link
Owner

Starou commented May 18, 2020

Hi,

Does the import of the XML file on the Structure works correctly from InDesign?
Are you using a with context to perform the import?

Here an example: https://github.com/Starou/SimpleIDML/blob/master/tests/regressiontests/idml.py#L326

@sinarchy
Copy link
Author

sinarchy commented May 18, 2020

Thanks for your reply @Starou
Yes, the XML works fine when imported via Indesign (with all import options set unchecked).
I have added my IDML and my XMl to my project folder and used with:

with IDMLPackage('my_idml.Idml) as idmlfile, open(my_xml.xml,'r') as xml:
    with idmlfile.import_xml(xml.read(),'/Root') as f:
        output = f.export_xml()

Output:
Process finished with error code 0.

When entered:

Print (f.export_xml())

The output is:

<Root attrib1="value1" attrib2="value2" />

My_xml.xml file content:

<article attrib1="value1" attrib2="value2">
<title>This is title</title>
<body>Body text goes here</body>
</article>

@Starou
Copy link
Owner

Starou commented May 19, 2020

Seems correct. I need to see the actual files (xml and idml) I guess.

@sinarchy
Copy link
Author

Thanks.
My IDML is a blank file and the XML is the same as I've posted, btw, I've attached them here as a zip archive (GitHub doesn't allow uploading XML).
IDML.zip

PS. Shouldn't newly imported XML structure, override the 'Root' tag?

@Starou
Copy link
Owner

Starou commented May 22, 2020

I have to look into it but my guess is that your IDML document does not contains the tags from your XML in its tag list.
I am marking this a bug that needs to be fixed.
Thanks.

@Starou Starou changed the title XML elements not imported XML elements not imported when tags not presents in the IDML file. May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants