|
Home > Online Product Documentation > Table of Contents > Mapping Source and Target Document Nodes Mapping Source and Target Document NodesYou map a source document node to a target structure node using drag and drop to create a link between the two nodes. Stylus Studio composes XQuery code based on these maps. This section covers the following topics: Preserving Mapper LayoutAs you add function blocks to the XQuery mapper, Stylus Studio places them in the center of the mapper canvas. You can change the default placement of function blocks by dragging and drag and dropping them where you like. Stylus Studio preserves the placement you select within and across sessions (as you toggle between the mapper and the XQuery Source tab, for example). As you use the splitter in the XQuery mapper to widen the source and target document panes, the size of the mapper canvas is reduced. The Fit in Mapper Canvas button ( ), located at the top of the XQuery mapper, redraws the diagram in whatever space is currently available to the mapper canvas. This feature is also available from the mapper short-cut menu (right-click anywhere on the mapper canvas to display the short-cut menu).
Left and Right Mouse Buttons ExplainedYou can use either the left or the right mouse button to perform the drag and drop operation used to create source-target mappings in XQuery. If you use the left mouse button to perform the drag operation, the link always maps the source node to the target node, one-to-one, without making any changes to the target structure. If you use the right mouse button, Stylus Studio displays a shortcut menu that provides you with alternatives for modifying the target structure.
Using this menu, you can easily perform many operations. For example, you can
How to Map NodesTo map nodes:
1. Using either the left or right mouse button, drag the source document element or attribute to the appropriate node on the target structure.
2. When the pointer is on the appropriate target element, release the mouse button to complete the link.
Link Lines ExplainedStylus Studio draws lines for the maps you create from source document nodes to target structure nodes. Different line styles are used to convey information about the XQuery represented by the node mapping. There are three line styles:
The sample files used to illustrate these styles are
Thin lineA thin line indicates that the XQuery code generated by Stylus Studio copies content from the source node to the target node. Such a line is created when you map one element or attribute to another using the left mouse button, or any of the following choices on the map shortcut menu:
In addition, the structure required to navigate to the node is also generated if it does not already exist in the XQuery. For example, consider the map between the
This map results in Stylus Studio composing the following XQuery code:
The content is expressed as
Dashed line
A dashed line indicates that only structure code is being generated. Such a line is created when you use a FLWOR or IF block. For example, consider the map between the
A map involving a FLWOR block results in the following code:
Notice that the FOR loop returns only structure (shown in italics), not content. To add content, we could also map the
Of course, the FLWOR block can be used to define much more complex expressions, involving maps from source document nodes to its WHERE and ORDER BY ports, for example. Thick line
A thick line indicates that the XQuery code generated by Stylus Studio replicates the complete structure and content of the source document node in the target. Such a map is created when you use the
Copy Node choice on the link shortcut menu. Consider the following map - the
For this type of map, Stylus Studio creates the XQuery code required to duplicate the source structure and content in the target, as shown in the following sample:
Notice that the
Removing Source-Target MapTo remove a map from a source document node to a target element node:
1. Select the line that represents the map you want to delete.
2. Press the
Delete key.
Alternative: Select Delete from the line shortcut menu (right click on the line to display the shortcut menu). |