Page 1 of 2 12>
Topic Options
#136407 - 2005-03-25 08:39 PM RFC: XML UDF's
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
Started a new topic due to size. Continued from here.
_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#136408 - 2005-03-25 08:45 PM Re: RFC: XML UDF's
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
Shawn, we've got a problem. The current setup of WriteXMLvalue, and probably every other UDF doesn't support this type of layout:
Code:
<korg>
<users>
<id>1</id>
<id>2</id>
<id>3</id>
<id>4</id>
<id>5</id>
</users>
</korg>



Back to the drawing board...


Edited by jtokach (2005-03-25 08:49 PM)
_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#136409 - 2005-03-25 11:50 PM Re: RFC: XML UDF's
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Quote:

and probably every other UDF doesn't




please be more specific.
_________________________
!

download KiXnet

Top
#136410 - 2005-03-27 12:21 AM Re: RFC: XML UDF's
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
All of the XML UDF's we've put together.
_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#136411 - 2005-03-28 08:07 PM Re: RFC: XML UDF's
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Jim,

I'm still working muchly with the "raw" XML functions. Lessons learned so far:

1) Reading Attributes of a node is much, much faster than reading child-elements (of the node) containing the same information... for example reading this:

Code:

<node1>
<data1>1</data1>
<data2>2</data2>
</node1>



is much slower then reading this:

Code:

<node1 data1="1" data2="2">
</node1>



Probably this has more to do with how one would "design" their schema, versus the UDF's themselves - just an observation.

-Shawn

Top
#136412 - 2005-03-28 08:18 PM Re: RFC: XML UDF's
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
Indeed, that makes sense; less parsing, more direct. Also agreed, more for planning purposes than anything else. I'll see what I can up with regarding the issue above.
_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#136413 - 2005-03-28 08:41 PM Re: RFC: XML UDF's
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I complained earlier in another thread - that it seemed a "waste" to have create an element as a child of the entire document, then later to have to add the element as a child of some other element ....

Lesson learned number two:

This isn't necessarily a bad thing - I learned that it is advantageous to be able to create an element, and to populate it with attributes and sub-elements - then to be able to later make the determination whether to actually add it as a child.

