Wow, impressive. (The searchAttributes macro is recursive!) I have tested the 2 macros with an XHTML document and they seem to work flawlessly.
Just remove 'trace="true"' if you don't want to be annoyed by traces. Note that you can improve the feedback by using commands beep (http://www.xmlmind.com/xmleditor/_distrib/docs/commands/ch06s04.html) and status (http://www.xmlmind.com/xmleditor/_distrib/docs/commands/ch06s55.html). Many thanks for your contribution. If you are interested, send us an order form with your coordinates (http://www.xmlmind.com/store/order.php) and you'll be offered a free XMLmind XML Editor Professional Edition. On the negative side, our Web site does not have a contribution area and we do not intend to add one in the short term. However, if I receive an inquiry about the lack of the search attributes feature, I'll point the user to your macros. Kevin Flynn wrote: > Here are a couple of macros that can be used to search attributes. They are > VERY simple, but may fill a gap for some of us until version 3.0 is ready. I > haven't really tested them very much at all, but they seem to work on my > documents so far. Maybe somebody can improve/extend them? > > Best regards > -------------- > Kevin Flynn > Birdstep Technology www.birdstep.com > Mobile: +47 93433942 > > > ------------------------------------------------------------------------ > > XXE macros for searching attributes. > > There are two macros: > > - setAttributePattern > - searchAttributes > > In order for the macros to work, you must add a namespace declaration like > this to the root of your > configuration file: > > xmlns:view="http://www.xmlmind.com/xmleditor/namespace/scope/view" > > You will also need to add them to your menu, for example: > > <item command="setAttributePattern" label="Find Attribute" mnemonic="F"/> > > <item command="searchAttributes" label="Find Next Attribute" > mnemonic="N"/> > > or make them available in some other way. > > > > setAttributePattern > ------------------- > Sets the string to search for. It displays a prompt dialog into which you can > enter a string and > then calls searchAttributes to perform a search. The search string is stored, > so it can be > used in later calls to "searchAttributes". The search string will survive in > the current view > until you call setAttributePattern again and modify it. It will not be > available in other views, > however. > > > <command name="setAttributePattern"> > <macro trace="true"> > <sequence> > <command name="prompt" parameter="'Find Attribute' 'Search for:'"/> > <set expression="%_" variable="view:searchString" > plainString="true"/> > <cfg:command name="searchAttributes"/> > </sequence> > </macro> > </command> > > > > > searchAttributes > ---------------- > Searches attributes for the string specified with setAttributePattern. > Searches as follows: > - down the document, not up > - for any attribute CONTAINING the specified string (an exact match is not > required) > - case-sensitively > > When a match is found, the element containing the matching element is > selected, but the Attribute > Tab is not automatically displayed. The caret mark is moved to the beginning > of the first text node > AFTER the matching element. > > > <command name="searchAttributes"> > <macro trace="true"> > <sequence> > <get expression="$view:searchString"/> > <choice> > <sequence> > <match context="$selectedElement" > pattern="*[contains(@*,'%_')]"/> > <choice> > <sequence> > <match context="$selectedElement" > pattern="*[child::node()]"/> > <set context="$selectedElement" > expression="child::node()[1]" variable="selectedNode"/> > <command name="searchAttributes"/> > </sequence> > <sequence> > <match context="$selectedElement" > pattern="*[following::node()]"/> > <set context="$selectedElement" > expression="following::node()[1]" variable="selectedNode"/> > <command name="searchAttributes"/> > </sequence> > </choice> > </sequence> > <sequence> > <test context="$implicitNode" > expression="count(descendant-or-self::*[contains(@*,'%_')])"/> > <set context="$implicitNode" > expression="descendant-or-self::*[contains(@*,'%_')][1]" > variable="selectedElement"/> > <set context="$selectedElement" > expression="following::text()[1]" variable="dot"/> > </sequence> > <sequence> > <test context="$implicitNode" > expression="count(following::*[contains(@*,'%_')])"/> > <set context="$implicitNode" > expression="following::*[contains(@*,'%_')][1]" variable="selectedElement"/> > <set context="$selectedElement" > expression="following::text()[1]" variable="dot"/> > </sequence> > </choice> > </sequence> > </macro> > </command> >

