Variable Scoping Errors

Oxygen general issues.
kirkilj
Posts: 110
Joined: Fri May 14, 2010 12:14 am

Variable Scoping Errors

Post by kirkilj »

Oxygen reports errors in XSL transforms if a variable was not defined in the same file; its lexical scope. The variables are global in nature declared in a master XSL file that imports the one I'm using as well as many others.

Is there a switch of some type to tell oXygen to look within a directory structure to see if the variable is defined and to not show it as an error.

I don't like globals in general, but this is not my code base and I'm new to XSL. For now, I've been equating a global variable within my files to its global equivalent so that the error that oXygen reports is at the top of the file where I expect it to be. This removes the false error noise from the rest of the file.

For example,

<!-- Global variables in runtime scope, but not lexical scope of this file. Helps to eliminate false positives in Oxygen. Prefixed by "local-".
-->

Code: Select all

   <xsl:variable name="local-base-font-family">
<xsl:value-of select="$base-font-family"/>
</xsl:variable>
If there are better ways to address this issue, let me know.

Thanks.
Costin
Posts: 833
Joined: Mon Dec 05, 2011 6:04 pm

Re: Variable Scoping Errors

Post by Costin »

Hello,

In order to solve the validation issues for your XSL, you should first tell oXygen to validate your XSL files in the context of the master XSL, which declares the variables and where the other XSL files are imported (including the one you are trying to transform).

For that you should configure a validation scenario that uses the master XSL file which will be used to validate each of your "slave" XSL files. You can do that by either by going in oXygen menu to Document > Validate > Configure Validation Scenario, or from the button on the toolbar. To configure the validation scenario you can use Configure Validation Scenario button from the toolbar or Document -> Validate -> Configure Validation Scenario. In this dialog:
- Press New and choose a name for the scenario
- In the "URL of the file to validate" select the master XSL (You can add more than one XSL files, if you have more)
- Hit OK in all dialogs.

After that, you can associate the other included XSL files with the validation scenario you've just created. You can do this by selecting multiple stylesheets in the project view and right clicking and selecting Validate -> Configure Validation Scenario for all of them. Then select the scenario from the list and press OK.
Now you should have both automatic and manual validation of all the stylesheets in the correct context.

Starting with the upcoming version 14 of oXygen , we will introduce "Master Files" - a new and powerful feature that will allow the user to define master files at project level. This feature simplifies the configuration and development of XML Projects as it will be used to determine the context for operations like validation, content-completion, refactoring or search for XSD, XSL and RNG modules.

Hope this helps.

Regards,
Costin
Costin Sandoi
oXygen XML Editor and Author Support
Post Reply