<div dir="auto"><div>Dear Prof. Masaki Aono,</div><div dir="auto"><br></div><div dir="auto">I am not sure if lxml.etree and xml.etree are completely equivalent.</div><div dir="auto"><br></div><div dir="auto">In my notebook etree is imported by</div><div dir="auto"><br></div><div dir="auto">import xml.etree.ElementTree as ET</div><div dir="auto"><br></div><div dir="auto">Do you want to give this a try ?</div><div dir="auto"><br></div><div dir="auto">The minimum Python version was referring to the linked documentation.</div><div dir="auto"><br></div><div dir="auto">Sincerely,<br><br><div data-smartmail="gmail_signature" dir="auto">---on the phone---</div><br><div class="gmail_quote" dir="auto"><div dir="ltr">On Mon, Jun 10, 2019, 11:14 PM Masaki Aono <<a href="mailto:aono@tut.jp" target="_blank" rel="noreferrer">aono@tut.jp</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <p>Dear Dr. Andreas Plesch</p>
    <p>Thank you for your advice. My Python version is 3.6.4 (> 3.4).</p>
    <p>I have tried.<br>
    </p>
    <p>Unfortunately, I have encountered an error when adding <i>short_empty_elements</i>
      option as below:</p>
    <p>from lxml import etree<br>
      xml = str0.encode('utf-8') # without converting to utf-8 encoding,
      errors have occurred<br>
      root = etree.fromstring(xml)</p>
    <p>x3domXML = etree.tostring(root, encoding = 'unicode', <i>short_empty_elements</i>=<b>False</b>)</p>
    <pre style="box-sizing:border-box;overflow:auto;font-family:monospace;font-size:14px;display:block;padding:1px 0px;margin:0px;line-height:inherit;word-break:break-all;color:rgb(0,0,0);background-color:rgb(255,255,255);border:0px;border-radius:0px;white-space:pre-wrap;vertical-align:baseline;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><span class="m_-6992373326001183697m_-1147013873556976865ansi-red-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(178,43,49);font-weight:bold">TypeError</span>                                 Traceback (most recent call last)
<span class="m_-6992373326001183697m_-1147013873556976865ansi-green-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(0,116,39);font-weight:bold"><ipython-input-8-89178b114c40></span> in <span class="m_-6992373326001183697m_-1147013873556976865ansi-cyan-fg" style="box-sizing:border-box;color:rgb(96,198,200)"><module></span>
<span class="m_-6992373326001183697m_-1147013873556976865ansi-green-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(0,116,39);font-weight:bold">----> 1</span><span class="m_-6992373326001183697m_-1147013873556976865ansi-yellow-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(178,125,18);font-weight:bold"> </span>str1 <span class="m_-6992373326001183697m_-1147013873556976865ansi-yellow-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(178,125,18);font-weight:bold">=</span> etree<span class="m_-6992373326001183697m_-1147013873556976865ansi-yellow-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(178,125,18);font-weight:bold">.</span>tostring<span class="m_-6992373326001183697m_-1147013873556976865ansi-yellow-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(178,125,18);font-weight:bold">(</span>root<span class="m_-6992373326001183697m_-1147013873556976865ansi-yellow-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(178,125,18);font-weight:bold">,</span> encoding <span class="m_-6992373326001183697m_-1147013873556976865ansi-yellow-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(178,125,18);font-weight:bold">=</span> <span class="m_-6992373326001183697m_-1147013873556976865ansi-blue-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(0,101,202);font-weight:bold">'unicode'</span><span class="m_-6992373326001183697m_-1147013873556976865ansi-yellow-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(178,125,18);font-weight:bold">,</span> short_empty_elements<span class="m_-6992373326001183697m_-1147013873556976865ansi-yellow-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(178,125,18);font-weight:bold">=</span><span class="m_-6992373326001183697m_-1147013873556976865ansi-green-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(0,116,39);font-weight:bold">False</span><span class="m_-6992373326001183697m_-1147013873556976865ansi-yellow-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(178,125,18);font-weight:bold">)</span>

