Jump to content


Photo

Important! Changes In XML Handling!


  • Please log in to reply
23 replies to this topic

#1 BenJeremy

BenJeremy

    X-S Elysian

  • Head Moderators
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 9,690 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:v1 (xenon)

Posted 21 February 2004 - 08:11 PM

There are important changes happening to the XML handling routines. They will make things easier, but if you are doing anything "undocumented" you may encounter problems.

The new changes affect how you specify "location" using the dotted format, and expands the places you can use dotted locations as well.

While you do not have to be precise, the way you specify a location can determine how an element, node or attribute is created...

The following, in old format, will not create an attribute:

!.SomeNode.SomeElement.SomeAttribute

The following, in "new" format, will:

!.SomeNode^SomeSlement~SomeAttribute

Note the new separators... "^" precedes an element. Must be last or second-to last (proceeded by a dotted attribute name or the tilded attribute name)

This new precision will give you a bit more control. Getting existing values can still be done using all dots as separators - MXM will search for nodes first, but then fall back to elements then attributes.

I hope this isn't too unclear; the new format was necessary to simplify (and perhaps speed things up a bit) in the code.

Also new is the Query. You may have been aware of the index - "!.SomeNode:5.SomeElement" - where identically named nodes or elements could be chosen based on the position in the XML they had, using the ":" and a number. This is still available, but now you can alternatively use a query: "!.SomeNode?Color=Red.SomeElement" which will look for a node or element among "multiples" with a subvalue that matches the query. Int he example, we look at all of the nodes named "SomeNode" and the first having an attribute or Element named "Color" with a value of "Red" is selected as the node to be used.

There is an example in the Build 1175 WIP internal.xml test script.

Lastly, I've added the ability to use an enhanced form of the dotted location anywhere variables are used. In this case, we preceed the dotted location with the "@" symbol and the handlename: "@MyXML.SomeNode?Color=Red.SomeElement" could be used anywhere a variable is used. Note these are not global, and the XML must be open and available. Still, this will make things very easy for you, I imagine.

I'd really like to hear the thoughts of ActionScripters on this.

#2 flattspott

flattspott

    X-S Freak

  • Moderator
  • PipPipPipPipPip
  • 1,787 posts
  • Location:Southern California
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 21 February 2004 - 08:38 PM

Gonna go check it out in second or two.

#3 flattspott

flattspott

    X-S Freak

  • Moderator
  • PipPipPipPipPip
  • 1,787 posts
  • Location:Southern California
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 21 February 2004 - 09:05 PM

QUOTE
<testxml>
<somenode>
<someelement anotherattr="ThisIsAnotherAttr!" someattr="ThisIsAnAttribute!">ThisIsAnElement, too!</someelement>
<someelement index="1" />
<someelement index="2" />
<someelement index="3" />
<someelement index="4" />
<someelement index="5">This Is the 6th Element!</someelement>
<someelement index="6" />
<someelement index="7" />
<someelement index="8">This Is the 9th Element!</someelement>
<someothernode somenodeattr="ThisIsAnAttribute!">
<anotherelement>ThisIsAnElement!</anotherelement>
</someothernode>
<someothernode testid="3">
<anotherelement>ThisIsAnElement Node 1!</anotherelement>
</someothernode>
<someothernode testid="4">
<anotherelement>ThisIsAnElement Node ID 4!</anotherelement>
</someothernode>
</somenode>
</testxml>


Now this is what I call an example. Good job BJ. I also think it's fantasic that with this new way the <element attr="value" /> works now unlike before when it would put it like
<element attr="value">
</element>

Edited by flattspott, 21 February 2004 - 09:06 PM.


#4 BenJeremy

BenJeremy

    X-S Elysian

  • Head Moderators
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 9,690 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:v1 (xenon)

Posted 21 February 2004 - 09:10 PM

Yes, you'll notice that when I set a value for the 9th identically named node, it created enough nodes to give me a proper node, and attributed them with an index value (except the first one, which by default is "0" numerically)

Same for Queried nodes and elements - it will create these nodes in a referencable fashion, meaning the query key and value will be set as attributes.

I imagine this will make life a LOT easier for using XML. Tetris and other big scripts could probably shave a lot of weight off of them with the new access methods.

#5 flattspott

flattspott

    X-S Freak

  • Moderator
  • PipPipPipPipPip
  • 1,787 posts
  • Location:Southern California
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 21 February 2004 - 09:15 PM

Well I gonna go and mess around with this stuff now. It's 3PM here now, I'll probable post my "thoughts" in a few hours

QUOTE
Yes, you'll notice that when I set a value for the 9th identically named node, it created enough nodes to give me a proper node, and attributed them with an index value (except the first one, which by default is "0" numerically)


Your referring to this part, part
<someelement index="1" />
<someelement index="2" />
<someelement index="3" />
<someelement index="4" />
<someelement index="5">This Is the 6th Element!</someelement>

My question about this is, is the "index" the default attr if not specified?

Edited by flattspott, 21 February 2004 - 09:24 PM.


#6 geniusalz

geniusalz

    Team MXM

  • Head Moderators
  • PipPipPipPipPip
  • 1,827 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:unknown

Posted 21 February 2004 - 09:23 PM

Cool, makes so much so much easier.

Skin customization will be much simpler:
XMLSetElementAttr !.LayoutElement?Source="DriveFFree" Source DriveGFree

/off to clean up tetris further

*still working on dialog maker, in case anyone's wondering

#7 flattspott

