[x3d-public] compiling abox.future.py Re: Please instruct me what Ishouldbetocatch up withyouRe:X3D/XSeen Python API (PyX3D or X3DPy)

Andreas Plesch andreasplesch at gmail.com
Tue Jun 11 03:35:48 PDT 2019


Dear Prof. Masaki Aono,

this is good news.  *short_empty_elements*=*False*  generates HTML
compatible tag syntax with full closing tags: instead of <Material />,
<Material></Material> is output. We need HTML rather than XML on the
jupyter page, since the page itself is a HTML document. There are other
options such as an IFrame or using a wrapper X3D with an Inline to the
actual content. which could accommodate XML but generating the full closing
tag is the simplest solution.

Looking up lxml, I found that

lxml.etree.tostring(root, method= 'html')

may also work to generate full closing tags using lxml but I did not have a
chance to test. Would you like to try that as well ?

Sincerely,

On Tue, Jun 11, 2019, 12:43 AM Masaki Aono <aono at tut.jp wrote:

> Dear Dr. Andreas Plesch
>
> Thank you.
>
>    * import* xml.etree.ElementTree *as* ET
>
> makes things better.
>
> I wonder what would be the benefit of using *short_empty_elements*=*False
> parameter?*
>
> Sincerely,
> On 2019/06/11 12:39, Andreas Plesch wrote:
>
> Dear Prof. Masaki Aono,
>
> I am not sure if lxml.etree and xml.etree are completely equivalent.
>
> In my notebook etree is imported by
>
> import xml.etree.ElementTree as ET
>
> Do you want to give this a try ?
>
> The minimum Python version was referring to the linked documentation.
>
> Sincerely,
>
> ---on the phone---
>
> On Mon, Jun 10, 2019, 11:14 PM Masaki Aono <aono at tut.jp wrote:
>
>> Dear Dr. Andreas Plesch
>>
>> Thank you for your advice. My Python version is 3.6.4 (> 3.4).
>>
>> I have tried.
>>
>> Unfortunately, I have encountered an error when adding
>> *short_empty_elements* option as below:
>>
>> from lxml import etree
>> xml = str0.encode('utf-8') # without converting to utf-8 encoding, errors
>> have occurred
>> root = etree.fromstring(xml)
>>
>> x3domXML = etree.tostring(root, encoding = 'unicode',
>> *short_empty_elements*=*False*)
>>
>> TypeError                                 Traceback (most recent call last)<ipython-input-8-89178b114c40> in <module>----> 1 str1 = etree.tostring(root, encoding = 'unicode', short_empty_elements=False)
>> src\lxml\etree.pyx in lxml.etree.tostring()
>> TypeError: 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,
>>
>>
>> On 2019/06/11 6:27, Andreas Plesch wrote:
>>
>> Dear Prof. Masaki Aono,
>>
>> from what I can tell, you may need to use the
>> short_empty_elements=False option
>> (https://docs.python.org/3.7/library/xml.etree.elementtree.html#xml.etree.ElementTree.tostring)
>> for Etree.toString:
>>
>> x3domXML = ET.tostring(ET.XML(xml), encoding="unicode",
>> short_empty_elements=False)
>>
>> see
>> https://mybinder.org/v2/gh/andreasplesch/conda/master/?urlpath=lab/tree/sphere.ipynb
>>
>> 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:
>> https://docs.python.org/3.7/library/xml.etree.elementtree.html#xml.etree.ElementTree.ElementTree.write
>>
>> Hope this helps,
>>
>> Sincerely,
>>
>> Dr. Andreas Plesch
>>
>> On Mon, Jun 10, 2019 at 4:33 PM Masaki Aono <aono at tut.jp> <aono at tut.jp> wrote:
>>
>> 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.
>>
>>
>> http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3DObject.html#toStringX3D-int-
>>
>>
>>
>> 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; lepeitso at nps.edu
>> Subject: Re: compiling abox.future.py Re: Please instruct me what Ishouldbetocatch up withyouRe:X3D/XSeen Python API (PyX3D or X3DPy)
>>
>>
>>
>> Dear John and all,
>>
>> I did a bit.
>>
>>
>> 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
>>
>> 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, https://mybinder.org/v2/gh/andreasplesch/conda/master/?urlpath=lab/tree/sphere.ipynb 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:
>>
>>
>> http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3DObject.html
>>
>>
>>
>> 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; lepeitso at nps.edu
>> Subject: Re: compiling abox.future.py 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:
>>
>>
>> python HelloWorld.py
>>
>> 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:
>>
>>
>> https://github.com/carlsonsolutiondesign/x3dpsail
>>
>>
>>
>> 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 abox.future.py 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
>> TEL:(0532) 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: aono at tut.jp
>>
>> ******************************************************
>>
>>
>>
>> --
>>
>> ******************************************************
>>
>> 青野雅樹
>>
>> 豊橋技術科学大学 情報・知能工学系
>>
>> 知識データ工学・情報検索研究室
>>
>> 〒441-8580 豊橋市天伯町雲雀ヶ丘1-1
>> TEL:(0532) 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: aono at tut.jp
>>
>> ******************************************************
>>
>>
>>
>> --
>>
>> ******************************************************
>>
>> 青野雅樹
>>
>> 豊橋技術科学大学 情報・知能工学系
>>
>> 知識データ工学・情報検索研究室
>>
>> 〒441-8580 豊橋市天伯町雲雀ヶ丘1-1
>> TEL:(0532) 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: aono at tut.jp
>>
>> ******************************************************
>>
>>
>>
>> --
>> ******************************************************
>> 青野雅樹
>> 豊橋技術科学大学 情報・知能工学系
>> 知識データ工学・情報検索研究室
>> 〒441-8580 豊橋市天伯町雲雀ヶ丘1-1TEL:(0532) 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: aono at tut.jp
>> ******************************************************
>>
>> --
>> ******************************************************
>> 青野雅樹
>> 豊橋技術科学大学 情報・知能工学系
>> 知識データ工学・情報検索研究室
>> 〒441-8580 豊橋市天伯町雲雀ヶ丘1-1TEL:(0532) 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: aono at tut.jp
>> ******************************************************
>>
>> --
> ******************************************************
> 青野雅樹
> 豊橋技術科学大学 情報・知能工学系
> 知識データ工学・情報検索研究室
> 〒441-8580 豊橋市天伯町雲雀ヶ丘1-1TEL:(0532) 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: aono at tut.jp
> ******************************************************
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190611/e10b2ffa/attachment-0001.html>


More information about the x3d-public mailing list