to X3D Resources: Quality Assurance
   

X3D Tidy for Scene Cleanup, Corrections and Conversions

   
to Web3D home page

X3D Tidy is an XSLT stylesheet that checks for simple authoring difficulties in X3D scenes and fixes them.

Overview | Availability | Corrections and Conversions | Parameters | References | Contact

Overview to top

Authors can use X3D Tidy to fix minor errors and apply best practices for X3D scene authoring. X3D Tidy provides an additional degree of Quality Assurance (QA) that helps achieve intended results in X3D scenes and metadata.

X3D Tidy takes an .x3d scene (written using the X3D XML encoding) as input, and returns a modified .x3d scene as output. Any corrections are applied in place without changing the overall formatting or layout of the original X3D scene.

X3D Tidy does not attempt to make scene corrections which might change intended scene content or require an authoring decision.

Prerequisite: since X3dTidy.xslt is an XSLT stylesheet, the input .x3d scene must be encoded in valid XML. The X3D Validator and various other tools listed in X3D Resources: Quality Assurance can help to achieve this necessary level of compliance.

Availability to top

X3D Tidy is an XSLT stylesheet, available at X3dTidy.xslt.

X3D Tidy is currently undergoing beta testing. It is available as part of the following tools:

TODO: X3D Tidy will be added as a feature in the following tools:

Corrections to top

X3D Tidy is able to make the following unambiguous scene corrections.

  1. Modify DOCTYPE and Schema references to match <X3D> element version in scene, if match is inconsistent or insufficient
  2. Modify <X3D> element version to match a given value (by default this is disabled; recommended version is 3.3)
  3. Omit default attribute values
  4. Alphabetize or sort remaining attribute values in X3D Canonicalization (C14N) order
  5. <meta> tag: if missing insert a default title, title moved as first meta tag
  6. <meta> tag: add provided or suggested license
  7. <meta> tag: normalize dates to match suggested date format
  8. Fix MFString array "quotes" (such as <Text> node string array, or <ProtoInstance> fieldValue initializations)
  9. Remove excess embedded SFString "quotes" (such as <Viewpoint> node description field)
  10. Fix quoting of geoSystem values, replace deprecated values
  11. Expand local url array to include online addresses, prepend .x3d variants to .wrl addresses, or append .wrl variants to .x3d addresses
  12. <Script> node embedded source: replace javascript: prefix with ecmascript:, or insert ecmascript: prefix if missing
  13. For line geometry (PointSet, LineSet, IndexedLineSet, Arc2D, ArcClose2D, Circle2D): if no contained Color/ColorRGBA node, and if associated Appearance/Material emissiveColor value is default (black) or missing, then apply the diffuseColor value as emissiveColor value.
  14. Correct erroneous attribute names: mustOutput to forceOutput.

TODO. More adjustment capabilities are planned, suggestions are welcome.

  1. Check other MFString attributes besides urls, handle fixMFStringQuotes setting accordingly
  2. Detect and fix embedded spaces within individual url values

Conversions to top

X3D Tidy is able to apply the following scene conversions.

  1. Add visualization spheres and lines to HAnimJoint and HAnimSegment nodes in an HAnimHumanoid skeleton.
  2. Add visualization shapes to HAnimSite nodes in an HAnimHumanoid skeleton.
  3. Add visualization lines to Viewpoint nodes embedded within an HAnimHumanoid skeleton.
  4. TODO. Remove Shape geometry from an HAnimHumanoid skeleton.
  5. TODO. Add visualization bones to HAnimSegment nodes in an HAnimHumanoid skeleton.
  6. TODO. Convert deprecated fields, such as GeoViewpoint navType.
  7. TODO. Remove quotes surrounding SFString values.

TODO. More adjustment capabilities are planned, suggestions are welcome.

Parameters to top

Fine-grained control of X3D Tidy operation can be achieved by overriding any of the following XSLT stylesheet parameters at invocation time.

