Render an XSD as an image

About rendering a XSD as an image.

1 Add the XSD file as attachment to Confluence

Open the edit mode of Confluence page where you want to render the XSD image. Click on files and images and locate the XSD schema on your computer and upload it to your Confluence page.

You don’t have to attach the same XSD file for every page where you want to use the macro. Once your XSD file is attached, the plugin can search through spaces and pages for your attachment.

2 Macro

Edit the Confluence page where you want to use the plugin. Start typing {xsd. Two options of the XSD-Viewer plugin will show up:

  1. XSD image

  2. XSD table

Select (1) XSD image to render an image.

3 Macro panel

Once you’ve selected XSD image, the macro panel/browser will show up giving you configuration fields.

  1. Page

  2. Attachment

  3. Starting element

  4. Depth

  5. Types to exclude

3.1 Page

This field has a built in search functionality. By typing the page where you’ve stored the attachment, even outside of the current space, you can select this page.

3.2 Attachment

A dropdown of all the attachments with the .xsd extension on this page will be shown. If no attachments with the .xsd extension are found the dropdown will mention this to you.

Note: The Atlassian OnDemand version does not yet support the attachment field type, this means that you have to manually enter the xsd filename as a string value. When this is fixed, it will be implemented! It is not possible to link to XSD files hosted elsewhere.

3.3 Starting element

Starting element is searched in the following order:

  • Element

  • SimpleType

  • ComplexType

Setting the starting element on setAttachmentResponse with depth 0 and no exclusions.

3.4 Depth

With the depth field you can configure how deep the image should be rendered. The depth configuration is applicable on element types, how far element types of element types should be rendered. The default setting is 1. For rendering the entire structure you can set the depth at 0. Please be aware that if the image to be rendered is too big the XSD-Viewer plugin might not be able to show the image. When recursiveness occurs in the chosen XSD schema we strongly suggest not to render the image at infinite depth. More about recursiveness can be found under recursiveness.

The image below is an XSD rendered with a depth limitation set at 2. The two borders drawn indicate the depth.

3.5 Types to exclude

In this input field you can configure element types you don’t want to see rendered. The element itself will still be rendered, otherwise the rendered image would be incorrect. This is handy to use when you want to render certain parts only. Some examples are given below.

The image below has a configured exclusion type. Compared to the full rendered image, you can see that the element itself is still drawn but the type no longer.

This gives you the advantage of going more into detail when wanting to render certain parts of your XSD schema as you can see in the example below.

4 Example XSD Schema

<xs:schema id="XMLSchema1"
           targetNamespace="http://tempuri.org/XMLSchema1.xsd"
           elementFormDefault="qualified"
           xmlns="http://tempuri.org/XMLSchema1.xsd"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
        >

    <xs:complexType name="error">
        <xs:sequence>
            <xs:element name="code" type="xs:int"/>
            <xs:element name="description" type="xs:string" minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="reference">
        <xs:all>
            <xs:element name="number" type="xs:string" minOccurs="0"/>
            <xs:element name="description" type="xs:string" minOccurs="0"/>
        </xs:all>
    </xs:complexType>

    <xs:complexType name="errors">
        <xs:sequence>
            <xs:element name="error" type="error" maxOccurs="10"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="messageAnswer">
        <xs:sequence>
            <xs:element name="indicationError" type="xs:boolean"/>
            <xs:element name="errors" type="errors" minOccurs="0" maxOccurs="1">
                <xs:annotation>
                    <xs:documentation>If the message contains errors</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="reference" type="reference"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="acknowledgement">
        <xs:sequence>
            <xs:element name="messageAnswer" type="messageAnswer">
                <xs:annotation>
                    <xs:documentation>The answer being given</xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

    <xs:element name="setAttachmentResponse" type="acknowledgement"/>

</xs:schema>

Last updated