xboxscene.org forums

OG Xbox Forums => Official MediaXMenu (MXM) Forum => Dashboard Forums => MXM WIP Beta forum => Topic started by: BenJeremy on February 21, 2004, 12:11:00 PM

Title: Important! Changes In XML Handling!
Post by: BenJeremy on February 21, 2004, 12:11:00 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.
Title: Important! Changes In XML Handling!
Post by: flattspott on February 21, 2004, 12:38:00 PM
Gonna go check it out in second or two.
Title: Important! Changes In XML Handling!
Post by: flattspott on February 21, 2004, 01:05:00 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>
Title: Important! Changes In XML Handling!
Post by: BenJeremy on February 21, 2004, 01:10:00 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.
Title: Important! Changes In XML Handling!
Post by: flattspott on February 21, 2004, 01:15:00 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?
Title: Important! Changes In XML Handling!
Post by: geniusalz on February 21, 2004, 01:23:00 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
Title: Important! Changes In XML Handling!
Post by: flattspott on February 21, 2004, 03:39:00 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.
Title: Important! Changes In XML Handling!
Post by: BenJeremy on February 21, 2004, 04:36:00 PM
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
Title: Important! Changes In XML Handling!
Post by: flattspott on February 21, 2004, 04:54:00 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.
Title: Important! Changes In XML Handling!
Post by: BenJeremy on February 21, 2004, 04:59:00 PM
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.
Title: Important! Changes In XML Handling!
Post by: flattspott on February 21, 2004, 05:10:00 PM
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.
Title: Important! Changes In XML Handling!
Post by: geniusalz on February 21, 2004, 07:36:00 PM
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.
Title: Important! Changes In XML Handling!
Post by: BenJeremy on February 21, 2004, 08:28:00 PM
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.

Title: Important! Changes In XML Handling!
Post by: geniusalz on February 21, 2004, 08:50:00 PM
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
Title: Important! Changes In XML Handling!
Post by: Kthulu on March 07, 2004, 01:02:00 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)?
Title: Important! Changes In XML Handling!
Post by: flattspott on March 07, 2004, 01:20:00 PM
CODE
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)
Title: Important! Changes In XML Handling!
Post by: Kthulu on March 07, 2004, 01:26:00 PM
thanks! that did the trick!
Title: Important! Changes In XML Handling!
Post by: BenJeremy on March 07, 2004, 01:29:00 PM
Yes, the "location" specifier is now more specific in determining where to place things....


"~" indicates attribute, "^" indicates element.

Don't forget the new Query features... it will save you a lot of trouble in scripts.
Title: Important! Changes In XML Handling!
Post by: flattspott on March 07, 2004, 01:39:00 PM
Can the Query be use for things other then attributes?

Like !.submeu.item?title=applications
Title: Important! Changes In XML Handling!
Post by: BenJeremy on March 07, 2004, 02:26:00 PM
QUOTE (flattspott @ Mar 7 2004, 06:39 PM)
Can the Query be use for things other then attributes?

Like !.submeu.item?title=applications

Yes, queries on elements work, too...

Title: Important! Changes In XML Handling!
Post by: flattspott on March 07, 2004, 02:39:00 PM
Cool, I wondered if that would work
Title: Important! Changes In XML Handling!
Post by: chilin_dude on March 18, 2004, 11:18:00 AM
Can someone tell me if it is possible to get the game icon to display from an inserted disk? If so what is the command as I am going to try to add this to the game copy script so it shows a picture of the game when it is copieng.
Thanks in advance!
Title: Important! Changes In XML Handling!
Post by: flattspott on March 18, 2004, 01:56:00 PM
Well if you're a WIP tester, you could do something like the testdialog. All you got to do is select an XBE file and the image shows up just like another other image file
Title: Important! Changes In XML Handling!
Post by: chilin_dude on March 19, 2004, 05:46:00 AM
QUOTE (flattspott @ Mar 18 2004, 11:56 PM)
Well if you're a WIP tester, you could do something like the testdialog. All you got to do is select an XBE file and the image shows up just like another other image file

All I want to know if there is what is the command to display the XBE icon...
I am a wip tester.