24.03.2013 Views

OpenEdge Development: Working with XML - Product ...

OpenEdge Development: Working with XML - Product ...

OpenEdge Development: Working with XML - Product ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Writing <strong>XML</strong> Documents <strong>with</strong> the Simple API for <strong>XML</strong> (SAX)<br />

Writing an <strong>XML</strong> document<br />

4–6<br />

The program flow of an <strong>XML</strong> write follows this general pattern in a forward-only stream:<br />

• The write begins <strong>with</strong> the START-DOCUMENT method and the document prolog is written.<br />

• To build an element, use the START-ELEMENT method to create the start tag for the desired<br />

element type. If you have created a SAX-attributes either to programatically build a list of<br />

attributes for the element or to capture a set of attributes during a SAX read operation, you<br />

can pass it as an optional parameter to the START-ELEMENT method. (The<br />

WRITE-EMPTY-ELEMENT and WRITE-DATA-ELEMENT methods also can take a SAX-attributes<br />

object as an optional parameter.)<br />

• Use the following methods to build the content of the tag:<br />

– INSERT-ATTRIBUTE( ) method<br />

– DECLARE-NAMESPACE( ) method<br />

– WRITE-CDATA( ) method<br />

– WRITE-CHARACTERS( ) method<br />

– WRITE-ENTITY-REF( ) method<br />

– WRITE-FRAGMENT( ) method<br />

• Use the END-ELEMENT method to provide the closing tag for the named element.<br />

• Use the other methods to provide other types of <strong>XML</strong> content:<br />

– WRITE-EMPTY-ELEMENT( ) method<br />

– WRITE-DATA-ELEMENT( ) method<br />

– WRITE-EXTERNAL-DTD( ) method<br />

– WRITE-PROCESSING-INSTRUCTION( ) method<br />

– WRITE-COMMENT( ) method<br />

• Use the END-DOCUMENT method to close the <strong>XML</strong> document.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!