XSLT/XQuery Input View

The structure of the XML document associated to the edited XSLT stylesheet, or the structure of the source documents of the edited XQuery is displayed in a tree form in a view called the XSLT/XQuery Input view. If the view is not displayed, it can be opened from the WindowShow View menu. The tree nodes represent the elements of the documents.

XSLT

If you click a node in the XSLT/XQuery Input view, the corresponding template from the stylesheet is highlighted. A node can be dragged from this view and dropped in the editor area for quickly inserting xsl:template, xsl:for-each, or other XSLT elements that have the match/select/test attribute already completed. The value of the attribute is the correct XPath expression that refers to the dragged tree node. This value is based on the current editing context of the drop spot.

XSLT Input View

XSLT Example:

For the following XML document:

<personnel>
    <person id="Big.Boss">
        <name>
            <family>Boss</family>
            <given>Big</given>
        </name>
        <email>chief@oxygenxml.com</email>
        <link subordinates="one.worker"/>
    </person>
    <person id="one.worker">
        <name>
            <family>Worker</family>
            <given>One</given>
        </name>
        <email>one@oxygenxml.com</email>
        <link manager="Big.Boss"/>
    </person>
</personnel>

and the following XSLT stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
        version="2.0">
    <xsl:template match="personnel">
        <xsl:for-each select="*">
            
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

if you drag the given element and drop it inside the xsl:for-each element, the following pop-up menu is displayed:

XSLT Input Drag and Drop Pop-up Menu

If you select Insert xsl:copy-of (for example), the resulting document will look like this:

XSLT Input Drag and Drop Result

XQuery

You can also use the XSLT/XQuery Input view to drag and drop a node into the editing area to quickly insert XQuery expressions.

XQuery Input View

XQuery Example:

For the following XML documents:

                    <movies>
                    <movie id="1">
                    <title>The Green Mile</title>
                    <year>1999</year>
                    </movie>
                    <movie id="2">
                    <title>Taxi Driver</title>
                    <year>1976</year>
                    </movie>
                    </movies>
                    <reviews>
                    <review id="100" movie-id="1">
                    <rating>5</rating>
                    <comment>It is made after a great Stephen King book.
                    </comment>
                    <author>Paul</author>
                    </review>
                    <review id="101" movie-id="1">
                    <rating>3</rating>
                    <comment>Tom Hanks does a really nice acting.</comment>
                    <author>Beatrice</author>
                    </review>
                    <review id="104" movie-id="2">
                    <rating>4</rating>
                    <comment>Robert De Niro is my favorite actor.</comment>
                    <author>Maria</author>
                    </review>    
                    </reviews>

and the following XQuery:

                    let $review := doc("reviews.xml")
                    for $movie in doc("movies.xml")/movies/movie
                    let $movie-id := $movie/@id
                    return
                    <movie id="{$movie/@id}">
                    {$movie/title}
                    {$movie/year}
                    <maxRating>
                    {
                    
                    }
                    </maxRating>
                    </movie>

If you drag the review element and drop it between the braces, the following pop-up menu is displayed:

XQuery Input Drag and Drop Pop-up Menu

Select FLWOR review, the resulting document will look like this:

XQuery Input Drag and Drop Result

Was this helpful?