Other Useful Info
Save an XPath expression I've typed
If you are typing in the XPath Editor, and in 'Auto' mode, every time you press the <enter> key, the expression will be saved.
If in 'Pause' mode, when typing in the XPath editor, pressing <enter> once will evaluate the expression, pressing <enter> a second time, will save the expression
Rename an XPath expression I've saved
Select the name of your saved expression in the 'Variables Pane' list (it will have been auto-named) and type in a new name. Alternatively, select 'Manager' mode from the Expression Toolbar and make the change in the full-width expression list.
Edit an XPath expression I've saved
To ensure only valid expressions are saved, you can't directly modify an expression already saved. However, you can easily recall a saved expression, edit it, save it and rename it. To do this, select 'Reviewer' mode from the toolbar. The expressions list is shown, select the expression you wish to change, the expression is then copied to the XPath editor ready for editing and saving again.
Use the result of one saved XPath expression as a variable in another
To do this, ensure that the expression you wish to reuse is displayed in the 'Variables Pane'. If it isn't, select the group name that the expression is in from the Variables Pane drop-down list. Note that expressions that have been 'un-marked' are hidden in this list so must first be marked from the Expression Manager.
When referencing a variable in an expression, use the '$' prefix, as used in XSLT. If a variable name does not match any in the current environment, the name will be underlined with a 'squiggle'.
Example of an XPath expression using a variable and colorized by SketchPath
/PDF/Metadata = $Pages-2
Move a saved expression to another group
If this is for a single expression, switch to 'Manager' or 'Reviewer' mode (from the toolbar), to show the XPath expression list. Select the group of the expression you wish to move and type the new group name, this can be either be an existing group, or a new group will be created.
Delete a mixed set of saved XPath expressions
SketchPath uses a Recycle Bin to allow you to 'delete' expressions, but restore them later if you need to. The Recycle Bin is saved to file when you save/update any XPath library. There is a 'Clear Bin' button on the XPath Manager toolbar, if you need to clear the Recycle Bin from time to time.
1. Select 'Manager' mode from the XPath toolbar
2. Click 'Unmark All' on the 'Manager' toolbar
3. Mark the items to delete
4. Click 'Select Bin' on the 'Manager' toolbar
5. Click 'Transfer to Bin' on the 'Manager' toolbar
Store to a library file my list of saved XPath expressions
Click the 'Save XPath File' button on the XPath toolbar. When prompted, enter the path and name of the file to save.
Reload a library file of XPath expressions
Click the 'Open XPath File' button on the XPath toolbar, then select the file you wish to load, (it must have an skpx extension).
Use a namespace prefix within an expression
If the source xml for the XPath uses namespaces, then you can simply use the same prefix for an element or attribute as that in the namespace declaration of the source. If you need to use another prefix, select the source prefix in the Namespace Manager and type in a new prefix.
Example of XPath using a node prefix for referencing a namespace
xs:element/@name
Reference a location path that is in the default namespace
If the xml source has a default namespace declared, then for nodes within that namespace, in SketchPath they can be referenced either with no prefix, or with a prefix that can be renamed in the namespace manager, but is initially set to 'def:'.
Auto-Complete a location path, as I type
As you type, the 'Intelli-List' is populated with a list of node names that are valid for that context. To insert a name, either (i) click on that item in the list, or (ii) start typing until the required node is selected and then press <tab>.
Auto-Complete an XPath 'value test' as I type
If testing the value of a node, typing '=' followed by <tab> will populate the 'Source Nodes' list with all values that the preceding node has in that context within the source XML document. In the example below 'bookmarks.xml' is auto-completed by clicking the item in the value in the 'Source Nodes' list.
/
PDF/Bookmarks[@src = 'bookmarks.xml'Debug an XPath expression
Copy and paste the expression into the XPath editor, open an XML 'source' file to test it against and double-click the part of the expression you wish to test. This enters the XPath editor into a trace mode where you can use the left/right cursor keys to navigate through an expression.
Integrate with Visual Studio
1. In Visual Studio 2005/2008, from the menu bar click Tools > External Tools...
2. In the resulting dialogbox, add a new item and set the Title to '&SketchPath' and the Command to the fullpath of the SketchPath.exe file.
3. In the Arguments field, enter: /f $(ItemPath)
4. Click 'Ok' to save
5. SketchPath will now appear in the Tools menu. To activate SketchPath with a specific XML file, first select the tabbed page for the XML file you wish to view and then click: Tools > SketchPath
