The XML Refactoring tool includes a variety of predefined operations that can be used for
common refactoring tasks. They are grouped by category in the Refactoring
operations wizard page and include the following operations:
Refactoring Operations for Attributes
- Add/Change attribute - Use this operation to change the value of
an attribute or insert a new one. To perform this operation, specify the following
parameters:
- The Local name and Namespace for the
Parent element.
- The Local name, Namespace, and
Value of the affected Attribute.
- One of the following choices for the Operation mode in the
Options section:
- Add the attribute in the parent elements where it is
missing
- Change the value in the parent elements where the atrribute already
exists
- Both
- Delete attribute - Use this operation to remove one or more
attributes. To perform this operation, specify the following parameters:
- The Local name and Namespace for the
Parent element.
- The Local name and Namespace for the
Attribute to be removed.
- Rename attribute - Use this operation to rename an attribute.
Specify the following parameters in the Rename attribute dialog
box:
- The Local name and Namespace for the
Parent element.
- The Local name, Namespace, and
New local name of the Attribute.
- Replace in attribute value - Use this operation to search for a
text fragment inside an attribute value and change the fragment to a new value. To perform
this operation, specify the following parameters:
- The Local name and Namespace for the
Parent element.
- The Local name and Namespace for the
Attribute to be modified.
- The text Fragments to Find and Replace
with.
Note: You can use Perl-like regular expressions when specifying the text to find. The
Replace with parameter can bind regular expression capturing
groups ($1, $2, etc.) from the find pattern.
Refactoring Operations for Elements
- Delete element - Use this operation to delete elements. To
perform this operation, specify the following parameters:
- The Target elements in the form of an XPath expression.
- Delete element content - Use this operation to delete content of
elements. To perform this operation, specify the following parameters:
- The Target elements in the form of an XPath expression.
- Insert element - Use this operation to insert new element. To
perform this operation, specify the following parameters:
- The Local name and Namespace for the
element to be inserted.
- The Location of the new element in the form of an
XPath expression and its Position. Use
the link provided in the lower part of the wizard to open the XML /
XSLT-FO-XQuery / XPath preferences page where you can configure XPath
options and declare namespace prefixes. The possible selections in the
Position drop-down list include After,
Before, First child, or
Last child.
- Rename element - Use this operation to rename elements. To
perform this operation, specify the following parameters:
- The Target elements in the form of an XPath expression. Use
the link provided in the lower part of the wizard to open the XML /
XSLT-FO-XQuery / XPath preferences page where you can configure XPath
options and declare namespace prefixes.
- The New local name of the element.
- Unwrap element - Use this operation to delete the surrounding
tags of elements, while keeping their content unchanged. To perform this operation,
specify the following parameters:
- The Target elements in the form of an XPath expression. Use
the link provided in the lower part of the wizard to open the XML /
XSLT-FO-XQuery / XPath preferences page where you can configure XPath
options and declare namespace prefixes.
- Wrap element - Use this operation to surround elements with
element tags. To perform this operation, specify the following parameters:
- The Target elements in the form of an XPath expression. Use
the link provided in the lower part of the wizard to open the XML /
XSLT-FO-XQuery / XPath preferences page where you can configure XPath
options and declare namespace prefixes.
- The Local name and Namespace of the
Wrapper element.
- Wrap element content - Use this operation to surround the content
of elements with element tags. To perform this operation, specify the following
parameters:
- The Target elements in the form of an XPath expression. Use
the link provided in the lower part of the wizard to open the XML /
XSLT-FO-XQuery / XPath preferences page where you can configure XPath
options and declare namespace prefixes.
- The Local name and Namespace of the
Wrapper element in which its content will be wrapped.
Refactoring Operations for XML Fragments
- Insert XML fragment - Use this operation to insert an XML
fragment. To perform this operation, specify the following parameters:
- The XML Fragment to be inserted.
- The Location of the new fragment in the form of an
XPath expression and its Position. Use
the link provided in the lower part of the wizard to open the XML /
XSLT-FO-XQuery / XPath preferences page where you can configure XPath
options and declare namespace prefixes. The possible selections in the
Position drop-down list include After,
Before, First child, or
Last child.
- Replace element content with XML fragment - Use this operation to
replace the content of elements with an XML fragment. To perform this operation, specify
the following parameters:
- The Target elements in the form of an XPath expression. Use
the link provided in the lower part of the wizard to open the XML /
XSLT-FO-XQuery / XPath preferences page where you can configure XPath
options and declare namespace prefixes.
- The XML Fragment with which to replace the content of the
target elements.
- Replace element with XML fragment - Use this operation to replace
elements with an XML fragment. To perform this operation, specify the following
parameters:
- The Target elements in the form of an XPath expression. Use
the link provided in the lower part of the wizard to open the XML /
XSLT-FO-XQuery / XPath preferences page where you can configure XPath
options and declare namespace prefixes.
- The XML Fragment with which to replace the target
elements.
Additional Notes
Note: There are some operations that allows <ANY> for the local name
and namespace parameters. This value can be used to select an element or attribute
regardless of its local name or namespace. Also, the <NO_NAMESPACE> value
can be used to select nodes that do not belong to a namespace.
Note: Some operations have parameters that accept XPath expressions to match elements or
attributes. In these XPath expressions you can only use the prefixes declared in the
page. This preferences page can be easily opened by clicking on the
link in the note (
Each prefix used in an XPath expression must be declared in the
Default prefix-namespace mappings section) at the bottom of the
Configure
Operation Parameters wizard page.