flattspott

    X-S Freak

  • Moderator
  • PipPipPipPipPip
  • 1,787 posts
  • Location:Southern California
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 21 February 2004 - 11:39 PM

Nevermind I figured it out myself. Yes, I am just that good. wink.gif

Maybe we could get an XMLForceOrder type of deal though.

Cause I just made a script that spits out the avalaunch xml and it is putting the internal menu stuff before the user menus.

Settings
IRC
Games

instead of

Games
Settings
IRC

Because the internal nodes are <item while the user ones are <list. So I am assumming this is done alphabetically.

Edited by flattspott, 21 February 2004 - 11:56 PM.


#8 BenJeremy

BenJeremy

    X-S Elysian

  • Head Moderators
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 9,690 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:v1 (xenon)

Posted 22 February 2004 - 12:36 AM

Glad you figured it out.

MXM's parser reads everything in order of the file.

Let me know, within reason, if there's something I can provide for the XML access. The new access methods only apply to XMLGetValue and XMLSaveValue and the "@" variable access methods, but I'll add it to other XML commands as I can.


There actually was a whole slew of things I am scrapping that were never documented, including a way to increment through the tree - but using the indexed values is far better anyway.

I'll have to add a method to check to see if a "location" is actually there, too. Accessing a location with an XMLGetValue won't create a node - it will just return the default if it doesn't exist. XMLSetValue, on the other hand, always creates the nodes, and they will be created in the order you create them in, on a given node.

Of course, if you want to do a sort, you could always use an intermediate XML tree to performs something like that.




I just want to make sure nothing is broken. I ran Tetris after making the changes only to find all the text disappeared. blink.gif Turns out I never initialized the default text colors (fixed in 1175 to WHITE) for ActionDraw lists, and since it was never defined, they were coming up as "0" in the previous build. Doh.

At least Tetris is a good exercise in testing XML functionality rolleyes.gif

#9 flattspott

flattspott

    X-S Freak

  • Moderator
  • PipPipPipPipPip
  • 1,787 posts
  • Location:Southern California
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 22 February 2004 - 12:54 AM

Well with this new (better) way, I can't see anything thats needs to added at the moment.

But what's up with it automaking an index="1" etc whenever you use and index? This is kinda annoying.

#10 BenJeremy

BenJeremy

    X-S Elysian

  • Head Moderators
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 9,690 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:v1 (xenon)

Posted 22 February 2004 - 12:59 AM

QUOTE (flattspott @ Feb 21 2004, 09:54 PM)
Well with this new (better) way, I can't see anything thats needs to added at the moment.

But what's up with it automaking an index="1" etc whenever you use and index? This is kinda annoying.

I needed a way of making a set of new values that had at least some unique aspect to them, but it also allows you to create a large number of nodes or elements, kind of like BASIC's DIM statement.

#11 flattspott

flattspott

    X-S Freak

  • Moderator
  • PipPipPipPipPip
  • 1,787 posts
  • Location:Southern California
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 22 February 2004 - 01:10 AM

Well I hate it, take it out tongue.gif

I quess I can live with it then. Actually, this could be usefull when you writing scripts and are using an XML with some sort of index. You'll have an index count readily available.

Edited by flattspott, 22 February 2004 - 01:12 AM.


#12 geniusalz

geniusalz

    Team MXM

  • Head Moderators
  • PipPipPipPipPip
  • 1,827 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:unknown

Posted 22 February 2004 - 03:36 AM

You could take them out when saving, and put them back in on load, if required.
Anyway, what're ActionDraw lists? Haven't been keeping up lately.

#13 BenJeremy

BenJeremy

    X-S Elysian

  • Head Moderators
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 9,690 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:v1 (xenon)

Posted 22 February 2004 - 04:28 AM

QUOTE (geniusalz @ Feb 22 2004, 12:36 AM)
You could take them out when saving, and put them back in on load, if required.
Anyway, what're ActionDraw lists? Haven't been keeping up lately.

It's the stuff between "BeginDraw" and "EndDraw" in your ActionScripts.

That's how I render the scenes with ActionScripts - I track the ACTIONs you DRAW in a LIST of commands and parameters, then every time I have to render a frame, I simply re-draw each item.

That may yet get some tweaking as well, but there's other stff to wrap up before I play with that yet.



#14 geniusalz

geniusalz

    Team MXM

  • Head Moderators
  • PipPipPipPipPip
  • 1,827 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:unknown

Posted 22 February 2004 - 04:50 AM

QUOTE (BenJeremy @ Feb 22 2004, 01:28 AM)
That's how I render the scenes with ActionScripts  - I track the ACTIONs you DRAW in a LIST of commands and parameters, then every time I have to render a frame, I simply re-draw each item.

laugh.gif

#15 Kthulu

Kthulu

    X-S Freak

  • XS-BANNED
  • PipPipPipPipPip
  • 1,287 posts
  • Xbox Version:v1.0
  • 360 version:unknown

Posted 07 March 2004 - 09:02 PM

thought i was gonna whip up a little script real quick, but ran into a problem. here's an example of the problem...
CODE

XMLCreate TestXML Main
XMLSetValue TestXML !.Item.One "This is the value of item one."
XMLSave TestXML f:\dashboards\mxm\scripts\test.xml
XMLClose TestXML

produces...
QUOTE

<main>
<item>
<one>
<value>This is the value of item one.</value>
</one>
</item>
</main>

is that supposed to happen now? (the <value>...</value> tags)?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users