Understand how to use search in a structured XML document.
When you are working on a structured XML document, you can use the FrameMaker Find/Change dialog in the WYSIWYG view.
However, if you are working the XML view, you can search Complex Expressions or XPath queries.
The XML-specific search functionalities (Complex Expression and XPath search); perform the search in the XML content of a document. This implies that if you are searching for content across elements in the XML, you will need to specify the element tags in the search.
For example, the following sample paragraph (<p>
)
text contains a word marked as bold (<b>
).
<p>The quick <b>brown</b> fox.</p>
The WYSIWYG view provides the functionality to search for text
as it displays in the FrameMaker window. This implies that the search
for The quick brown fox
will find the text. However,
in the XML view, the same search does not find any results.
In the XML view, you will need to include the <b>
(opening)
and </b>
closing tags in the search.
Work with some complex expressions for search in FrameMaker.
In the XML view for the current XML document, open the Find/Change dialog ( or Ctrl + F).
The dialog includes a Complex Expressions option.
Check the Complex Expressions option and enter an expression in the Find Text field.
Click Find.
Complex expressions are similar to regular expressions. The following table contains a list of sample complex expressions:
Complex expression sample |
Locates |
---|---|
Licen[sc]e |
License and Licence |
e{2} |
Words with two consecutive ‘e’s, such as in freeand week |
[2-3][0-2] |
Numbers where 20, 21, 22, 30 , 31, or 32 exist, such as 2055, 3155, and 2255. |
[a-c][a-c][a-c] |
Words where a, b, and/or c occur back to back, such as in accompanying, applicable, backup, and abbreviation |
Understand how you can use XPath queries to navigate through elements in an XML document in FrameMaker.
An XML document consists of a hierarchy of elements. An XPath query is used to navigate through elements and attributes in an XML document.
Given the following XML file:
<topic id="abc">
<title>Using XPATH</title>
<body>
<p>Using XPATH is easy.</p>
<fig>
<image href="images/xpath.png"/>
</fig>
<section>
<title>Examples</title>
<p audience="novice">A simple example.</p>
<p audience="expert">An advanced example.</p>
<p audience="expert">Another advanced example.</p>
<fig>
<image href="images/xpath-axes.png">
<alt>This screenshot shows the XPATH axes</alt>
</image>
</fig>
</section>
<p>The End.</p>
</body>
</topic>
The following table contains a list of several sample XPath queries for the XML example given above.
XPath Query |
Locates |
---|---|
|
Returns the |
|
Returns any |
|
Returns only the |
|
Returns any |
|
Returns any |
|
Returns any |
|
Returns any |
|
Returns any |
|
Returns any |
|
Returns any |
For more information on XPath, see http://www.w3.org/TR/xpath/
Open the XPath toolbar (
).In the XPath field, enter the query and click the Run button.
The results of the query display in the XPath Builder pod.
The Query Builder is also a convenient interface to build XPath queries. In the Query Builder, you can create (using Auto-Suggest functionality) and run an XPath query.
You can also specify the Scope of the search:
Current File
All Open Files
Folder
DITA Map or Book. This option is available if you select a DITA Map or book in the Resource Manager
The Auto-Suggest feature provides suggested components that you can add to the XPath query as you create the query.
For example, in the following XML:
<body>
<p>The quick brown fox.</p>
<p audience="admin">Jumped over the lazy dogs.</p>
</body>
In the Query Builder field start with entering a forward slash (/).
As soon as you enter the forward slash, the following suggestions display:
Use the up and down arrow keys to select the option and press Enter to insert the component into the query.
To add another element to the query, enter a forward slash.
Alternatively, to add an attribute, enter an opening square bracket ([).
The Auto-Suggest list contains the following components of an XPath query:
Elements at the current position in the current document.
Attributes at the current position in the current document.
An axis is a node definition relative to the current node. For example, parent, child, ancestor.
Click the drop-down list to the right of the Enable Auto-Suggest option and un-check the Axes option to hide the available axes in the Auto-Suggest list.
Click the Save icon to save the current results of the XPath query.