Skip to main content
GameDev.net gamedev.net
🔒 Locked

comments in xml

Started by aboeing Jul 5, 2004 at 9:59 AM 7 replies 750+ views
Original Post
aboeing
aboeing
Hi, not sure if this is the best forum, but: Does anyone know of a #if 0 equivalent for XML? (you cant have a nested ) Cheers. (yes - I am too lazy to read the specs) edit: brackets
Mulligan
Mulligan
are you talking about C# xml comments? If you are, im still not sure what youre asking. More info please.
evolutional
evolutional
I'm not sure I get your question...

The specs

Definition: Comments MAY appear anywhere in a document outside other markup; in addition, they MAY appear within the document type declaration at places allowed by the grammar. They are not part of the document's character data; an XML processor MAY, but need not, make it possible for an application to retrieve the text of comments. For compatibility, the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity references MUST NOT be recognized within comments.Comments[15]    Comment    ::=    '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->' An example of a comment:<!-- declarations for <head> & <body> -->Note that the grammar does not allow a comment ending in --->. The following example is not well-formed.<!-- B+, B, or B--->


EDIT: Browser ate my comments - WTF... used source tags
Arild Fines
Arild Fines
As far as I know, there is no such thing. Make sure to match your comment tags instead.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
aboeing
aboeing
Thanks for the replies, just to clarify what I meant:
I wanted to be something that would be the equivalent of:
&lt--
some xml
&lt--
some more xml
-->
-->

But as you can see from the specs which evolutional kindly posted, you cant have a '--' sequence within a comment, so you cant have a comment which surrounds another comment.
I was just wondering if there was any other way around this.
(eg: in C you can make comments with /*,*/ but you can make comments around that comment by using #if 0, #endif - I was looking for a similar thing for XML)
clum
clum
Is there some reason why you want to? I don't believe I've ever done #if 0 in C
Zorx (a Puzzle Bobble clone)Discontinuity (an animation system for POV-Ray)
aboeing
aboeing
Basically: I'm lazy.
I use #if 0 for testing all the time, and thats why I want it for the xml file, because I have xml comments describing whats happening in my xml file (its a startup scrip type thing), and I want to not-do bits of it for testing purposes: the easiest way to achieve this would be to comment out those sections.
Its not a big deal, It just means I need to make back-up copies of the xml script all the time.
DrPizza
DrPizza
Quote:
Original post by clum
Is there some reason why you want to? I don't believe I've ever done #if 0 in C

Because they nest. /* */ does not. And nested comments are often a useful thing to have, because often commenting is done on a temporary basis (just to skip a block of code you know to be problematic or slow or otherwise not interesting to you so that you can concentrate on the task at hand).
char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;} /*** drpizza@battleaxe.net ***/
evolutional
evolutional
XML is used only as a data definition source - by nature it's a static dataset and there isn't any capability to introduce this sort of dynamicity.

If you want to do this sort of thing, you'll have to use XSLT which performs conditional transformations on a given XML dataset.

So in short, no - there is no way to nest comments or introduce the sort of feautre you want using just raw XML.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.