<span class="m_-6992373326001183697m_-1147013873556976865ansi-green-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(0,116,39);font-weight:bold">src\lxml\etree.pyx</span> in <span class="m_-6992373326001183697m_-1147013873556976865ansi-cyan-fg" style="box-sizing:border-box;color:rgb(96,198,200)">lxml.etree.tostring</span><span class="m_-6992373326001183697m_-1147013873556976865ansi-blue-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(0,101,202);font-weight:bold">()</span>

<span class="m_-6992373326001183697m_-1147013873556976865ansi-red-intense-fg m_-6992373326001183697m_-1147013873556976865ansi-bold" style="box-sizing:border-box;color:rgb(178,43,49);font-weight:bold">TypeError</span>: tostring() got an unexpected keyword argument 'short_empty_elements'


I think for this option to work out, I may need Python version 3.7 or newer
from what I can tell the pages I visit, according to your url links.

Thanks anyway.

Sincerely,

</pre>
    <div class="m_-6992373326001183697m_-1147013873556976865moz-cite-prefix">On 2019/06/11 6:27, Andreas Plesch
      wrote:<br>
    </div>
    <blockquote type="cite">
      <pre class="m_-6992373326001183697m_-1147013873556976865moz-quote-pre">Dear Prof. Masaki Aono,

