Mapping Source and Target Document Nodes

You 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 XSLT based on these maps.

This section covers the following topics:

Tip

 

You can also map source document nodes to XSLT instruction blocks, XPath and Java function blocks, and logical operators. See Working with XSLT Instructions in XSLT Mapper and Processing Source Nodes.

Preserving Mapper Layout

As you add function blocks to the XSLT 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 XSLT Source tab, for example).

As you use the splitter in the XSLT 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 XSLT 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 Explained

You can use either the left or the right mouse button to perform the drag and drop operation used to create source-target mappings in the XSLT mapper.

If you use the left mouse button to perform the drag operation, the link always maps the source node to the target node 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.

Figure 221. Shortcut Menu for Target Document Operations

Using this menu, you can

  • Map a source document node to an existing target structure node - this menu choice, Map to This Node, is the same as creating the link using the left mouse button.
  • Add a source document node (element or attribute) as an attribute of the target structure node you select and map the two nodes.
  • Add a source document node as a child element of the target structure node you select and map the two nodes.
  • Add a source document node as a sibling of the target structure node you select and map the two nodes.
  • Copy the entire source document node - its structure and its content - to the target structure and map it.

How to Map Nodes

To 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.
Tip

 

If you need help with this step, see Left and Right Mouse Buttons Explained.

2. When the pointer is on the appropriate target element, release the mouse button to complete the link.

Stylus Studio draws a link between the source and target nodes you chose is step 1. If you linked two repeating elements, Stylus Studio displays a symbol representing the xsl:for-each instruction. See Working with XSLT Instructions in XSLT Mapper.

Removing Source-Target Maps

To 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.
Tip

 

Select the portion of the line that is drawn on the XSLT mapper canvas.

2. Press the Delete key.

Alternative: Select Delete from the line shortcut menu (right click on the line to display the shortcut menu).

 
Free Stylus Studio XML Training: