[x3d-public] X3DJSAIL XML output error I think. nested ' apostrophecharacters?
yottzumm at gmail.com
yottzumm at gmail.com
Mon Feb 27 02:50:40 PST 2017
I’ll have to figure out what to do for \" and " in DOM SFStrings so I’m doing the right thing. I’m currently replacing them with " in my JavaSerializer.js. Not sure if the main Java program should contain XML entities, or if that should be a feature of X3DJSAIL. Hopefully, you are handling &, < and > in SFStrings and MFstrings as well (hint). I should probably let X3DJSAIL convert " to " if possible, at least in SFStrings. We shall see if my DOM MFString handler passes mustard (do I have to check for " ", " " and " " as well?)—the handler probably will since we come from JSON originally. I have to remember that I’m working with DOM and not JSON or XML.
I will also readdress what is happening in SourceCode with single quotes. I think right now, the Java doesn’t compile, so there’s some work on my end. Right now, the monstrosity looks like:
} else if (element.childNodes.hasOwnProperty(cn) && node.nodeType == 4) {
str += " "+element.nodeName+n+'.setSourceCode("'+node.nodeValue.replace(/"/g, '\\"').replace(/\\n'/, "\\n'").split("\r\n").join('\\n\"+\n\"')+'");\n';
Oh, lovely, I just discovered appendSourceCode() that should help. Or I will use Array.map to do the substitutions after first splitting along newlines.
John
Sent from Mail for Windows 10
From: Don Brutzman
Sent: Monday, February 27, 2017 2:33 AM
To: yottzumm at gmail.com
Cc: X3D Graphics public mailing list; Roy Walmsley
Subject: Re: X3DJSAIL XML output error I think. nested ' apostrophecharacters?
so the error appears to be in the X3DJSAIL toStringX3D() exporter.
changed SFString and MFString export from entries like
stringX3D.append(" appinfo='").append(SFStringObject.toString(getAppinfo())).append("'");
to
stringX3D.append(" appinfo='").append(SFStringObject.toString(getAppinfo()).replace("'","'")).append("'");
looks like it worked, your next example Hub.java had correct line
meta0_0_14.setContent("wheels' hub");
for which X3DJSAIL was producing invalid content
<meta name='subject' content='wheels' hub'/>
but now creates an intermediate .x3d file, as desired, with
<meta name='subject' content='wheels' hub'/>
On 2/26/2017 10:54 PM, Don Brutzman wrote:
> looks like this might be a problem with handling of nested ' apostrophe characters?
>
> we could get rid of those in original source, but frankly they are there to provoke this kind of interoperability issue (bwa ha ha...)
>
> it is better to deal with them correctly since "content in the wild" is guaranteed to have them.
>
> On 2/26/2017 12:45 PM, yottzumm at gmail.com wrote:
>> From this line:
>>
>>
>>
>> <field name='isMaster' accessType='outputOnly' appinfo='Whether networkMode 'networkWriter' (output to network as master entity at writeInterval) is true/false' type='SFBool'/>
>>
>>
>>
>> See attached XML.
>>
>>
>>
>> John
>>
>>
>>
>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
>>
>>
>>
>> *From: *yottzumm at gmail.com <mailto:yottzumm at gmail.com>
>> *Sent: *Sunday, February 26, 2017 7:19 AM
>> *To: *Don Brutzman <mailto:brutzman at nps.edu>; X3D Graphics public mailing list <mailto:x3d-public at web3d.org>; Roy Walmsley <mailto:roy.walmsley at ntlworld.com>
>> *Subject: *X3DJSAIL XML output error I think. Could be the Java, not sure.
>>
>>
>>
>> www_web3d_org/x3d/content/examples/Basic/DistributedInteractiveSimulation/RadioCommunicationsPrototypes.java
>>
>> [Fatal Error] RadioCommunicationsPrototypes.new.json.intermediate.x3d:35:94: Element type "field" must be followed by either attribute specifications, ">" or "/>".
>>
>> Exception in thread "main" org.web3d.x3d.sai.X3DException: outputFile not writable: C:\Users\coderextreme\X3DJSONLD\www_web3d_org\x3d\content\examples\Basic\DistributedInteractiveSimulation\RadioCommunicationsPrototypes.new.json, IOException when transforming and creating fileName www_web3d_org\x3d\content\examples\Basic\DistributedInteractiveSimulation\RadioCommunicationsPrototypes.new.json, unable to save result: org.xml.sax.SAXParseException; systemId: file:/C:/Users/coderextreme/X3DJSONLD/www_web3d_org/x3d/content/examples/Basic/DistributedInteractiveSimulation/RadioCommunicationsPrototypes.new.json.intermediate.x3d; lineNumber: 35; columnNumber: 94; Element type "field" must be followed by either attribute specifications, ">" or "/>".
>>
>> at org.web3d.x3d.jsail.Core.X3DObject.toFileJSON(X3DObject.java:815)
>>
>> at www_web3d_org.x3d.content.examples.Basic.DistributedInteractiveSimulation.RadioCommunicationsPrototypes.main(RadioCommunicationsPrototypes.java:2956)
>>
>>
>>
>
>
> all the best, Don
all the best, Don
--
Don Brutzman Naval Postgraduate School, Code USW/Br brutzman at nps.edu
Watkins 270, MOVES Institute, Monterey CA 93943-5000 USA +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170227/f0b1791e/attachment-0001.html>
More information about the x3d-public
mailing list