|
next
|
Subject: Instructions In Mapper Author: (Deleted User) Date: 15 Mar 2007 08:43 AM
|
Kevin,
the "when" instruction is filled as soon as you drag something on the ports on the left.
As an example of a possible usage of xsl:choose, I created a new XSL stylesheet, switched to Mapper,
- selected books.xml as source and catalog.xml as target (from the examples\simpleMappings folder)
- dragged the "book" node to the "Book" node
- right clicked on the canvas, and chose XSLT Instructions | choose
- right clicked on the canvas, and chose XSLT Functions | count
- right clicked on the canvas, and chose Condition Tests | =
- dragged "author" to the left port of the "count()" block
- dragged the right port of the "count()" block into the top left port of the "=" block
- double clicked on the bottom left port of the "=" block and entered 1 in the dialog box
- dragged the right port of the "=" port into the left port of the "choose" block
- right clicked on the "Book" node in the target tree and selected Add Child Element, entering "SingleAuthor" as the node name
- dragged the top right port of the "choose" to the "SingleAuthor" node in the target tree
- dragged "author" from the source tree to "SingleAuthor" of the target tree
This generates
<xsl:choose>
<xsl:when test="count(authors/author) = 1">
<SingleAuthor>
<xsl:value-of select="authors/author"/>
</SingleAuthor>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
Then, I
- dragged from the square right port of the "choose" block to the "Authors" node of the target tree
- dragged "author" to "Author" twice (the first builds the for-each, the second copies the data)
This builds the xsl:otherwise part
<xsl:otherwise>
<Authors>
<xsl:for-each select="authors/author">
<Author>
<xsl:value-of select="."/>
</Author>
</xsl:for-each>
</Authors>
</xsl:otherwise>
Hope this helps,
Alberto Mapper(1).JPG Screenshot
|
|
|