Kevin Flynn wrote:
> I am having trouble sharing user variables between macros.
> 
> The following code works:
> ...
>             <cfg:set expression="$selected"
> variable="saveSelected"></cfg:set>
>             <cfg:set expression="id($id)" variable="selected"></cfg:set>
>             <cfg:command name="selectNode" parameter="firstChild"/>
>             <cfg:set context="$selectedNode" expression="."
> variable="preview"></cfg:set>
>             <cfg:set expression="$saveSelected"
> variable="selected"></cfg:set>
>               <cfg:get expression="$preview"/>
>             <cfg:command name="putAttribute" parameter="[implicitElement] 
> preview
> '%_'" />
> ...
> 
> If, however, I try to move a portion of the code to a different macro and
> call it, as follows:
> 
> ...
>             <cfg:set expression="$selected"
> variable="saveSelected"></cfg:set>
>               <cfg:get expression="$id"/>
>             <cfg:command name="getPreview" parameter="%_" />
>               <cfg:get expression="$view:preview"/>
>             <cfg:command name="putAttribute" parameter="[implicitElement] 
> preview
> '%_'" />
> ...
> 
>   <cfg:command name="getPreview">
>     <cfg:macro>
>       <cfg:sequence>
>         <cfg:set expression="id(%0)" variable="selected"></cfg:set>
>         <cfg:command name="selectNode" parameter="firstChild"/>
>         <cfg:set context="$selectedNode" expression="."
> variable="view:preview"></cfg:set>
>       </cfg:sequence>
>     </cfg:macro>
>   </cfg:command>
> 
> it no longer works: the <cfg:get expression="$view:preview"/> returns an
> empty string.
> 
> I have included the following namespace declaration in the root
> configuration element:
> 
>               
> xmlns:view="http://www.xmlmind.com/xmleditor/namespace/scope/view";
> 
> What am I doing wrong?

At first glance, I don't see anything wrong. Please note that variable 
"view:preview" has a *document view scope*, not a document scope, not a 
global scope.

This means that what you did should work within the same ``document 
window'' but not in the ``window'' of another document and not in 
another ``window'' (with a different style sheet) of the same document.

If this is not the case, may be you have found a bug and in such case, 
send us an new email reporting this.


Reply via email to