This ability really helped me in my GRID script - i was able to skip-over having to save CELL elements that only contained default settings (therefore don't need to be saved) - this speeds up the "loading" of the grid later on.

-Shawn

Top
#136414 - 2005-03-28 08:57 PM Re: RFC: XML UDF's
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Having a "messy" XML file isn't necessarily a "bad thing", if one has a half-decent XML editor/viewer to edit/view with ;0)

Lesson learned number #3 - messy XML aint the end of the world ... here's a sample of my GRID (spread-sheet) like schema so far...

<Grid RowCount="11" ColumnCount="3" AllowSorting="-1" AlternatingBackColor="-1" BackColor="16777215" ColumnHeaderStyle="2" CurrentColumnIndex="0" CurrentRowIndex="0" FontName="Verdana" FontSize="8" ForeColor="0" FullRowSelect="0" GridColor="8421504" GridLines="3" MultiSelect="0" ReadOnly="0" SingleClickEdit="0">
- <Columns>
<Column.0 Index="0" Alignment="-1" AllowSorting="-1" BackColor="-1" CellType="-1" ForeColor="-1" Format="" HeaderText="CategoryID" ImageIndex="-1" MinimumWidth="15" Name="CategoryID" ReadOnly="0" Resizable="-1" Width="100" ValueType="5" />
<Column.1 Index="1" Alignment="-1" AllowSorting="-1" BackColor="-1" CellType="-1" ForeColor="-1" Format="" HeaderText="CategoryName" ImageIndex="-1" MinimumWidth="15" Name="CategoryName" ReadOnly="0" Resizable="-1" Width="100" ValueType="8" />
<Column.2 Index="2" Alignment="-1" AllowSorting="-1" BackColor="-1" CellType="-1" ForeColor="-1" Format="" HeaderText="Description" ImageIndex="-1" MinimumWidth="15" Name="Description" ReadOnly="0" Resizable="-1" Width="100" ValueType="8" />
</Columns>
- <Cells>
<Cell.0.0 Value="1" RowIndex="0" ColumnIndex="0" />
<Cell.0.1 Value="Beverages" RowIndex="0" ColumnIndex="1" />
<Cell.0.2 Value="Soft drinks, coffees, teas, beers, and ales" RowIndex="0" ColumnIndex="2" />
<Cell.1.0 Value="2" RowIndex="1" ColumnIndex="0" />
<Cell.1.1 Value="Condiments" RowIndex="1" ColumnIndex="1" />
<Cell.1.2 Value="Sweet and savory sauces, relishes, spreads, and seasonings" RowIndex="1" ColumnIndex="2" />
<Cell.2.0 Value="3" RowIndex="2" ColumnIndex="0" />
<Cell.2.1 Value="Confections" RowIndex="2" ColumnIndex="1" />
<Cell.2.2 Value="Desserts, candies, and sweet breads" RowIndex="2" ColumnIndex="2" />
<Cell.3.0 Value="4" RowIndex="3" ColumnIndex="0" />
<Cell.3.1 Value="Dairy Products" RowIndex="3" ColumnIndex="1" />
<Cell.3.2 Value="Cheeses" RowIndex="3" ColumnIndex="2" />
<Cell.4.0 Value="5" RowIndex="4" ColumnIndex="0" />
<Cell.4.1 Value="Grains/Cereals" RowIndex="4" ColumnIndex="1" />
<Cell.4.2 Value="Breads, crackers, pasta, and cereal" RowIndex="4" ColumnIndex="2" />
<Cell.5.0 Value="6" RowIndex="5" ColumnIndex="0" />
<Cell.5.1 Value="Meat/Poultry" RowIndex="5" ColumnIndex="1" />
<Cell.5.2 Value="Prepared meats" RowIndex="5" ColumnIndex="2" />
<Cell.6.0 Value="7" RowIndex="6" ColumnIndex="0" />
<Cell.6.1 Value="Produce" RowIndex="6" ColumnIndex="1" />
<Cell.6.2 Value="Dried fruit and bean curd" RowIndex="6" ColumnIndex="2" />
<Cell.7.0 Value="8" RowIndex="7" ColumnIndex="0" />
<Cell.7.1 Value="Seafood" RowIndex="7" ColumnIndex="1" />
<Cell.7.2 Value="Seaweed and fish" RowIndex="7" ColumnIndex="2" />
<Cell.8.0 Value="13" RowIndex="8" ColumnIndex="0" />
<Cell.8.1 Value="ssss" RowIndex="8" ColumnIndex="1" />
<Cell.9.0 Value="14" RowIndex="9" ColumnIndex="0" />
<Cell.9.1 Value="xxxx" RowIndex="9" ColumnIndex="1" />
<Cell.10.0 Value="9" RowIndex="10" ColumnIndex="0" />
<Cell.10.1 Value="Shawn" RowIndex="10" ColumnIndex="1" />
</Cells>
</Grid>

Top
#136415 - 2005-03-29 10:17 PM Re: RFC: XML UDF's
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
Shawn just to add to this story I have seen on a simple google search that attributes are known to be fast but there is reason why.

Reference

Quote:


The primary key in an XML structure, the one used to identify specific objects, has a requirement that it be unique. Typically for XML structures, this uniqueness will come in the form of an ID of some sort. For the sample characters document, the ID is actually an attribute called "id" attached to the node. Because most parsers are able to parse attributes faster than elements and because an ID is less a describing property of the object and more a name for that object, you should keep IDs and ID references as attributes within your document structure for best efficiency.










But using attributes as child element has its problems too.

Quote:


Some of the problems with using attributes are:

* attributes cannot contain multiple values (child elements can)
* attributes are not easily expandable (for future changes)
* attributes cannot describe structures (child elements can)
* attributes are more difficult to manipulate by program code
* attribute values are not easy to test against a Document Type Definition (DTD) - which is used to define the legal elements of an XML document.

If you use attributes as containers for data, you end up with documents that are difficult to read and maintain. Try to use elements to describe data. Use attributes only to provide information that is not relevant to the data.



_________________________
Life is fine.

Top
#136416 - 2005-04-21 08:11 AM Re: RFC: XML UDF's
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
I have been doing some XML and noticed that in WriteXMLValue($source, $path, $value) any child included in the path cannot start with a number, otherwise you get error.
Example:
Code:

$= WriteXmlValue($xml, "korg/shawn/1_number", 119)

_________________________
Life is fine.

Top
#136417 - 2005-04-26 01:49 AM Re: RFC: XML UDF's
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
Shawn, Jim:
I find these new UDF´s very intresting and usefull but still there is something I cannot do with them.

It is ideal and for a better xml structure to store data on an XML file using the attribute as a table Id like this:
Code:
  
<messages>
<note id="p501">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<note id="p502">
<to>Jani</to>
<from>Tove</from>
<heading>Re: Reminder</heading>
<body>I will not!</body>
</note>
</messages>


I found difficulties when you need to update an elemets that hangs from a a root value referenced with an attribute, FE (case above). I want to modify the body when id="p502".

If we can solve this I think there is gonna be little left to manipulate any XML with Kix.

Thanks boys.


BTW:
Looks like 'without UBBcode/HTML' combo is not working.....mnn......yes it is, after I posted this modification...weird.
_________________________
Life is fine.

Top
#136418 - 2005-04-26 02:16 AM Re: RFC: XML UDF's
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Jose/Jim.

I have been playing much with the XMLDOM object model and wrote a little script that helped me "explore" the model. Its actually quite instructive to poke around XMLDOM and see (visually) just how "strange" it is.

If you want to check it out (the work-in-progress), I posted it here:

XML Workshop

You need the latest kixforms dev build to run this, here:

Kixforms Development Build

Would love to get your feedback/observations on this.

-Shawn

Top
#136419 - 2005-04-26 07:19 AM Re: RFC: XML UDF's
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
Well Shawn you have really done some difference here. Very nice man!! .
I will give a try tomorrow at and post some feedback.

About what I have asked above about the element uptade according to the attr (similar to id of table), now that Shawn is an XMLDOM expert he had fixed a code that does the task wich can perfectly fit to a new UDF.
Here is the code:
Code:
  
<?xml version="1.0" encoding="UTF-8"?>
<messages>
<note id="p501">
<to>Jani</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Dont forget me this weekend!</body>
</note>
<note id="p502">
<to>Jani</to>
<from>Tove</from>
<heading>How are you</heading>
<body>Gimme a call Tovy!!</body>
</note>
<note id="p503">
<to>Shawn</to>
<from>Joser</from>
<heading>Shawn you.....</heading>
<body>.....are a wonderfull person</body>
</note>
</messages>


In wich case if I want to update <to> value of id="p501" attr would be something like this. It is rought script wet.
Code:
  
UpdateFromAttribute('id', 'p501', 'body', 'Dont forget me this weekend!...please')


Code:
  
Function UpdateFromAttribute($Attr, $AttrValue, $Path, $PathValue)
For Each $note In $xml.documentelement.childnodes
If $note.getattribute($Attr) = $AttrValue
$heading = $note.selectsinglenode($Path)
$heading.text = $PathValue
EndIf
Next
EndFunction



Edited by Jose (2005-04-26 07:24 AM)
_________________________
Life is fine.

Top
#136420 - 2005-04-26 06:15 PM Re: RFC: XML UDF's
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
Jose,

There are several problems with the current UDF's which I didn't realize until afterwards; my second post in this thread being the main problem. I really haven't had time to come back to this and probably wont for a few weeks. Of course, if Shawn has developed a better model, we can choose to emulate it in Kix so that they are independant of the kixforms.dll. It certainly wont be anywhere near as fast though but at least they'll jive.
_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#136421 - 2005-04-26 06:39 PM Re: RFC: XML UDF's
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I didn't devise a new model, just wrote a kixscript that allows one to "explore" the existing XMLDOM model. It presents a TreeView on the left, with all the nodes as they are presented by xmldom. On the right, one can see all the xmldom properties. There is another Tab for xml view.

-Shawn

Top
#136422 - 2005-04-26 06:49 PM Re: RFC: XML UDF's
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
Ah, well then, these still need a major overhaul to cope with post #2 and jose's attribute thingys. We jumped into this without enough forethought. The specifications need to be changed to handle the above or a different model needs adoption. I think we have enough info and made enough mistakes to develop a solid set of UDF's here on out. Perhaps we can also consider performance this time through, or leave it for version 2.
_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#136423 - 2005-04-26 07:01 PM Re: RFC: XML UDF's
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
But Jim those "several problems" arent that bad. I have been using these udf's normally, besides there where none to use before so that is good. I say to go ahead shoot the UDF's and make corrections on the fly.
_________________________
Life is fine.

Top
#136424 - 2005-04-26 07:06 PM Re: RFC: XML UDF's
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
For me, the post #2 problem is a show stopper. It needs to be fixed/incorporated which means a major overhaul to the UDF's specifications.
_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#136425 - 2005-04-26 07:24 PM Re: RFC: XML UDF's
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
Pardon my ignorance Jim, can you explain me the problem #2 with a sample for me to understand? I cannot find your reference.
_________________________
Life is fine.

Top
#136426 - 2005-04-26 07:32 PM Re: RFC: XML UDF's
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Me too - Can we have a summary of issues ?
Top
Page 1 of 2 12>


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.078 seconds in which 0.029 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org