[x3d-public] feature request for X3DJSAIL

John Carlson yottzumm at gmail.com
Mon Dec 18 02:43:34 PST 2017


I would like to set the XsltEngine ConfigurationProperty from the command line.

Small favor will help immensely I think.

-Dx3djsail.xslt.engine=NATIVE_JAVA

Or:

-Dx3djsail.xslt.engine=SAXON9HE

Or:

Another way?

And how do I put it in the build.xml? Trying to put it before the java class….

Thanks,

John
Sent from Mail for Windows 10

From: John Carlson
Sent: Thursday, December 14, 2017 6:03 AM
To: Don Brutzman
Cc: x3d-public at web3d.org
Subject: RE: feature request for X3DJSAIL

Thanks Don, I knew I should have looked at ConfigurationProperties. Is there a way to load ConfigurationProperties through a Properties file?  I see the use of Properties in BrowserFactory, but I think it may be unrelated.

I’m not saying I’m fond of Properties files, or want you to implement it, as it appears counter to web-development in general.  In otherwords, I can deal with it if my only option is to set it in the program itself.  In fact, I would prefer it if you didn’t use Properties at all for portability.

It’s much more important that we figure out how do export to JSON (for use in the intermediate step of the to JavaScript serializer).  And how that is different (or even the same) from the JSON produced from X3dToJson.xslt for example.

If on the other hand, you want to pursue a stylesheet solution for generating JavaScript (and a variety of other programming languages we’re working on), like you did with X3dToJava.xslt, that’s okay by me, as I’ve suggested.  I don’t expect to be supporting any stylesheets myself, and am still pursuing other options for DOM->JSON conversion, so I am freed from stylesheets.

As usual, I want to do the stylesheets in the web browser, and so far, it looks like that is not a viable option for low cost (free).  I would love to be proved wrong, and that I can use X3dToJson.xlst in the web browser for free.  Ideally, I would have no server-side dependencies besides serving files, and perhaps file search.    The use case I am trying to solve is where someone enters XML into X3DJSONLD and wants a conversion to JSON.  I believe this is mostly solved with server-side support at this time.  My attempts at using Saxon-CE have failed in the past, and it may be that I even attempt a conversion with Saxon-CE at this point, and the results are not what I expect.  To see for yourself, visit https://coderextreme.net/X3DJSONLD/ and click on the “here” in the sentence that appears on the website: Click here to load X3D XML into Cobweb and XML X3DOM viewer.

Observe the alerts, then peruse the JSON result at left to see the problems.   The result JSON doesn’t even parse properly and if you try to load it, it will blank out the JSON. Whoops!  As far as I know, the original JSON that does come from the XML does parse properly.

It looks like EXI is broken in X3DJSONLD.  As I download the code from external sources, perhaps something broke, not sure.  I will have to look into it.

Thanks,

John

Sent from Mail for Windows 10

From: Don Brutzman
Sent: Wednesday, December 13, 2017 12:19 PM
To: John Carlson
Cc: x3d-public at web3d.org
Subject: Re: feature request for X3DJSAIL

Thanks for the interesting suggestion John.  Hmmm...

On 12/10/2017 11:49 PM, John Carlson wrote:
> Provide an argument or CommandLine parameter or ConfigurationProperty which allows you to bypass the validation check, or at least ignore the results, and produce a partial output file (XML and JSON only initially).

It looks like your wish is already granted as part of ConfigurationProperties class, available to X3DJSAIL programmers.  Also some fine-tuning options.

Looking at X3DObject, am finding the following code block under toFileX3D(fileName) method.  Note inclusion of ConfigurationProperties.isValidationExceptionAllowed() call.  Javadoc follows.

==============================================
                public File toFileX3D(String fileName)
                {
                                String errorNotice = new String();
                                if ((fileName == null || fileName.isEmpty()))
                                {
                                                throw new X3DException("toFileX3D(fileName) fileName not provided;" +
                                                                " be sure to end with extension \"" + FILE_EXTENSION_X3D + "\"");
                                }
                                if (!fileName.endsWith(FILE_EXTENSION_X3D) && !fileName.endsWith(FILE_EXTENSION_XML))
                                {
                                                throw new X3DException("fileName " + fileName + " does not end with extension " +
                             "\"" + FILE_EXTENSION_X3D + "\" or " +
                             "\"" + FILE_EXTENSION_XML + "\"");
                                }
                                Path outputFilePath = Paths.get(fileName);
                                if (ConfigurationProperties.isDebugModeActive()) // debug check, defaults to local directory
                                {
                                                errorNotice += "[debug] Output file path=" + outputFilePath.toAbsolutePath() + "\n";
                                                System.out.println (errorNotice);
                                }
                                
                                // http://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html
                                // http://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html
                                Charset charset = Charset.forName(ConfigurationProperties.XML_ENCODING_DECLARATION_DEFAULT); // "UTF-8"
                                                                                                                                                
                                try
                                {              
                                                validate(); // strict checks before serializing scene and saving file
                                }
                                catch (Exception e)
                                {
                                                System.out.println (e); // output exception but allow serialization to continue, file may be editable
                                                e.printStackTrace();
                                                if (ConfigurationProperties.isValidationExceptionAllowed())
                                                                System.out.println ("Output serialization allowed to continue, file may be editable...");
                                                else throw (e);
                                }
[...]

==============================================
public static boolean isValidationExceptionAllowed()

Indicate whether partial results are allowed if validation exception occurs when serializing scene output.

Returns:
     whether validation exceptions are allowed (and operation continues)

http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/ConfigurationProperties.html#isValidationExceptionAllowed--

==============================================
public static void setValidationExceptionAllowed(boolean newValidationExceptionAllowed)

Set whether partial results are allowed (and operation continues) if validation exception occurs when serializing scene output. Can be useful technique for debugging, default value is false for strict operation.
Warning: setting value to true permits creation of an invalid scene graph.

Parameters:
     newValidationExceptionAllowed - whether validation exceptions are allowed (and operation continues)

http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/ConfigurationProperties.html#setValidationExceptionAllowed-boolean-

==============================================
public static boolean isCreationConnectionValidationExceptionAllowed()

Indicate whether continuation is allowed if validation exception occurs when creating an object.
Warning: TODO experimental.

Returns:
     whether validation exceptions are allowed (and operation continues) during object creation

http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/ConfigurationProperties.html#isCreationConnectionValidationExceptionAllowed--

==============================================
public static void setCreationConnectionValidationExceptionAllowed(boolean newCreationConnectionValidationExceptionAllowed)

Set whether partial results are allowed (and operation continues) if validation exception occurs when creating an object. Can be useful technique for debugging, default value is true for permissive order of object creation.
Warning: be sure to validate() this scene once construction is complete.
Warning: TODO experimental.

Parameters:
     newCreationConnectionValidationExceptionAllowed - whether validation exceptions are allowed (and object creation continues)

http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/ConfigurationProperties.html#setCreationConnectionValidationExceptionAllowed-boolean-

==============================================

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/20171218/e84b6261/attachment-0001.html>


More information about the x3d-public mailing list