LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2001, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 29 Jun 2001 12:06:21 +0200
Reply-To:   "Tribius, Heide" <Heide.Tribius@KFW.DE>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Tribius, Heide" <Heide.Tribius@KFW.DE>
Subject:   Re: SAS 6.12 and XML
Comments:   To: "bdvorak@YAHOO.COM" <bdvorak@YAHOO.COM>
Content-Type:   text/plain; charset="iso-8859-1"

sorry, last code doesn't work...

refered to the mail by Urs we have a class ('XMLCODE') which makes from a SCL-list a XML-File. I think you are interested in code - perhaps you can use it. But unfortunately you have to bring your data into the SCL-list before (I think, you can use the organizational chart class for it). And we have the discription of the structure in DTD-file (for this example at the end), so this class produces just the data-XML-code. (sorry, my English is quite poor and I'm not really sure, wether you can understand it... - please contact me, if you need further information)

greetings from Germany. Heide

XMLCODE.CLASS: _______________________________ instance variables: ca (character, automatic, value= <), ce (character, automatic, value= </), cx (character, automatic, value= >)

methods: MAKE (new - run SAS/AF entry)

entry-parameters: liste (SCL-list with named items, name=tag-name) level (starts with 1) fid (file-id XML-file) knotenpktl (SCL-list which contains the tagnames of parents (with tagnames inside))

_______________________________ code:

length ca cx $1 ce $2 name $8; entry liste level fid knotenpktl 8;

INIT:

do i=1 to listlen(liste);

name = nameitem(liste,i);

if not searchc(knotenpktl,name) then do;

link ZEILE;

end;

else do; * list of entries; link AGR;

zz+1; * counts the elements; cl = instance(getnitemn(_self_,'_CLASS_'));

call send(cl,'MAKE', getniteml(liste,name,zz),level+1,fid,knotenpktl); call send(cl,'_TERM_'); link EGR;

end;

end;

return;

ZEILE: * only one line;

rc = fput (fid, repeat(' ',level*2) !!ca!!lowcase(name)!!cx);

rc = fput (fid, trim(left(getitemc(liste,i))));

rc = fput (fid, ce!!lowcase(name)!!cx);

rc = fappend(fid);

return;

AGR: * start group; if searchc(knotenpktl,name) then do;

rc = fput (fid, ' ');

rc = fappend(fid);

end;

rc = fput (fid, repeat(' ',level*2) !! ca !!lowcase(name)!!cx);

rc = fappend(fid);

return;

EGR: * end group; rc = fput (fid, repeat(' ',level*2) !! ce !!lowcase(name)!!cx);

rc = fappend(fid);

return;

ca=ca; * compiler dummies;

ce=ce;

cx=cx;

rc=rc;

_self_=_self_;

________________________________________________________________ call inside the SCL-program:

rc = filename('infofile',pathname('DATEN')!!'\menu.xml'); * allready exists; fid = fopen ('infofile','O');

*__ first lines ___________________________________________;

rc = fput (fid,'<?xml version="1.0" encoding="ISO-8859-1" ?>');

rc = fappend(fid);

rc = fput (fid,'<!DOCTYPE menu SYSTEM "menu.dtd">'); rc = fappend(fid);

rc = fput (fid,' ');

rc = fappend(fid);

*_ list with tagnames of parents _______________; li = makelist(); rc = insertc(li,'MENU' ,-1);

rc = insertc(li,'VERSION',-1);

rc = insertc(li,'THEMA' ,-1);

rc = insertc(li,'LISTE' ,-1);

rc = insertc(li,'EINTRAG',-1);

*__ call the class ______________; call send(instance(loadclass('XMLCODE')),'MAKE', liste, 1, fid, li);

*__ end _________; rc = dellist(liste,'Y'); rc = dellist(li);

call fslist ('infofile'); * just for test; rc = fclose (fid);

____________________________________________________ DTD-file:

<!--MIS.menu.dtd--> <!--Datenbeschreibung-->

<!ELEMENT titel (#PCDATA)> <!ELEMENT link (#PCDATA)> <!ELEMENT infotext (#PCDATA)> <!ELEMENT id (#PCDATA)> <!ELEMENT menu (titel, version*)> <!ELEMENT version (id, titel, footnote, thema*)> <!ELEMENT footnote (#PCDATA)> <!ELEMENT thema (id, titel, liste*)> <!ELEMENT liste (id, titel, infotext, link?, eintrag*)> <!ELEMENT eintrag (id, titel, link)>


Back to: Top of message | Previous page | Main SAS-L page