[x3d-public] x3d document structure for autocomplete
Andreas Plesch
andreasplesch at gmail.com
Tue May 2 13:27:38 PDT 2023
Thanks. It does look a little like json schema:
https://www.web3d.org/specifications/x3d-3.3-JSONSchema.json
https://github.com/sagold/json-schema-library
looks useful. Perhaps the getTemplate method could be used to generate
resolved json for each node.
The object model xml could also be used directly:
https://www.web3d.org/specifications/X3dUnifiedObjectModel-3.3.xml
after parsing into a dom.
The difficulty would be to extract all possible concrete node names
for SF/MFNode type fields.
https://www.web3d.org/specifications/AllX3dElementsAttributes3.3.xml
would be easy to use to generate attribute names and default values
for each node. That would be already quite useful.
I went ahead and converted AllX3dElementsAttributes3.3.xml to json with:
all=parsedXML.children[0].children
function getattr(n) { at={}; n.getAttributeNames().forEach( a =>
at[a]=[n.getAttribute(a)]); return at }
tags={};[...all].forEach( (n) => tags[n.localName]={"attrs": getattr(n)} )
JSON.stringify(tags)
and included it in
https://andreasplesch.github.io/Library/Viewer/index.html
It seems to work fine.
-Andreas
On Tue, May 2, 2023 at 2:27 PM John Carlson <yottzumm at gmail.com> wrote:
>
> It’s not JSON. Property names in JSON have double quotes.
>
> My advice is to generate the JavaScript from X3DUOM. Examples are in X3DJSONLD/src/main/python.
>
> I realize this is using way too many languages. Please provide a JavaScript generator instead of Python.
>
> It kind of looks like you’re trying to duplicate JSON Schema. I believe there are additional parts beyond JSON Schema core for creating GUIs.
>
> Let’s continue the discussion.
>
> John
>
> On Tue, May 2, 2023 at 12:56 PM Andreas Plesch <andreasplesch at gmail.com> wrote:
>>
>> The editor which is used for
>>
>> https://andreasplesch.github.io/Library/Viewer/index.html
>>
>> has autocomplete functionality for xml. It is based on a json data
>> structure as a source to suggest completions. The json data looks like
>> this:
>>
>> x3d_tags = {
>> X3D: {
>> children: ["Scene"]
>> },
>> Transform: {
>> attrs: {
>> rotation: ["0 1 0 0"],
>> scale: ["1 1 1"],
>> translation: ["0 0 0 0"]
>> }
>> },
>> Shape: {
>> children: ["Appearance", "IndexedLineSet", "Box",
>> "Extrusion"],
>> },
>> Appearance: {
>> children: ["Material", "ImageTexture", "PixelTexture"],
>> },
>> Material: {
>> attrs: {
>> "diffuseColor": ["0.8 0.8 0.8"],
>> "emissiveColor": ["0 0 0"],
>> "specularColor": ["0.1 0.1 0.1"],
>> "shininess": ["0.1"],
>> "transparency": ["0"]
>> }
>> }
>> };
>>
>> Hopefully, this will not be mangled too badly. Possible tags are
>> listed as keys which then have possible attribute options and children
>> tag options as values.
>>
>> What would be the closest x3d document structure definition to
>> construct a complete autocomplete from ?
>>
>> Thanks, Andreas
>>
>>
>>
>> --
>> Andreas Plesch
>> Waltham, MA 02453
>>
>> _______________________________________________
>> x3d-public mailing list
>> x3d-public at web3d.org
>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
--
Andreas Plesch
Waltham, MA 02453
More information about the x3d-public
mailing list