XSLT / XQuery Back-mapping in Altova XMLSpy

Blessings Photo

Blessings
8 years 1 Views
Category:
Description:

Learn how XSLT/XQuery back-mapping works and see how it can be used to speed up your XSLT and XQuery development and ...

Back-mapping in Altova XMLSpy allows you to transform XML data using XSLT or XQuery and view how changes in the output affect the input XML. Here’s how to perform back-mapping in XMLSpy:

Step 1: Open XMLSpy

  1. Launch Altova XMLSpy.
  2. Open your XML file that you want to transform.

Step 2: Create an XSLT or XQuery File

  1. For XSLT:

    • Create a new XSLT file by selecting File > New > XSLT.
    • Write your XSLT transformation code.

    Example XSLT:

    xslt
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/books">
        <html>
          <body>
            <h1>Book List</h1>
            <ul>
              <xsl:for-each select="book">
                <li>
                  <strong><xsl:value-of select="title"/></strong> by <xsl:value-of select="author"/> - 
                  <em><xsl:value-of select="price"/></em>
                </li>
              </xsl:for-each>
            </ul>
          </body>
        </html>
      </xsl:template>
    </xsl:stylesheet>
    
  2. For XQuery:

    • Create a new XQuery file by selecting File > New > XQuery.
    • Write your XQuery transformation code.

Step 3: Configure Back-Mapping

  1. With your XML file open, select the Transformation menu.
  2. Choose either XSLT or XQuery, depending on which transformation method you are using.
  3. In the dialog that appears, select the XSLT or XQuery file you created.

Step 4: Perform the Transformation

  1. Execute the transformation by clicking the Transform button.
  2. The output will display in the output pane.

Step 5: Enable Back-Mapping

  1. Go to the View menu and select Show Back-mapping.
  2. This feature allows you to click on elements in the output and see their corresponding elements in the input XML.

Step 6: Edit and Update

  1. You can now edit the XML directly in the input pane.
  2. Changes made in the input XML will be reflected in the output, thanks to the back-mapping feature.

Conclusion

Back-mapping in Altova XMLSpy is a powerful way to visualize transformations and ensure that changes in the XML data are accurately reflected in the output. This makes it easier to debug and refine your XSLT or XQuery transformations. If you have any specific scenarios or questions, feel free to ask!