<div dir="ltr">Actually, I don't see that recursion is a difficulty, since I only look at attributes, and not child nodes?<div><br></div><div>Guess I'll have to sleep on this one, but I just woke up?</div><div><br></div><div>Hmm.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 8, 2020 at 5:21 AM John Carlson <<a href="mailto:yottzumm@gmail.com">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">Here's critical code piece. I know the recursive calls are the problem. Would you suggest some kind of symbol table?</div><div dir="ltr"><br></div><div>Thanks!</div><div><br></div><div>John</div><div dir="ltr"><div><br></div><div>descendAttribute: function(element, at, parent, mapToMethod) {<br> console.log("descend attribute", element.nodeName, at)<br> var value = "";<br> if (at === "containerField") {<br> value = "children";<br> }<br> if (element !== null && typeof element !== 'undefined') {<br> for (var a in element.attributes) {<br> var attrs = element.attributes;<br> try {<br> parseInt(a);<br> if (attrs.hasOwnProperty(a) && attrs[a].nodeType == 2) {<br> var attr = attrs[a].nodeName;<br> if (attr === at) {<br> value = attrs[a].nodeValue;<br> }<br> if (attr === 'name') {<br> var fieldName = attrs[a].nodeValue;<br> }<br> }<br> } catch (e) {<br> console.error(e);<br> }<br> }<br> // find the value of to Proto field's type<br> if (element.parentNode) {<br> var parentName = this.descendAttribute(element.parentNode, "name");<br> // console.error("parent", parentName, "DEF", def, "fieldName", fieldName, element.parentNode);<br> var def = this.descendAttribute(element.parentNode, "DEF");<br> if (element.nodeName === "field" && at === 'type') {<br> if (element.parentNode.nodeName === "ExternProtoDeclare" ||<br> element.parentNode.parentNode.nodeName === "ProtoDeclare") {<br> if (!parentName) {<br> parentName = this.descendAttribute(element.parentNode.parentNode, "name");<br> }<br> if (typeof def === 'undefined') {<br> def = this.descendAttribute(element.parentNode.parentNode, "DEF");<br> }<br> if (typeof parentName !== 'undefined') {<br> if (typeof this.fieldTypeMapping[parentName] === 'undefined') {<br> this.fieldTypeMapping[parentName] = {};<br> }<br> // console.error("parent2", parentName, "DEF", def, "fieldName", fieldName);<br> this.fieldTypeMapping[parentName][fieldName] = value;<br> this.DEFMapping[def] = parentName;<br> // console.error("SET", parentName, this.fieldTypeMapping[parentName]);<br> // console.error("SET DEF", def, this.DEFMapping[def]);<br> }<br> }<br> } else if (element.nodeName === "fieldValue" && at === 'type') {<br> if (typeof parentName === 'undefined') {<br> // find name by looking up USE<br> var use = this.descendAttribute(element.parentNode, "USE");<br> parentName = this.DEFMapping[use];<br> // console.error("GET USE", use, this.DEFMapping[use]);<br> }<br> if (typeof parentName !== 'undefined') {<br> // console.error("GET", parentName, this.fieldTypeMapping[parentName]);<br> value = this.fieldTypeMapping[parentName][fieldName];<br> }<br> // console.error("parent3", parentName, "USE", use, "fieldName", fieldName, "value", value);<br> }<br> }<br> if (typeof parent !== 'undefined' && typeof mapToMethod !== 'undefined' && (value === "" || value === "children")) {<br> if (typeof mapToMethod[parent.nodeName] !== 'undefined' && typeof mapToMethod[parent.nodeName][element.nodeName] !== 'undefined') {<br> var tmpvalue = mapToMethod[parent.nodeName][element.nodeName].substring(3,4).toLowerCase()+mapToMethod[parent.nodeName][element.nodeName].substring(4); // lowercase first letter<br> if (tmpvalue !== 'proxy') { // must be set with containerField attribute<br> value = tmpvalue;<br> }<br> }<br> }<br> }<br> return value;<br> },<br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 8, 2020 at 3:54 AM John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">Okay, I have put in some tracing code into DOM2JSONSerializer. It appears that it is traversing up the tree as much as possible, even after it goes down. So I get to about 23 levels down, and can't proceed much farther. Seems like I'm playing a game of rogue?<div><br></div><div>Anyway, If you want to debug my code, it's at: <a href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/DOM2JSONSerializer.js" target="_blank">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/DOM2JSONSerializer.js</a></div><div><br></div><div>I suggest searching for `parentNode`. I'm going to try to get some sleep.</div><div><br></div><div>I feel like a newb writing such code. Thanks to people like Joe who make good test examples, we'll track this down.</div><div><br></div><div>None of this affects code in either X_ITE or X3DOM! My code in the JSONParser does JSON -> XML, not XML to JSON. DOM2JSONSerializer is not in X_ITE or X3DOM to my knowledge. It does affect the X3DJSONLD.</div><div><br></div><div>However, I am somewhat concerned that X_ITE may be "freezing" like my code when processing XML. It may be worth searching for parentNode in x_ite or x_ite_dom.</div><div><br>Use Joe's Skin Kick when testing.</div><div><br></div><div>John</div><div><br></div><div><br></div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 8, 2020 at 3:06 AM John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">New node.exe, no luck!<div><br>Trying browserify (the --node sets it up for nodejs instead of web browser).</div><div><br></div><div>$ browserify --node xml2all.js -o foo.js<br></div><div><br></div><div>Still waiting</div><div><br></div><div>$ node foo.js ../data/JoeSkinTexcoordDisplacerKick.x3d<br></div><div><br></div><div>hmmm. Guess I'll try WASM next, if possible!</div><div><br></div><div>John</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 8, 2020 at 2:35 AM John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hmm. Well, node with 32GB of memory doesn't seem to finish either. Looking into a new node.exe for my system.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 8, 2020 at 2:00 AM John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">X3dToJson.xslt wins (finishes).<div><br></div><div>This is why we don't want to implement the XML/DOM Prototype Expander in JavaScript (not that this message has anything to do with Prototype Expanding, more likely my newbie JavaScript experience). I think that ProtoExpanding on the server can work extremely well.</div><div><br></div><div>The players:<br></div><div><br></div><div>X3dToJson.xslt (winner)</div><div>$ sh don.sh ../data/JoeSkinTexcoordDisplacerKick.x3d<br></div><div><br></div><div>DOM2JSONSerializer.js (loser)</div><div>$ node xml2all.js ../data/JoeSkinTexcoordDisplacerKick.x3d<br></div><div><br></div><div>1 Point for XSLT!</div><div><br></div><div>John</div></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>