Default parameter default=value pairs follow:

    <!-- Default parameter values can be overridden when invoking this stylesheet -->
    <xsl:param name="conversionRequired"          ><xsl:text>true</xsl:text></xsl:param>
    <xsl:param name="title"                       ><xsl:text><!-- default title value for file name is empty --></xsl:text></xsl:param>
    <xsl:param name="modifyX3dVersion"            ><xsl:text>true</xsl:text></xsl:param>
    <xsl:param name="revisedX3dVersion"           ><xsl:text>3.3</xsl:text></xsl:param>
    <xsl:param name="fixDateFormats"              ><xsl:text>true</xsl:text></xsl:param>
    <xsl:param name="fixMFStringQuotes"           ><xsl:text>true</xsl:te xt></xsl:param>
    <xsl:param name="fixGeoSystemMetadata"        ><xsl:text>true</xsl:text></xsl:param>
    <xsl:param name="fixMetaNamesMatchDublinCore" ><xsl:text>true</xsl:text></xsl:param>
    <xsl:param name="replaceBlackEmissiveColor"   ><xsl:text>true</xsl:text></xsl:param>
    <!-- expand local url array to include online addresses -->
    <xsl:param name="fixUrlAdditionHttpAddresses" ><xsl:text>true</xsl:text></xsl:param>
    <!-- note that url quotes are always added if needed -->
    <xsl:param name="appendWrlAfterX3dAddresses"  ><xsl:text>true</xsl:text></xsl:param>
    <xsl:param name="prependX3dBeforeWrlAddresses"><xsl:text>true</xsl:text></xsl:param>
    <xsl:param name="defaultUrlAddress"           ><xsl:text><!-- default value is empty --></xsl:text></xsl:param>
    <!-- $baseUrlAvailable false means that stylesheet is being used by servlet, or else styled results won't be in original directory: -->
    <xsl:param name="baseUrlAvailable"            ><xsl:text>true</xsl:text></xsl:param>
    <xsl:param name="changeJavascriptEcmascript"  ><xsl:text>true</xsl:text></xsl:param>
    <xsl:param name="insertMissingEcmascript"     ><xsl:text>true</xsl:text></xsl:param>
    <xsl:param name="insertMissingMetaLicense"    ><xsl:text>true</xsl:text></xsl:param>
    <xsl:param name="licenseLink"                 ><xsl:text>http://www.web3d.org/x3d/content/examples/license.html</xsl:text></xsl:param>

H-Anim: illustrating or cleaning HAnimHumanoid skeletons of HAnimJoint/HAnimSegement/HAnimSite nodes:

    <!-- Default parameter values can be overridden when invoking this stylesheet -->
    <xsl:param name="HAnimGeometryRemove"         ><xsl:text>false</xsl:text></xsl:param>
    <xsl:param name="HAnimSkeletonIllustrate"     ><xsl:text>false</xsl:text></xsl:param>
    <xsl:param name="HAnimSiteIllustrate"         ><xsl:text>false</xsl:text></xsl:param>
    <xsl:param name="HAnimViewpointIllustrate"    ><xsl:text>false</xsl:text></xsl:param>

    <xsl:param name="jointColor"                  ><xsl:text>1 0.5 0</xsl:text></xsl:param>
    <xsl:param name="segmentColor"                ><xsl:text>1 1 0</xsl:text></xsl:param>
    <xsl:param name="siteColor"                   ><xsl:text>1 0 0</xsl:text></xsl:param>
    <xsl:param name="siteViewpointColor"          ><xsl:text>0 0 1</xsl:text></xsl:param>
TODO:
    <xsl:param name="HAnimAddBoneSegments"        ><xsl:text>false</xsl:text></xsl:param>

Authors can also suppress the external application of X3D Tidy corrections to a scene by including one or more of the following <meta/> tags in the <head> section of an X3D scene.

    <!-- Authors can override stylesheet parameter values by including meta tag(s) in an X3D scene. -->
    <meta name="X3dTidy" content="ignore"/>  <!-- ignores all corrections -->
    <meta name="X3dTidy" content="modifyX3dVersion=false"/>
    <meta name="X3dTidy" content="fixMFStringQuotes=false"/>
    <meta name="X3dTidy" content="fixGeoSystemMetadata=false"/>
    <meta name="X3dTidy" content="fixMetaNamesMatchDublinCore=false"/>
    <meta name="X3dTidy" content="fixDateFormats=false"/>
    <meta name="X3dTidy" content="replaceBlackEmissiveColor=false"/>
    <meta name="X3dTidy" content="fixUrlAdditionHttpAddresses=false"/>
    <meta name="X3dTidy" content="appendWrlAfterX3dAddresses=false"/>
    <meta name="X3dTidy" content="prependX3dBeforeWrlAddresses=false"/>
    <meta name="X3dTidy" content="changeJavascriptEcmascript=false"/>
    <meta name="X3dTidy" content="insertMissingEcmascript=false"/>
    <meta name="X3dTidy" content="insertMissingMetaLicense=false"/>

References to top

X3D Tidy has been developed as part of the X3D Quality Assurance (QA) efforts.

HTML Tidy provides inspiration for this work. The following references describe HTML Tidy functionality in further detail.


Contact to top

Updated: 27 March 2016

Valid XHTML 1.0!

Maintained by Don Brutzman (brutzman at nps.edu). Comments & suggestions are welcome.

Revisions are found under Sourceforge version control. This page is available online at http://www.web3d.org/x3d/stylesheets/X3dTidy.html