abhay1207
24th November 2005, 13:13
Hi All
Does Baan IV c Support XML. I am trying Parse an XML file. How can I do this?

vahdani
24th November 2005, 13:24
Hi,

yes, Baan IVc supports XML as long as you have recent Porting set. See also: XML Object (http://www.baanboard.com/programmers_manual_baanerp_help_functions_xml_overview) and work through the example.

abhay1207
24th November 2005, 13:50
Hi,

yes, Baan IVc supports XML as long as you have recent Porting set. See also: XML Object (http://www.baanboard.com/programmers_manual_baanerp_help_functions_xml_overview) and work through the example.

hi,

how to include libraries for Baan IV to work for XML?what is that syntax for it..Please give one example..

Thanx

abhay1207
24th November 2005, 13:52
hi,

how to include libraries for Baan IV to work for XML?what is that syntax for it..Please give one example..

Thanx

vahdani
24th November 2005, 14:35
Hi,

no need to include anything. To see if the XML functionality is there. Just create a 3GL script with following content and try to compile it.


function main()
{
long cmfId, identId, recipientsId, fromId, dtdId
long fd, retVal

|Create the doctype element and populate its contents
dtdId = xmlNewNode("CMF", XML_DTD)
retVal = xmlsetAttribute(dtdId, "NAMEURL", "cmf1.dtd")

|Create the root element and make it a right sibling of the XML_DTD node.
cmfId = xmlNewNode("CMF" )
retVal = xmlAdd(dtdId, cmfId )

|Create IDENTIFICATION element and add its attributes
identId = xmlNewNode("IDENTIFICATION", XML_ELEMENT, cmfId)

retVal = xmlSetAttribute (identId, "MESSAGE-ID", "34a98u0erirori" )
retVal = xmlSetAttribute(identId, "CLASS", "order" )
retVal = xmlSetAttribute(identId, "SUBJECT", "Subject string" )

|Create RECIPIENTS element
recipientsId = xmlNewNode("RECIPIENTS", XML_ELEMENT, cmfId)

|Create FROM element and add its attributes
fromId = xmlNewNode("FROM", XML_ELEMENT, recipientsId)

retVal = xmlSetAttribute(fromId, "NAME", "Wiebe Riphagen" )
retVal = xmlSetAttribute(fromId, "TYPE", "SMTP" )
retVal = xmlSetAttribute(fromId, "ADDRESS", "wriphagen@baan.nl" )

|Open a file for write and store the XML document
fd = seq.open("file.xml", "w" )
xmlWritePretty(fd, dtdId, 0 )
seq.close(fd)

parse()
}

|The resulting XML-document is shown below:
|<?xml version="1.0"?>
|<!DOCTYPE CMF SYSTEM "cmf1.dtd">
|<CMF>
| <IDENTIFICATION
| MESSAGE-ID="34a98u0erirori"
| CLASS="order"
| SUBJECT="Subject string"
| />
| <RECIPIENTS>
| <FROM
| NAME="Wiebe Riphagen"
| TYPE="SMTP"
| ADDRESS="wriphagen@baan.nl"
| />
| </RECIPIENTS>
|</CMF>

function parse()
{
long fd
long cmfId, identId, fromId
long retVal
long found

string error_string(120)
string messageId(20)
string messageClass(20)
string subject(100)

|Open the XML file for reading.
fd = seq.open ("file.xml", "r" )

|Parse the XML file
cmfId = xmlRead(fd, error_string)
seq.close(fd)

|Search for the IDENTIFICATION element
identId = xmlFindFirst( "IDENTIFICATION", cmfId)
if (identId <> 0 )
then
|Get the identificiation attributes
retVal = xmlGetAttribute(identId, "MESSAGE-ID" ,messageId)
retVal = xmlGetAttribute(identId, "CLASS", messageClass)
retVal = xmlGetAttribute(identId, "SUBJECT", subject)
endif

|Search for the first FROM element
fromId = xmlFindFirst( "FROM", cmfId)
if (fromId <> 0)
then
|TODO: Get the from attributes

endif

|Alternative 1 to get to the FROM element
fromId = xmlFindFirstMatch( "<CMF>.<RECIPIENTS>.<FROM>", cmfId)

|Alternative 2 to get to the FROM element
fromId = xmlFindFirstMatch( "?<FROM>", cmfId)

|Alternative 3 to get to the FROM element
fromId = xmlFindFirstMatch( "<CMF>.lChild.<FROM>", cmfId)

|Alternative 4 to get to the FROM element
fromId = xmlFindFirstMatch( "<CMF>.<IDENTIFICATION>.right.fChild", cmfId)

|Alternative 5 to get to the FROM element
fromId = xmlFindFirstMatch( "parent.lChild.fChild", identId )

|Alternative to get to the CMF> element from the <FROM> element
cmfId = xmlFindFirstMatch( "*<CMF>", fromId )

}

abhay1207
27th December 2005, 12:11
Hi
I tried as u suggested, but I got the compilation errors. I am sending the screen shot as attachment of those error messages.

Thanks

Abhay

JaapJD
28th December 2005, 14:34
You seem to use a rather old porting set.

abhay1207
2nd January 2006, 07:00
Hi
I am using Porting set 6.1c.07.07.

vahdani
2nd January 2006, 18:54
Hi,

your porting set is more than up to date! According to solution 107473 the xml functionalitiy is declared in bic_global include file located in $BSE/include6.1. This file is not automatically updated when a new porting set is installed. Apparantly you have an old version of the file on your Baan installation. See Solution 108694 for downloading the latest bic_global or Solution 114812 for all the latest includes. If you download using solution 108694 you have to rename the downloaded file to bic_global and then copy it to $BSE/include6.1.