Prev Next

Model an XSL Transformation

When you model an XSL Transformation, you can either draw on files that already exist in your file system, or you can create the contents of the stylesheet and source within the model elements.

Model elements from existing files

This is the simplest and most common method for modeling transformations. When you drag a file on to the XML Transform diagram, the appropriate Artifact element is generated for you. You can then use the Quick Linker to link the file Artifact elements as inputs to the XML Transform element, using Trace connectors.

Optionally, you can:

  • Specify an alternative output location (file) by linking an XML File or Output Artifact to a Trace connector from the XML Transform Artifact
  • Validate the output document by dragging an XSD schema file on to the diagram and connecting the resulting XSD element to any Output Artifact of the XML Transform element

Step

Action

See also

1

Open your file browser and the XML Transform diagram.

2

In the file browser, click on the input file and drag it onto the XML Transform diagram.

A prompt displays to save the file as an:

  • External Artifact, where the XML File Artifact serves as a shortcut to the file in the file system
  • Internal Artifact, where the file content is read into the XML File Artifact and stored inside the model; you would select this option to make the source file contents available to other users of the model

3

Select the 'External Artifact' option.

An XML File Artifact element is generated for the input file.

4

In the file browser, click on the XSL stylesheet file and drag it onto the XML Transform diagram.

In response to the prompt, select the 'External Artifact' option.

An XSLT element is generated for the stylesheet file.

5

Drag the XML Transform icon from the Toolbox onto the diagram, to create an XML Transform Activity element. If you prefer, give this element a new name.

6

Dragging the Trace icon from the 'Common' Toolbox page, create relationships between the:

  • Input XML file element and the transformation Activity element
  • XSLT Stylesheet file element and the transformation Activity element

7

(Optional.)

  • If you want to capture the output in a file, locate the appropriate file in the file browser and drag it onto the diagram to generate another File Artifact; link it to the XML Transform element with a Trace connector
  • If you want to validate the output document, locate the XSD schema file in the file browser and drag it on to the diagram to generate an XSD element; link this to the output File Artifact (or any Output Artifact) of the Transform element

8

Press Ctrl+S to save the diagram contents.

If the output is intended to be HTML, your diagram might resemble this:

Modeling elements from scratch

When you use the 'XML Transformation' Toolbox to create XSLT and XML File elements, the system stores these as model documents. You double-click on the elements on the XML Transform diagram to open the model documents in Enterprise Architect's XSLT Debugger, where you can write and edit the file contents. When the document is saved, the contents will be saved back to the model.

Otherwise, the process of modeling a transformation is the same as described in Modeling elements from existing files.

Edit Documents with the XML Editor

Enterprise Architect provides a robust and powerful XML editor with many features including:

  • intelli-sense
  • Contextual structure tree providing quick alternative navigation ( tip: press CTRL+1 to toggle document tree view)
  • Custom icons for XSL and XSD document elements
  • Code completion and
  • Validation of document and referenced schemas

The XML Editor will open when any document with an xml declaration is opened within Enterprise Architect. (Alternatively, press Ctrl+Shift+O.) The XSLT Debugger uses two XML editors side-by-side, to display both the stylesheet and the document being transformed.

Learn more