Menu

#35 Problem with VRML/X3D export

open
None
5
2012-04-17
2011-02-18
No

When I click on 'File->Save as...' and then select VRML (*.wrl) or X3D (*.x3dv), I get an error:

WARNUNG: null could not be saved.
javax.xml.transform.TransformerConfigurationException: Die Translet-Klasse 'X3dToVrml97' konnte nicht geladen werden.
at com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl.defineTransletClasses(TemplatesImpl.java:331)
at com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl.getTransletInstance(TemplatesImpl.java:349)
at com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl.newTransformer(TemplatesImpl.java:382)
at de.grogra.pf.io.XSLTFilter.transform(XSLTFilter.java:91)
at de.grogra.pf.io.XSLTFilter.write(XSLTFilter.java:77)
at de.grogra.pf.io.LazyFilter.write(LazyFilter.java:71)
at de.grogra.pf.io.StreamAdapter.write(StreamAdapter.java:127)
at de.grogra.pf.io.StreamAdapter.write(StreamAdapter.java:429)
at de.grogra.pf.io.StreamAdapter.write(StreamAdapter.java:381)
at de.grogra.pf.ui.Workbench.save(Workbench.java:654)
at de.grogra.pf.ui.Workbench.saveAs(Workbench.java:514)
at de.grogra.pf.ui.Workbench.saveAs(Workbench.java:535)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at de.grogra.util.Utils.invoke(Utils.java:727)
at de.grogra.util.Utils.invokeStatic(Utils.java:695)
at de.grogra.util.Utils.invoke(Utils.java:684)
at de.grogra.pf.ui.registry.CommandItem.run(CommandItem.java:259)
at de.grogra.pf.ui.registry.CommandItem.eventOccured(CommandItem.java:347)
at de.grogra.pf.ui.tree.RegistryAdapter.eventOccured(RegistryAdapter.java:120)
at de.grogra.pf.ui.tree.UITreePipeline$Node.handleEvent(UITreePipeline.java:170)
at de.grogra.pf.ui.tree.UITreePipeline.eventOccured(UITreePipeline.java:637)
at de.grogra.pf.ui.awt.ButtonSupport$Dispatcher.run(ButtonSupport.java:83)
at de.grogra.imp.IMPJobManager.run(IMPJobManager.java:550)
at java.lang.Thread.run(Thread.java:662)