from what I can tell, you may need to use the
short_empty_elements=False option
(<a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-freetext" href="https://docs.python.org/3.7/library/xml.etree.elementtree.html#xml.etree.ElementTree.tostring" rel="noreferrer noreferrer" target="_blank">https://docs.python.org/3.7/library/xml.etree.elementtree.html#xml.etree.ElementTree.tostring</a>)
for Etree.toString:

x3domXML = ET.tostring(ET.XML(xml), encoding="unicode",
short_empty_elements=False)

see

<a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-freetext" href="https://mybinder.org/v2/gh/andreasplesch/conda/master/?urlpath=lab/tree/sphere.ipynb" rel="noreferrer noreferrer" target="_blank">https://mybinder.org/v2/gh/andreasplesch/conda/master/?urlpath=lab/tree/sphere.ipynb</a>

for an example. It is a relatively new Python option, so you will need
Python >= 3.4.

There is also an equivalent Etree.write method which generates a file:

<a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-freetext" href="https://docs.python.org/3.7/library/xml.etree.elementtree.html#xml.etree.ElementTree.ElementTree.write" rel="noreferrer noreferrer" target="_blank">https://docs.python.org/3.7/library/xml.etree.elementtree.html#xml.etree.ElementTree.ElementTree.write</a>

Hope this helps,

Sincerely,

Dr. Andreas Plesch

On Mon, Jun 10, 2019 at 4:33 PM Masaki Aono <a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-rfc2396E" href="mailto:aono@tut.jp" rel="noreferrer noreferrer" target="_blank"><aono@tut.jp></a> wrote:
</pre>
      <blockquote type="cite">
        <pre class="m_-6992373326001183697m_-1147013873556976865moz-quote-pre">Dear John and all,

I have just tried your

    str0 = toStringX3D(2)

as attached without doing anything.

Am I doing the right thing? I hope this helps somehow.

Sincerely,

On 2019/06/10 3:08, John Carlson wrote:

Dr. Aono, thanks for your efforts! toStringX3D is passed an indent level, I believe Don suggests 2.  That’s how far the hierarchical indentation in the produced XML code goes (number of “tabstops” in a way).  You can probably also use 0, but not sure.



<a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-freetext" href="http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3DObject.html#toStringX3D-int" rel="noreferrer noreferrer" target="_blank">http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3DObject.html#toStringX3D-int</a>-



so you would use it like this:



str0 = X3D0.toStringX3D(2)



Then proceed with the returned string as XML (parse, add closing tags per Andreas’ code, etc).



Please capture what you did to create a pip package or conda package and the installation process so we can publish amongst ourselves and other interested parties, thanks!



I apologise for the late reply, my thinker gave up for a while I guess.



So 4 more action items:



Use toStringX3D in your code
Use Andreas’ code to add any closing tags
Document how to create an installation package for x3dpsail and how to install.
Loren, look at Masaki Aono’s previous post and comment on if we did imports and import references correctly (4 should precede 3)



John



Sent from Mail for Windows 10



From: Masaki Aono
Sent: Friday, May 24, 2019 8:58 PM
To: John Carlson; Andreas Plesch
Cc: Brutzman, Donald (Don) (CIV); Vincent Marchetti; X3D Graphics public mailing list; <a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-abbreviated" href="mailto:lepeitso@nps.edu" rel="noreferrer noreferrer" target="_blank">lepeitso@nps.edu</a>
Subject: Re: compiling <a href="http://abox.future.py" rel="noreferrer noreferrer" target="_blank">abox.future.py</a> Re: Please instruct me what Ishouldbetocatch up withyouRe:X3D/XSeen Python API (PyX3D or X3DPy)



Dear John and all,

I did a bit.

</pre>
        <blockquote type="cite">
          <pre class="m_-6992373326001183697m_-1147013873556976865moz-quote-pre">I think the next step is to copy/paste the HelloWorld.py into the Jupyter notebook and see if it builds and exports XML correctly
</pre>
        </blockquote>
        <pre class="m_-6992373326001183697m_-1147013873556976865moz-quote-pre">I still don't understand how I should do toStringX3D.

Sincerely,

On 2019/05/23 12:07, John Carlson wrote:

Dr. Aono,



Thank you for your testing and installation efforts.  I think the next step is to copy/paste the HelloWorld.py into the Jupyter notebook and see if it builds and exports XML correctly, similar to Andreas Plesch’s binder, <a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-freetext" href="https://mybinder.org/v2/gh/andreasplesch/conda/master/?urlpath=lab/tree/sphere.ipynb" rel="noreferrer noreferrer" target="_blank">https://mybinder.org/v2/gh/andreasplesch/conda/master/?urlpath=lab/tree/sphere.ipynb</a> but with the package import as you have, and package prefixes found in HelloWorld.py.   The only thing we’re testing in this step is the “x3dpsail” namespace inside jupyter.  Whereas Andreas’ solution had no package.  Ideally, I’d like to get Loren’s signoff on what we’re doing re: packaging and imports after the notebook is published again.



You’ll have to change the toFileX3D to toStringX3D in HelloWorld.py to get the xml into the page (instead of doing the file open).   There are a couple of more XML strings you’ll have to add per Andreas’ notebook.  There may also be an issue with trusting the X3DOM javascript url.



See X3DObject (X3D in python) Javadoc here for toStringX3D method:



<a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-freetext" href="http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3DObject.html" rel="noreferrer noreferrer" target="_blank">http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3DObject.html</a>



We should probably collect a series of Jupyter notebooks into a test suite.  Something else to research.



I am sorry if this seems very basic. It takes small steps to get a long distance.  We really need to gather this information into a wiki or web page (or jupyter notebook!)



John



Sent from Mail for Windows 10



From: Masaki Aono
Sent: Wednesday, May 22, 2019 1:09 PM
To: John Carlson; Andreas Plesch
Cc: Brutzman, Donald (Don) (CIV); Vincent Marchetti; X3D Graphics public mailing list; <a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-abbreviated" href="mailto:lepeitso@nps.edu" rel="noreferrer noreferrer" target="_blank">lepeitso@nps.edu</a>
Subject: Re: compiling <a href="http://abox.future.py" rel="noreferrer noreferrer" target="_blank">abox.future.py</a> Re: Please instruct me what I shouldbetocatch up withyouRe:X3D/XSeen Python API (PyX3D or X3DPy)



Dear all,

I think I could install x3dpsail.

C:\Aono\ISO-2019\Python\John\pyjnius>pip freeze | grep x3dpsail
x3dpsail==0.1

Then, I did as follows:

</pre>
        <blockquote type="cite">
          <pre class="m_-6992373326001183697m_-1147013873556976865moz-quote-pre">python HelloWorld.py
</pre>
        </blockquote>
        <pre class="m_-6992373326001183697m_-1147013873556976865moz-quote-pre">which produced HelloWorld_RoundTrip.x3d.

The attached are the log + Jupyter log (PDF) that might be interesting, with no texture map though.

Sincerely,

On 2019/05/22 14:42, John Carlson wrote:

Dr Aono, Don, Andreas, Loren,



I have attempted to collect items necessary for building a x3dpsail package in the GitHub repository:



<a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-freetext" href="https://github.com/carlsonsolutiondesign/x3dpsail" rel="noreferrer noreferrer" target="_blank">https://github.com/carlsonsolutiondesign/x3dpsail</a>



If I was able to find you as an email address or user in the GitHub database, I added you as collaborators



We need, I believe:



A pip package
A conda package
A mybinder package
A conda-forge package



Please check your various attempts and successes to create packages into this repository.   Also modify README.md to include instructions.



I have added a HelloWorld.py which should run under all packaging techniques I hope.



I would hope we could find a way to add our package to any activated conda environment.



What I would like to have is the ability to release this folder as an “X3DPSAIL release” and maybe have Travis CI (or similar) deploy the release to various package repositories.



If you know someone with CI experience (I have some, but it’s nearly a decade old, with Java) who is willing to help, that would be terrific (Do they teach CI in schools?)  Let me know and I will add them.  I think we have a fairly simple release.   The only complication is the jar.



I will go back to reading recipes, etc from Andreas’ posts.



Thanks,



John



Sent from Mail for Windows 10



From: Masaki Aono
Sent: Tuesday, May 21, 2019 11:00 PM
To: John Carlson
Cc: Brutzman, Donald (Don) (CIV); Vincent Marchetti; X3D Graphics public mailing list
Subject: Re: compiling <a href="http://abox.future.py" rel="noreferrer noreferrer" target="_blank">abox.future.py</a> Re: Please instruct me what I should betocatch up withyouRe:X3D/XSeen Python API (PyX3D or X3DPy)



Dear John and all,

Thank you.

Actually I did svn cleanup and update, which did not solve my problems.

But, yes, I think I could download the necessary sub-folders.

I haven't yet downloaded x3d/content/examples/X3dForWebAuthors folder.

Sincerely,

On 2019/05/22 12:35, John Carlson wrote:

If svn checkout abends, you can cd to the folder, then run



svn cleanup

svn up



to continue the checkout.   Cleanup removes the abend.



You need the specifications folder, the stylesheets folder, the tooltips folder, and the x3d/content/examples/X3dForWebAuthors folder,  I believe for a clean build.

--

******************************************************

青野雅樹

豊橋技術科学大学 情報・知能工学系

知識データ工学・情報検索研究室

〒441-8580 豊橋市天伯町雲雀ヶ丘1-1

<a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-freetext" href="TEL:(0532)" rel="noreferrer noreferrer" target="_blank">TEL:(0532)</a> 44-6764

FAX:(0532) 44-6757



Masaki Aono

Professor

Knowledge Data Engineering Laboratory

Dept. of Computer Science and Engineering

Toyohashi University of Technology

1-1 Hibarigaoka, Tempaku-cho,

Toyohashi-shi, Aichi 441-8580 JAPAN

TEL: 81+532-44-6764

FAX:81+532-44-6757

email: <a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-abbreviated" href="mailto:aono@tut.jp" rel="noreferrer noreferrer" target="_blank">aono@tut.jp</a>

******************************************************



--

******************************************************

青野雅樹

豊橋技術科学大学 情報・知能工学系

知識データ工学・情報検索研究室

〒441-8580 豊橋市天伯町雲雀ヶ丘1-1

<a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-freetext" href="TEL:(0532)" rel="noreferrer noreferrer" target="_blank">TEL:(0532)</a> 44-6764

FAX:(0532) 44-6757



Masaki Aono

Professor

Knowledge Data Engineering Laboratory

Dept. of Computer Science and Engineering

Toyohashi University of Technology

1-1 Hibarigaoka, Tempaku-cho,

Toyohashi-shi, Aichi 441-8580 JAPAN

TEL: 81+532-44-6764

FAX:81+532-44-6757

email: <a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-abbreviated" href="mailto:aono@tut.jp" rel="noreferrer noreferrer" target="_blank">aono@tut.jp</a>

******************************************************



--

******************************************************

青野雅樹

豊橋技術科学大学 情報・知能工学系

知識データ工学・情報検索研究室

〒441-8580 豊橋市天伯町雲雀ヶ丘1-1

<a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-freetext" href="TEL:(0532)" rel="noreferrer noreferrer" target="_blank">TEL:(0532)</a> 44-6764

FAX:(0532) 44-6757



Masaki Aono

Professor

Knowledge Data Engineering Laboratory

Dept. of Computer Science and Engineering

Toyohashi University of Technology

1-1 Hibarigaoka, Tempaku-cho,

Toyohashi-shi, Aichi 441-8580 JAPAN

TEL: 81+532-44-6764

FAX:81+532-44-6757

email: <a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-abbreviated" href="mailto:aono@tut.jp" rel="noreferrer noreferrer" target="_blank">aono@tut.jp</a>

******************************************************



--
******************************************************
青野雅樹
豊橋技術科学大学 情報・知能工学系
知識データ工学・情報検索研究室
〒441-8580 豊橋市天伯町雲雀ヶ丘1-1
<a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-freetext" href="TEL:(0532)" rel="noreferrer noreferrer" target="_blank">TEL:(0532)</a> 44-6764
FAX:(0532) 44-6757

Masaki Aono
Professor
Knowledge Data Engineering Laboratory
Dept. of Computer Science and Engineering
Toyohashi University of Technology
1-1 Hibarigaoka, Tempaku-cho,
Toyohashi-shi, Aichi 441-8580 JAPAN
TEL: 81+532-44-6764
FAX:81+532-44-6757
email: <a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-abbreviated" href="mailto:aono@tut.jp" rel="noreferrer noreferrer" target="_blank">aono@tut.jp</a>
******************************************************
</pre>
      </blockquote>
      <pre class="m_-6992373326001183697m_-1147013873556976865moz-quote-pre"></pre>
    </blockquote>
    <pre class="m_-6992373326001183697m_-1147013873556976865moz-signature" cols="72">-- 
******************************************************
青野雅樹
豊橋技術科学大学 情報・知能工学系
知識データ工学・情報検索研究室
〒441-8580 豊橋市天伯町雲雀ヶ丘1-1
<a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-freetext" href="TEL:(0532)" rel="noreferrer noreferrer" target="_blank">TEL:(0532)</a> 44-6764
FAX:(0532) 44-6757

Masaki Aono
Professor
Knowledge Data Engineering Laboratory
Dept. of Computer Science and Engineering
Toyohashi University of Technology
1-1 Hibarigaoka, Tempaku-cho,
Toyohashi-shi, Aichi 441-8580 JAPAN
TEL: 81+532-44-6764
FAX:81+532-44-6757
email: <a class="m_-6992373326001183697m_-1147013873556976865moz-txt-link-abbreviated" href="mailto:aono@tut.jp" rel="noreferrer noreferrer" target="_blank">aono@tut.jp</a>
****************************************************** </pre>
  </div>

</blockquote></div></div></div>