|
Home >Online Product Documentation >Table of Contents >Mapping Nodes in Sample Files Mapping Nodes in Sample FilesThis topic is part of a sequence that starts with Opening the XSLT Mapper.
To define links and examine the stylesheet Stylus Studio creates:
1. In the Mapper tab, expand the tree for both books.xml and catalog.xml.
2. In books.xml, place the pointer over the book repeating element.
3. Press and hold the left mouse button, and drag from book to the Book repeating element in catalog.xml.
Stylus Studio draws a line as you drag.
4. Release the mouse button to create the link between book and Book.
Stylus Studio creates an xsl:for-each block that links the book and Book repeating elements. (If you mouse over the block, xsl:for-each appears in a pop-up to indicate the XSLT operation represented by the link.)
Also notice that the complete xsl:for-each instruction has been added to the XSLT source, which appears in the XSLT source pane under the XSLT Mapper canvas. The back-mapping pointer identifies the line of XSLT that was just added to stylesheet.
The template contains an xsl:for-each instruction that selects the book element, which is the node you selected in Step 2. The output from this template is an empty Book element, which is the node that was the target of the link. Stylus Studio created the Catalog element automatically, to provide the document structure necessary to support the Book element.
5. Click the Params/Other tab.
In the Output method: field, display the drop-down list and select xml. (Even if the setting for Output method is unspecified, Stylus Studio still generates XML.) Other choices for the output method include text and HTML.
6. Click the Mapper tab.
The xsl:output instruction is added to the XSLT source:
7. Create another link from the title element to the Title element.
8. Click the XSLT Source tab to see the new instructions in the template. (If you prefer, you can simply adjust the splitter between the XSLT source pane and the XSLT Mapper canvas.
For each link you define, Stylus Studio adds instructions to the template that matches the root node. In the XSLT you have composed so far, the XSLT inserts a Book element for each book element it finds in the source document. In the Book element, the stylesheet selects the title elements. For each title element, it inserts a Title element. Finally, in each Title element, the stylesheet extracts the value of the current context node, which is the title node.
Why does the stylesheet extract the value of the title nodes but not the book nodes? The title node has only a text node as its child. In this situation, the default is that the XSLT Mapper inserts an xsl:value-of instruction.
|