Home
Categories
Dictionary
Glossary
Download
Project Details
Changes Log
What Links Here
FAQ
License

XUL Scripts MIME types





The following script languages are supported: Several MIME types are supported for each scripting language. The MIME is defined through the type attribute of the script element. For example:
      <script type="application/groovy">
      public int getValue(){
        return 10;
      }
      </script>

Languages MIME types

Javascript MIME types

The MIME types supported for Javascript scripts are:
  • "text/javascript"
  • "text/ecmascript"
  • "application/javascript"
  • "application/ecmascript"
  • "application/x-javascript"

Groovy MIME types

The MIME types supported for Groovy scripts are:
  • "text/groovy"
  • "application/javascript"
  • "application/groovy"
  • "application/x-groovy"

Python MIME types

The MIME types supported for Python scripts are:
  • "text/python"
  • "application/python"
  • "application/x-python"

Inferring script types

The algorithm to infer the language of a script is the following:
  • If the script element has a type attribute, the framework will use this MIME type to get the language of the script
  • If the script element has no type attribute but it is an external script, the framework will use the extension of the script file to infer the language of a script
  • If the script is external but the file has no extension, or embedded without a type attribute, the framework will assume that it is a XUL Javascript script
For example:
  • This script is detected as a XUL Groovy script because of the type attribute:
               <script type="text/groovy"> 
                public int clicked() {
                  context.echo("Clicked!");
                }
               </script>
    
  • This script is assumed by default to be a XUL Javascript script:
               <script> 
                function clicked() {
                  print("Clicked!");
                }
               </script>
    
  • This script is detected as a XUL Groovy script because of the file extension:
               <script src="myScript.groovy" />
    

Understanding Script parsing exceptions

You can have strange exceptions when parsing you script if you defined the wrong MIME type. For example if you have the following embedded script:
      <script>
      public int checked() {
        context.echo("checked!");
      }      
      </script>
The framework will show the following exception:
xul-scripterrormime
The reason here is that:
  • You did not define a MIME type for your script
  • As this is an embedded script, the framework assumed it was a XUL Javascript script
  • Obviously it is a XUL Groovy script, so the framework tried to compile the script as Javascript but failed

See also


Categories: builtin-applis

Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence