Skip to main content
Jump to: navigation, search

STP/Policy Component/Policy editor documentation

< STP‎ | Policy Component
Revision as of 07:39, 27 August 2007 by (Talk | contribs) (Quick start)

The STP Policy Editor and XEF (Xml Editing Framework)

The STP policy editor is an Eclipse editor for editing WS-Policy content or other XML content that is based on XML-Schema with a graphical editor. It is based on the XML Editing Framework (XEF), which also part of STP.

What kind of policies can be edited

The simplest way to use the policy editor is on a file in the Eclipse workspace. In the example below you can see the policy editor being used on a file called 'myService.policies'. The file contains a logging and a security policy.


The policy editor dynamically generates an editor as the above one that can be used to edit policies. It provides both a graphical view as well as a text-based view of the policy document being edited.

The editor in the example above is editing the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<wsp:Policy xmlns:wsp="">
    <acme:Logging xmlns:acme="">
      <file encryption_password="edcba" encryption_type="DES" filename="myService.log" rolling_file="true" />
    <acme:Security xmlns:acme="" />

In this example, the Logging and Security policy are based on their XML Schema definitions and the policy editor has created the editor dynamically by reading the Schema definitions. By looking at the editor, you can see that the policies document currently contains 2 policies: Logging and Security. The logging policy has a sub-element called 'file'.

The file element has a number of attributes, some of which has defaults others are required. They have tooltips and documentation in the policy help view. There are also extra sections with 'Encryption' and 'Advanced' attributes. There are fields that are enumerated (the encryption type) and password fields. Some fields have their units of measurement specified (the kb. field) and all of them have proper display names. The following section provides a quick start to getting here.

The resulting XML file in this example is a WS-Policy compliant document. However note that currently not all of the WS-Policy constructs are supported yet. Currently only wsp:All is supported.

Quick start

While the policy editor doesn't have to work directly on files, it uses the org.eclipse.stp.ui.xef.editor.XMLProviderEditorInput as its editing interface. The XMLProviderEditorInput provides the actual XML to be edited as well as a catalogue of the schemas available.

The eclipse.stp.ui.xef.editor.XMLXPathView in the org.eclipse.stp.xef.test fragment provides a way to edit a file in your project using the policy editor. It opens the Policy Editor using all the .xsd files in the current project as the policy catalogue.

To open this view select Window | Show View | Other | XML XPath View while having the test fragment loaded. (The reason why this view is in the test fragment is because its really for testing purposes).

To start with an empty policy file, create a file, e.g. myService.policies with the following initial content, which really is an empty WS-Policy document.

<wsp:Policy xmlns:wsp="">

(BTW it would be a nice addition if an empty file would work here too).

Also make sure to have with the following schema for the logging policy in your project. It's called Logging_Basic (in the file acme_logging_basic.xsd) as it is just the basic schema. Some of the GUI elements in the previous screenshot have been influenced by annotations. Below you can find the basic schema to start with without these annotations.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="" 
  <xs:complexType name="fileLoggingType">
    <xs:attribute name="filename" type="xs:string" use="required"/>
    <xs:attribute name="echo" type="xs:boolean" default="false"/>
    <xs:attribute name="rolling_file" type="xs:boolean"/>
    <xs:attribute name="max_size" type="xs:integer" default="50000"/>
    <xs:attribute name="encryption_type">
        <xs:restriction base="xs:string">
          <xs:enumeration value="none"/>
          <xs:enumeration value="AES"/>
          <xs:enumeration value="DES"/>
    <xs:attribute name="encryption_password" type="xs:string" use="required"/>
    <xs:attribute name="write_interval" type="xs:integer" default="10000"/>
  <xs:element name="Logging_Basic">
        <xs:element name="file" type="tns:fileLoggingType"/>
        <xs:element name="console"/>

Select the file and hit 'Edit' in the XML XPath View:


Then hit 'Add Policy' and you will see the policy in the Policy Catalogue:


Select the policy and you see it appear:


From the little 'plus' sign on the policy you can see that there are extra elements. Right-click and you can choose from 'file' and 'console'. These are taken from the 'xs:choice' in the Logging_Basic element. xs:sequence and xs:all are also supported.

After selecting the 'file' sub-element you can see the attributes in their basic form as found in the schema:

Back to the top