Discussion

  • Reinhard Hemmerling

    When saving the current scene as VRML or X3D, the scene is transformed from mimetype model/x3d+xml to mimetypes model/vrml or model/x3d+vrml. The transformation is performed by an XSLT file called X3dToVrml97.xslt (can be obtained from http://www.web3d.org/x3d/content/X3dToVrml97.xslt ). The JRE/JDK uses Xalan-J (http://xml.apache.org/xalan-j/) to process the XSLT file. The XSLT compiler (XSLTC) transforms the XSLT file into a set of Java classes and executes those to perform the transformation from XML based X3D into VRML. A problem with XSLTC is, that Java classes can be generated having methods that exceed the maximum allowed bytecode size of 64kB (sizes specified in http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#88659\). When the generated bytecode is loaded into the JVM with a call to ClassLoader.defineClass(), an error is generated:
    java.lang.ClassFormatError: Invalid method Code length 68380 in class file X3dToVrml97

    The bug is confirmed elsewhere as well:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5056688
    https://issues.apache.org/jira/browse/XALANJ-2318

    It is said that the bug did not occur with Java 1.4, as the XSLT is interpreted there. Only since Java 1.5 XSLT files are compiled into classes and therefore produce this error. It is also said, that for Java 1.6 this issue should be fixed. This could not be confirmed (with JDK 1.6.0.24).

    It is suggested to replace the Xalan-J by a current version (currently this is version 2.7.1) and use this one to transform the file. Setting a Java system property "javax.xml.transform.TransformerFactory" to the correct factory is needed (instead of System.setProperty() it was passed with the -D option on the command line).

    Setting the property to "org.apache.xalan.processor.TransformerFactoryImpl" (using the interpreting processor of Xalan-J 2.7.1) results in another error:
    (Position des Fehlers unbekannt)org.xml.sax.SAXException: Präfix des Namensbereichs kann nicht aufgelöst werden: #all.
    The error is generated when Xalan-J compares the prefix #all with its internal prefix constant org.apache.xalan.templates.Constants.ATTRVAL_DEFAULT_PREFIX="#default".

    Setting the property to "org.apache.xalan.xsltc.trax.TransformerFactoryImpl" reports another error:
    FEHLER: 'Syntaxfehler in '$node/msml:data/g:Shape/(x3d:Cone|x3d:Cylinder)'.'
    SCHWER WIEGENDER FEHLER: 'Die Formatvorlage konnte nicht kompiliert werden.'
    FEHLER: ''
    FEHLER: 'java.lang.NullPointerException'
    The syntax error is generated by some XSLT code from another file msml2x3d.xslt. There is a filter chain transforming from mimetype text/msml+xml to model/x3d+xml (using msml2x3d.xslt) to model/vrml (using X3dToVrml97.xslt). So before even working with X3dToVrml97.xslt, already another error stops the whole conversion. Strange is, that the other XSLT processors did not complain about this.

    Other Java based XSLT processors are Saxon and XT.

    Trying Saxon (http://saxon.sourceforge.net/ with "javax.xml.transform.TransformerFactory" set to "net.sf.saxon.TransformerFactoryImpl"), at least an output file is generated. It contains a valid VRML scene, but all spheres and rotations are gone. So the binary tree example is just a set of stacked and intersecting cylinders. Also an error is generated some time afterwards (triggered by a TimerThread) saying:
    java.lang.IllegalArgumentException: Unknown configuration option indent-number

    Trying XT (http://www.blnz.com/xt/ with "javax.xml.transform.TransformerFactory" set to "com.jclark.xsl.trax.TransformerFactoryImpl") gives an exception:
    javax.xml.transform.TransformerException: java.lang.NullPointerException
    at com.jclark.xsl.trax.TransformerImpl.transform(TransformerImpl.java:124)

     
  • Reinhard Hemmerling

    The error with #all when using Xalan-J 2.7.1 with the interpreting XSLT is generated by the msml2x3d.xslt, which comes in the filter chain before X3dToVrml.xslt.

    The msml2x3d.xslt starts with:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msml="http://grogra.de/msml"
    xmlns:x3d="http://www.web3d.org/specifications"
    xmlns:fn="http://www.w3.org/2005/xpath-functions"
    xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
    xmlns:g="http://grogra.de/msml/datatypes/groimp"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="#all"
    version="2.0">
    <xsl:output method="xml" indent="yes" encoding="utf-8" version="1.0" omit-xml-declaration="yes"/>
    ...

    Removing the 'exclude-result-prefixes="#all" ' also removes the error about #all, but other errors about node-name are generated. The function node-name is described here:
    http://www.xsltfunctions.com/xsl/fn_node-name.html

    Prefixing all node-name occurrences by 'fn:' solves this error, but creates other errors:
    System-ID unbekannt; Zeilennummer180; Spaltennummer70; Nach dem Token '/' oder '//' wurde ein Positionsschritt erwartet.
    System-ID unbekannt; Zeilennummer180; Spaltennummer70; Zusätzliche nicht zulässige Token: '(', 'http://www.web3d.org/specifications', ':', 'Cone', '|', 'http://www.web3d.org/specifications', ':', 'Cylinder', ')'
    System-ID unbekannt; Zeilennummer203; Spaltennummer91; Die Funktion konnte nicht gefunden werden: tokenize
    System-ID unbekannt; Zeilennummer203; Spaltennummer91; Funktionstoken wurde nicht gefunden.

    Line 180 is (column 70 is after the second 'x3d'):
    <xsl:when test="$node/msml:data/g:Shape/(x3d:Cone|x3d:Cylinder)">
    Line 203 is:
    <xsl:value-of select="(tokenize($node/msml:data/g:Shape/x3d:Box/@size,'\s+'))[2]"/>

     
  • Yongzhi Ong

    Yongzhi Ong - 2012-03-16

    1)
    MSML functionality is disabled as it interfered with MTG exports. As a result, the VRML and X3D export functionalities that depended on MSML are also disabled.

    2)
    X3D export from the 3D view however still functions. The previous XSLT file ("x3dtovrml.xslt") is outdated.

    Updated copies are found at: http://x3d.svn.sourceforge.net/viewvc/x3d/www.web3d.org/x3d/stylesheets

    Java's default XSLT Transformer class (JDK1.6) is unfortunately unable to parse the latest xslt style sheets.

    Saxon XSLT library (version 9.4) is used and able to transform X3D exports to both VRML97 and Classic VRML.

    Functionality to export VRML97 and Classic VRML files from 3D view menu is implemented. Subjected to further testing for next release.

     
  • Reinhard Hemmerling

    • assigned_to: nobody --> ongyz
     

Log in to post a comment.