Adding Processing Instructions to a Handler Definition

Processing Instructions appear at the beginning of many XML documents and are used by applications when parsing the document. They can include information such as the XML version and encoding.

Image

The following outlines the steps required to add Processing Instructions to your XML Thunder Handler design. There are two approaches described. The first approach applies when you are using an XML Schema to create your Handler design and the schema contains the processing instruction information. The second approach applies when you have an existing XML Handler definition and you would like to add Processing Instructions to it.

%%%%EditSectionPlaceHolder%%%%

Importing Processing Instructions from an XML Schema»



This approach can be used when you are creating a Handler design from an XML schema and the schema contains processing instructions.

1. Go to Tools -> Default Properties -> XML Rules and check the “Import XML declaration node” setting.

Image

Image

When you create your handler design using the New Handler Design Wizard, it should appear as shown below. Processing Instruction information will be included. The version and encoding attribute nodes will have a Fixed Value (i.e. a constant) that will always be written when the XML Thunder Writer creates an XML document. Note that the “Has Data” property is automatically set to “False” and the “Fixed Value” property is populated with the constant.

Image

Image

2. Add additional Processing Instructions

In some cases, you may need to add additional Processing Instruction information. For example, the XML schema may contain only the XML version information – as shown below.

Image

To add additional attributes to the Processing instruction (such as encoding), right click on the attribute list icon in the XML tree and choose “Add -> Attribute.

Image

Enter the name of the new Processing Instruction attribute (e.g. “encoding”).

Image

Set the “Has Data” property to “False” and set the “Fixed Value” that you would to appear in the XML documents that are created.

Image



%%%%EditSectionPlaceHolder%%%%

Adding Processing Instructions to an Existing Handler Definition»



Sometimes you may want to add Processing Instructions to an existing Handler. Examples of when this may be necessary are:

• You did not use an XML schema to create your XML Handler Definition (e.g. you used a copybook or header file and derived the XML structure, or you used a sample XML instance for the XML structure).

• The schema does not contain Processing Instructions, but you would like to include them in your XML document.

• You have an existing Handler Definition that did not import Processing Instructions and you would like to add them after the fact.

The following outlines the approach for adding Processing Instructions to an existing Handler definition.

1. Click on XML Item -> Add -> Add P.I. Node.

Image

The Processing Instruction node will appear at the bottom of the Handler design. Set the node name to “xml”.

Image

2. Drag the Processing Instruction Node to the Beginning of the XML Structure.

To get the P.I. node to the beginning of the Handler design, drag and drop the node to the top. You may find it helpful to collapse the nodes under the root element (click the “-“ symbol next to a node to collapse its children).

Image

3. Add Processing Instruction Attributes. Right-click on the Processing Instruction node and choose Add -> Add Attribute Node

Image

Set the “Has Data” property to “False” and set the “Fixed Value” that you would to appear in the XML documents that are created.

Image

To add additional attributes to the Processing instruction (such as encoding), right click on the attribute list icon in the XML tree and choose “Add -> Attribute.

Image

Enter the name of the new Processing Instruction attribute (e.g. “encoding”).

Image

Set the “Has Data” property to “False” and set the “Fixed Value” that you would to appear in the XML documents that are created.

Image