Event Observer and Contributed Tool

The Class

The XML_Convert class is an observer that listens for the post-process event of the Incremental build of data/other files.

Class Documentation

Click HERE to view the API documentation for this class template. The complete documentation for all of the classes can be found in the API Reference.

Source Code

Click HERE to view the source code for this class.

Double Duty Class

This class actually performs two distinct functions. It will register itself as a post-process observer. It will also register itself as a contributed tool. This section will discuss only the event observer portion of the class.

Do the Work

The update() method has been modified to perform specific actions for the post process of the build process for specific minor IDs.

BuildType_DataFile
This observer will check the file to verify that it is a ProvideX keyed file and will then convert it to XML.
BuildType_OtherFile
This observer will verify that the file has an .xml extension and will then attempt to convert (or create) a ProvideX data file. The conversion logic requires that the XML file be defined for the schema 'providex'.
update:
enter aPvxState 

	/*
	 * This observer is triggered when an incremental build is initiated on a
	 * data file.
	 *
	 * If the source file ends with the XML extension, it will be converted to
	 * a PVX keyed file.  Otherwise, the file header is read to verify that this
	 * is in fact a PVX keyed file and then it is converted to XML.
	 */
 
	/* Get the major/minor codes for this event. */
	psMajor$     = aPvxState'getMajor$(), \
	psMinor$     = aPvxState'getMinor$()

	/* Get the parameters that were passed into this event. */
	source$      = aPvxState'getArgumentValue$(_pvxConstants'SrcFile$), \
	dest$        = aPvxState'getArgumentValue$(_pvxConstants'Dest$), \
	domFile$     = aPvxState'getArgumentValue$(_pvxConstants'DomFile$), \
	passwd$      = aPvxState'getArgumentValue$(_pvxConstants'pkf_Password$), \
	passwd_type$ = aPvxState'getArgumentValue$(_pvxConstants'_iPasswordType$)
	
	/* Create a local reference to the EventLog */
	_eventLog = new("ErrorLogBuilder",_pvxConstants,ViewManager)
	_eventLog'bufferInit()
	_eventLog'bufferAddText("["+psMajor$+"]"+$0A$+"==:"+psMinor$+":=="+$0A$)

 	switch psMajor$
	case _pvxConstants'Incremental_Build$
		switch psMinor$

		/* Convert a ProvideX data file to XML */
		case _pvxConstants'BuildType_DataFile$
			_obj'data2xml(source$)
			break
		/* Convert a XML to ProvideX data file */
		case _pvxConstants'BuildType_OtherFile$
			_obj'xml2data(source$,dest$)
			break
		end switch
		break
 	end switch

	_eventLog'bufferWriteText()
	drop object _eventLog

return 0