John Salerno wrote:[color=blue]
> Hi everyone. I thought I might do a little experiment with XML and type
> up some rules for syntax formatting for a programming language. But I'm
> a little confused about how to format the XML file. My first thought was
> I might do this in HTML instead, and I think I sort of wrote the XML
> file with HTML syntax in mind. Needless to say, nothing is nested properly:
>
> <?xml version='1.0' encoding='utf-8'?>
>
> <category>Code Layout</category>
>
> <subcategory>Indentation</subcategory>
> <rule>Use 4 spaces per indentation level.</rule>[/color]
This is generally counterproductive. XML works on the basis of
hierarchies and containers (think DIVs), so better would be
<subcategory>
<name>Indentation</name>
<rule>Use 4 spaces per indentation level.</rule>
</subcategory>
However, if you want to use the XML in processing, rather than just
document things, you need to phrase it so a machine can read it:
<subcategory>
<name>Indentation</name>
<rule class="textindent" lang="css" value="4" units="em"/>
</subcategory>
[...][color=blue]
> My question is, how do I have text within an element like <category>,[/color]
Just type it. But in practice, for an XML document going to be used as
data, mixing text and markup is A Bad Idea. It's normal for text
documents (eg HTML) but for XML-used-as-data is will only lead to tears
and recriminations.
[color=blue]
> which should actually be the entire parent node of the file? Am I not
> supposed to have text in it? What would be the proper way to do this?
>
> I am thinking of something like this:
>
> <h1>Code Layout</h1>
> <h2>Indentation</h2>
> <p>Use 4 spaces per indentation level.</p>[/color]
Not useful.
///Peter
--
XML FAQ:
http://xml.silmaril.ie/