• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Alpha_ProgDes

Is this valid XML?

17 posts in this topic

I know you can have:

[code]<name>Sam</name>[/code]

and

[code]<name>
<nickname>Wooty</nickname>
<nickname>Yogi</nickname>
<nickname>Chi-Lite</nickname>
</name>
[/code]
but is this valid/legal:

[code]<name>Sam
<nickname>Wooty</nickname>
<nickname>Yogi</nickname>
<nickname>Chi-Lite</nickname>
</name>[/code]
0

Share this post


Link to post
Share on other sites
Well the [url=http://validator.w3.org/]W3C validator[/url] accepts it as long as you give slap a version tag on it first.
2

Share this post


Link to post
Share on other sites
yes ... xml allows mixed content definitions for tags ... like this valid xhtml snippet

<div>And once he finally laid hands on <a href="daggers_of_ice.html">it</a> he felt a nearly irresistible compulsion to flee.</div>

it just isn't very desirable to do these types of formats when the focus is on data modelling / interchange vs markup.
1

Share this post


Link to post
Share on other sites
Just out of curiosity, what exactly are you doing with said XML?

(Just remember... XML is like violence. If it doesn't work, you just aren't using enough of it...)
2

Share this post


Link to post
Share on other sites
Well really this is for a FSM I'm working on.

Basically I wanted it to look like this:

[code]<state>
<name>Assign Responsible</name>
<transition>Notify Responsible
<trigger_value>Open</trigger_value>
<trigger_value>Need Acknownledgement</trigger_value>
</transition>
<action>email</email>
</state>[/code]

Where [b]name[/b] = state of current state, [b]transition[/b] = name of the next state to move to, [b]trigger_value[/b] = values needed to move to next state, [b]action[/b] = any additional activity that must be performed while in current state.
0

Share this post


Link to post
Share on other sites
Personally, I'd go for something like this:
[code]
<transition target="Notify Responsible">
<trigger_value>Open</trigger_value>
<trigger_value>Need Acknownledgement</trigger_value>
</transition>[/code]
1

Share this post


Link to post
Share on other sites
[code]
<transition>
<target>Notify Responsible</target>
<trigger_value>Open</trigger_value>
<trigger_value>Need Acknowledgement</trigger_value>
</transition>[/code]

Is this more "acceptable" or is the difference between yours and mine a stylistic one?
0

Share this post


Link to post
Share on other sites
[quote name='Alpha_ProgDes' timestamp='1316048061' post='4861823']
[code]
<transition>
<target>Notify Responsible</target>
<trigger_value>Open</trigger_value>
<trigger_value>Need Acknowledgement</trigger_value>
</transition>[/code]

Is this more "acceptable" or is the difference between yours and mine a stylistic one?
[/quote]
There's no real difference. For short, single, simple types an attribute is valid, for child nodes, long values or multiple values of the same type, sub nodes are preferable. What are your design goals ? Manual edited xml files, error robust files, easy to read, fast to read, small memory footprints ?

One tip: consider to use [url="http://www.w3schools.com/schema/"]xml schema [/url]from the beginning to make your xml files schema conform and get some automatically xml file validation.
0

Share this post


Link to post
Share on other sites
[quote name='ApochPiQ' timestamp='1316055669' post='4861859']
Parsing blended CDATA and tags is a bit cumbersome in most libraries I've used, if that weighs into your decision any.
[/quote]
I'm a beginner when it comes to XML. So though I've [b]seen[/b] CDATA tags before, they won't be showing up in this XML... ever.
0

Share this post


Link to post
Share on other sites
[quote name='Ashaman73' timestamp='1316066715' post='4861915']
[quote name='Alpha_ProgDes' timestamp='1316048061' post='4861823']
[code]
<transition>
<target>Notify Responsible</target>
<trigger_value>Open</trigger_value>
<trigger_value>Need Acknowledgement</trigger_value>
</transition>[/code]

Is this more "acceptable" or is the difference between yours and mine a stylistic one?
[/quote]
There's no real difference. For short, single, simple types an attribute is valid, for child nodes, long values or multiple values of the same type, sub nodes are preferable. What are your design goals ? Manual edited xml files, error robust files, easy to read, fast to read, small memory footprints ?

One tip: consider to use [url="http://www.w3schools.com/schema/"]xml schema [/url]from the beginning to make your xml files schema conform and get some automatically xml file validation.
[/quote]
This is a file that I would like to be (or can be): manually editable, easy to read, fast to read (for a human), and easy to XPath.
0

Share this post


Link to post
Share on other sites
It's well-formed. If there is only one root element. The above snippets are well-formed.

Valid XML requires a schema.

[quote]XPath[/quote]
Needs a schema.
0

Share this post


Link to post
Share on other sites
.NET must be very lax then. Because I did XPath on XML that I wrote and it didn't scream at me.

Though, I'm pretty sure that I missed your point.
0

Share this post


Link to post
Share on other sites
Goto W3Schools, they have alot on XML and other related tech. Simple straightforward examples. Great place to learn the basics.

[url="http://www.w3schools.com/"]http://www.w3schools.com/[/url]
-1

Share this post


Link to post
Share on other sites
[quote name='Alpha_ProgDes' timestamp='1316116244' post='4862191']
.NET must be very lax then. Because I did XPath on XML that I wrote and it didn't scream at me.

Though, I'm pretty sure that I missed your point.
[/quote]

So few ever write valid XML that any real world parser needs to ignore validity and work with what it's got. Ideally, tools would reject all non-valid XML, but considering there were competing specs and standards, many of them pushed by heavyweights like IBM and Oracle, neither would cede and result in multiple exclusive yet standard-compliant and incompatible XML documents. People in the trenches got yelled when enterprise_big_arcane_soap_rfc service suddenly couldn't talk to another_enterprise_soap_provider and rigged them together into enterprise_grade_service_that_works_for_us_and_keeps_management_happy. Of course, when such company sold, there were now 3 incompatible XML providers...

This led to XML ecosystem being a complete mess and is generally being abandoned in favor of JSON by anyone who can do so.

XML makes sense if it's completely and correctly implemented. Otherwise it's just an unreadable tag soup, which is why it's universally hated, despite generally being a "Good Idea".

Similar idea. Ask any seasoned veteran and they'll agree it's a good idea, but the result in practice is just a useless mess that everyone abandoned.


IMHO - either implement XML fully and correctly so it passes all validations, including DTDs, published namespace and schema
or - use JSON.

JSON supports schemas or something similar, but parsers are allowed to be lax in what they accept. It does lack in the tooling department, but is not verbose, so complex tools aren't needed and grep gets you far.
0

Share this post


Link to post
Share on other sites
[quote name='Net Gnome' timestamp='1316116470' post='4862194']
Goto W3Schools, they have alot on XML and other related tech. Simple straightforward examples. Great place to learn the basics.
[/quote]
Be careful about using W3Schools as a learning resource or reference, as there are a lot of problems with the information presented -- see [url="http://w3fools.com/"]"W3Fools"[/url] for further information. W3Schools can still be useful, but do take anything you read there with a grain of salt and be sure to check other sources.


0

Share this post


Link to post
Share on other sites
[quote name='Alpha_ProgDes' timestamp='1316048061' post='4861823']
[code]
<transition>
<target>Notify Responsible</target>
<trigger_value>Open</trigger_value>
<trigger_value>Need Acknowledgement</trigger_value>
</transition>[/code]

Is this more "acceptable" or is the difference between yours and mine a stylistic one?
[/quote]
It's not really any more or less acceptable, just stylistic.


I might just stretch so far as to say that it's mine that may be more widely preferred, my intuition is that there are more guidelines out there something along the lines of:
Use an attribute over a nested element when:
* There's no more than 1 occurance permitted
* If it's mandatory
* When the content of the property is short and 'inline-able' like a number or a name.

The target property fits that description, but the trigger_value doesn't since you permit a variable number of them.

These are just ad-hoc rules though, it doesn't really make much difference. Some schemas allow you to specify a value either as an attribute or as a sub-element which allows the author to decide which is better.
0

Share this post


Link to post
Share on other sites
[quote name='jbadams' timestamp='1316162116' post='4862354']
Be careful about using W3Schools as a learning resource or reference, as there are a lot of problems with the information presented -- see [url="http://w3fools.com/"]"W3Fools"[/url] for further information. W3Schools can still be useful, but do take anything you read there with a grain of salt and be sure to check other sources. [/quote]

While they do point out a few issues, advice which lists: "Professional web developers do not recommend the use of WYSIWYG editors. " should be taken with a grain of salt as well.

The same crowd would scoff at anyone who ever in their career used anything but emacs or vi. The comments are way too similar to Ruby hipster crowd for my liking.

It reminds of various edge cases in C++. They make for endless debates, but are ultimately useless, because beginners will get stuck at linker error and MSVCRT redistributable problem.

Also, XML sections are not touched by W3Fools, since cool people don't touch XML. Which by default excludes anything even remotely related to any serious business or enterprise. If your font doesn't downgrade properly on IE8.1b2 nobody cares, but if your SOAPs are incompatible the servers will clog up and all your customers won't be able to pay. So, priorities...
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0