Create new account I forgot my password    

Expression Web Queries
Rating: 3 user(s) have rated this article Average rating: 4.0
Posted by: Minal Agarwal, on 1/19/2010, in category "Expression Web"
Views: this article has been read 15208 times
Abstract: Queries in Expression Web to search and replace a particular pattern or factor could be required often while developing a website. The Find and Replace dialog box in Expression Web has much to offer, than the traditional find and replace mechanism. You can create queries for the same. In this article we would take a deep insight into how to create such queries to pinpoint any misses in the code and search and replace intelligently.

Expression Web Queries
 
Expression Web queries should be used to search and replace a particular pattern or expressions. It could be really helpful while developing a website to search and replace in a long and complicated codes. The Find and Replace dialog box was used to find a word or an expression and replace with another set. But in Expression Web, the Find and Replace tool has much more to offer, than the traditional search mechanism. You can create queries for the same.
In this article we would take a deep insight into how to create search queries, to run them and search and replace intelligently.
To create a query to find missing attributes
1.    Go to the Edit menu > Find or Replace to open the ‘Find and Replace’ dialog box.
 
2.    Switch to the ‘HTML Tags’ tab.
 
3.    Enter the following values:
·         Find Tag dropdown: img
·         Replace Action dropdown: Set attribute value
·         Attribute: alt
 
4.    Click on the ‘HTML Rules…’ button.
 
5.    In the HTML Rules dialog box, click on ‘New rule…’ In the New Rule dropdown, that appears in the bottom of the box, choose ‘Without attribute’ and in the [any attribute] dropdown, choose ‘alt’.
FindandReplace
 
6.     The query description is always shown next to the Clear rules button in the Find and Replace dialog box. See image below:
Rules
 
7.    Click OK in HTML Rules dialog box. Click on the Save query button in the Find and Replace window (see highlighted button in the image above).
 
8.    The default location to save this query would be – ‘C:\Users\Username\AppData\Roaming\Microsoft\Expression\Web 3\Legacy\Expression\Web 3\Queries’
where C:\ would be your hard drive where and ‘Username’ would be your Windows username.
 
NOTE: If Queries folder does not exist, then create one in the same location or create your own folder at a simpler and easily accessible location.
 
Give a relevant name and save. The query will be saved with the extension ‘.fpq’.
 
9.    In the Find and Replace window, under the ‘Search options’ choose ‘All Pages’ and click ‘Find All’.
 
10.Expression Web will run the query and find all the <img> tags without the alt attribute and display it in the Find Task Pane or Panel (Task Panes are called as Panels in Expression Web 3) at the bottom on your workspace.
 
11.Since you have saved your query, you can use it again.
 
Reuse the query
We saved the query that we wrote above to reuse it later. To do that launch the Find and Replace dialog box (Edit > Find or Edit > Replace or CTRL + F or CTRL + H). On the HTML Tags tab click on the open the query icon (open folder icon next to Save query), browse to the Queries folder (path given above) choose the query and click Open. The query is now open in the Find and Replace dialog box.
Edit or Refine query search
The Find Panel when displays the results of the query, could be used to refine your search. Each column in the panel gives you option for Custom Filter as shown below:
Page
As you choose (Custom…) the Custom AutoFilter dialog box is launched.
CustomAutofilter
Set additional conditions to refine your search.
Some more options are also available when you right click on the results in the Find Panel, see image below:
Find1
Open a query as an xml
Queries are saved as ‘.fpq’. In the Windows Explorer/browser window, browse to the location of the query. Right click and choose ‘Open’. If you are opening this file type for the first time, then Windows will ask you to associate a program to open the file. See image below:
Windows
Choose ‘Select a program from a list of installed programs’ and click OK. In the ‘Open With’ dialog box, choose Notepad, make sure the ‘Always use the selected program to open this type of file’ option button is selected. Click OK.
The query will now be opened with a notepad and would look something like this:
<?xml version="1.0" encoding="utf-8" ?>
<fpquery version="1.0">
 <queryparams />
 <find tag="img">
    <rule type="attribute" attribute="alt" compare="=" value="" negate="true" />
 </find>
 <replace type="setAttribute" attribute="alt" value="" />
</fpquery>
 
You can save this xml and use the file in your pages.
 

I hope this article has thrown some light on Expression Web Query. So now you could use them to smartly reduce your efforts.

If you liked the article,  Subscribe to the RSS Feed or Subscribe Via Email










Page copy protected against web site content infringement by Copyscape


How would you rate this article?

User Feedback

Post your comment
Name:
E-mail: (Will not be displayed)
Comment:
Insert Cancel

NEWSLETTER