Scolring - Forum

Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology

Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered

You are not logged in.

#1 24-Oct-2014 18:18:53

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

writing a simple .xml file with scol

colleagues:

i would like to create a simple .xml file format with scol, one that just contains a scene name string and string representing the url of a .mesh file:

<scene>scenename, type S </scene>
<mesh>http://www.ifam.net/mesh.mesh, type S</mesh>
</scene>

how would I use scol to write this file? I've looked over the api, but the way it is implemented in the editor is a bit too complicated for me to understand.

-h

Offline

#2 24-Oct-2014 21:08:52

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: writing a simple .xml file with scol

You can use the xmlparser from os3D lib or directly the xml API : http://redmine.scolring.org/projects/sx … psxml.html

using the lib :

  let XMLcreate file nil -> xmlstr in
  let XMLaddMark xmlstr "scene" nil ["name" "scene name"]::nil nil -> scenestr in
  let XMLaddMark xmlstr "mesh" scenestr nil "http://www.ifam.net/mesh.mesh"-> meshstr in
    XMLSave xmlstr file;

Offline

#3 24-Oct-2014 21:16:52

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: writing a simple .xml file with scol

Thx  smile

Offline

#4 28-Oct-2014 20:08:41

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: writing a simple .xml file with scol

hebdemnobad wrote:

Thx  smile

here is code I wrote to save a simple xml file, with two parameters. each is a child of a scene parameter.  this writes the file:

<scene minfps="12"/>



<scene maxpaksize="5"/>

here is the code:

proto XMLload = fun [S] XMLfile;;
proto XMLcreate = fun [S S] XMLfile;;
proto XMLaddMark= fun [XMLfile S XMLmark [[S S] r1] S] XMLmark;;
proto XMLwrite = fun [XMLfile S] I;;
//typeof file = XMLfile;;


fun secureLoad(pack)=

  let _testpak pack -> ret in
  if (ret == nil) then

  (
    _fooS "xmlparser loading";
    _load pack;
    1;
  )
  else
  (
    _fooS strcat "Error in " ret;
   0;
  );;
    
fun load_dependencies() =
let "tools/os3dlib/tools.pkg"::"tools/os3dlib/xmlparser.pkg"::nil -> list_of_dependencies in
(
		while (list_of_dependencies!= nil)&& (secureLoad hd list_of_dependencies) do
				(
					set list_of_dependencies = tl list_of_dependencies;
					_fooS "dependencies loading";
				);
		//all dependencies have been read
		if list_of_dependencies==nil then
  				(
  			        //read hybridgui.xos and write to hybridgui.xml in openspace3d/tests/filreader
  			          let "xmlwriter/xmlwriter.xml" -> file in
                   let XMLcreate file nil -> xmlstr in
					  	 let XMLaddMark xmlstr "scene" nil ["minfps" "12"]::nil nil -> namestr in
					  	 let XMLaddMark xmlstr "scene" nil ["maxpaksize" "5"]::nil nil -> paksizestr in
						 //let XMLaddMark xmlstr "mesh" scenestr nil "http://www.ifam.net/mesh.mesh"-> meshstr in  
						(
  							 XMLwrite xmlstr "xmlwriter/xmlwriter.xml";
  							 		
  						);
  				0;
  				) 
  		else
  				(
  							_fooS "error in dependency loading";
  				0;
  				);
);
0;;
fun main ()=
  _showconsole;
  load_dependencies;
  0;;

thx for your help, it works

Offline

#5 28-Oct-2014 20:10:06

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: writing a simple .xml file with scol

smile

Offline

#6 28-Oct-2014 20:11:40

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: writing a simple .xml file with scol

it has confusing comments in it..when I get my project going I have some cleaning up to do.

Offline

#7 28-Oct-2014 20:16:35

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: writing a simple .xml file with scol

All the code for that is in the post about config file :

fun getConfigParam(type, pname)=
  let XMLgetMarkByValue xmlConfigFile "config" -> configmark in
  let XMLgetMarkByValueFromMarkSons configmark type -> typemark in
  let XMLgetMarkByValueFromMarkSons typemark pname -> pmark in
    XMLgetParam pmark "value";;

Offline

#8 28-Oct-2014 20:22:35

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: writing a simple .xml file with scol

arkeon wrote:

All the code for that is in the post about config file :

fun getConfigParam(type, pname)=
  let XMLgetMarkByValue xmlConfigFile "config" -> configmark in
  let XMLgetMarkByValueFromMarkSons configmark type -> typemark in
  let XMLgetMarkByValueFromMarkSons typemark pname -> pmark in
    XMLgetParam pmark "value";;

thx, I will try to figure this out.

Offline

#9 28-Oct-2014 20:50:25

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: writing a simple .xml file with scol

I'm answering in the thread about reading an .xml file.

Offline

Board footer

Powered by FluxBB