Impressive macros! Thank you very much for trying to help.

Alain Pierrot wrote:
> 
> Hi, I met the same kind of need, and devised the following work-around.
> 
>>
>> The homegrown DTD I use includes a conditional filtering mechanism 
>> similar
>> to (but a little more complex than) docbook "profiling". Since the 
>> documents
>> I create make heavy use of this mechanism, they can sometimes get 
>> difficult
>> to edit. In order to simplify editing, therefore, I can switch between
>> different "views" in which different sets of conditions are applied  and
>> irrelevant information is hidden. The current view is determined by an
>> attribute of the document's root element. Ideally, changing this 
>> attribute
>> would immediately change the view. This is not possible, however, 
>> because
>> CSS selectors are not powerful enough. I currently get around this
>> limitation by running a "process" transformation that sets a "view"
>> attribute to "show" or "hide" on all conditionalized elements each 
>> time the
>> "current-view" attribute is updated. This view attribute can then  be
>> used by
>> XXE's CSS display mechanism to show/hide the correct elements. The  view
>> attribute is only needed for display purposes; it has no real 
>> function in
>> the DTD.
>>
> You are not stuck with a process transformation :
> XMLEditors commands can be used recursively to toggle (or create and 
> set a value to) your "view" attribute.
> I use the same (inelegant but effective) way to show/hide features 
> reflecting, through XPath selectors, the current status of the edited 
> document.
> Here is a snippet of .xxe which might help you :
> 
> 
> <binding>
>     <keyPressed code="F8" />
>     <command name="toggleAllView" parameter="show"/>
> </binding>
> 
> <binding>
>     <keyPressed code="F8" modifiers="shift"/>
>     <command name="toggleAllView" parameter="hide"/>
> </binding>
> 
> <!-- selects all elements with attribute "view" -->
> <command name="toggleAllView">
>     <macro trace="false">
>         <sequence>
>             <set variable="selectedElement" expression="//*...@view][1]"/>
>             <command name="toggleView" parameter="%0"/>
>         </sequence>
>     </macro>
> </command>
> 
> <command name="toggleView">
>     <macro trace="false">
>         <sequence>
>             <choice>
>                 <sequence>
>                     <test expression="contains('%0','show')"/>
>                     <command name="setViewShow"/>
>                 </sequence>
>                 <sequence>
>                     <test expression="contains('%0','hide')"/>
>                     <command name="setViewHide"/>
>                 </sequence>
>             </choice>
>             <sequence>
>                 <pass>
>                     <test
> expression="$implicitElement/following::*...@view]"/>
>                 </pass>
>                 <set variable="selectedElement"
> expression="$implicitElement/ following::*...@view][1]"/>
>                 <command name="toggleView" parameter="%0"/>
>             </sequence>
>         </sequence>
>     </macro>
> </command>
> 
> <!-- Commands to be customized and called for "local toggling" or 
> creating the attribute when implicit -->
> <command name="setViewShow">
>         <macro trace="false">
>             <sequence>
>                 <command name="putAttribute" parameter="view show"/>
>             </sequence>
>         </macro>
> </command>
> 
> <command name="setViewHide">
>         <macro trace="false">
>             <sequence>
>                 <command name="putAttribute" parameter="view hide"/>
>             </sequence>
>         </macro>
> </command>
> 

Reply via email to